O'Reilly logo

Getting Started with Terraform by Kirill Shirinkin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Playing with Terraform graph

Let's play around with our VPC a bit to better understand how resource dependencies are handled. Instead of adding a subnet, let's destroy complete infrastructure we have so far and then plan creation from scratch:

$> terraform destroy
$> terraform plan
      # ... 
+ aws_subnet.public
    availability_zone:       "<computed>"
    cidr_block:              "10.0.1.0/24"    map_public_ip_on_launch: "false"
    vpc_id:                  "${aws_vpc.my_vpc.id}"
# ...

Terraform doesn't know the VPC ID yet, so it doesn't show it to you in the plan. Let's apply the template and observe the order of resource creation:

$> terraform apply
aws_vpc.my_vpc: Creating...
  cidr_block:                "" => "10.0.0.0/16"
  default_network_acl_id:    "" => "<computed>"
 default_security_group_id: "" => "<computed>" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required