code-dumps/terraform/aws-vpc
2020-04-23 10:36:56 +08:00
..
provider.tf NEW: vpc-subnet 2020-04-23 10:36:56 +08:00
README.md NEW: vpc-subnet 2020-04-23 10:36:56 +08:00
terraform.tfstate.backup NEW: vpc-subnet 2020-04-23 10:36:56 +08:00
tfgraph.png NEW: vpc-subnet 2020-04-23 10:36:56 +08:00
vpc-subnets.tf NEW: vpc-subnet 2020-04-23 10:36:56 +08:00

Terraform config for creating VPC and subnets

These config will create the following resources on AWS. The VPC CIDR is hard-coded as 10.0.0.0/16. The number of subnets are also hard-coded. The subnets will sit in different availablity zones for redundancy.

  • 1 VPC
  • 2 public subnets
  • 2 private subnets
  • 1 internet gateway
  • 1 nat gateway

Variables to TF

These are required variables:

aws_access_key = "redacted"
aws_secret_key = "redacted"
aws_region = "ap-southeast-1"
resource_prefix = "project1-dev"

TF graph

Here is what the graph looks like tf graph

Revision notes

  • Previously terraform plan would fail to compute the count for routing table association. This is now corrected by hard-coding count to 2.