Terraform apply running out of order

When using the aws provider. I am building a new vpc, and subnet. As of late it seems to run the resources out of order. It will try to create the “aws_subnet” before the “aws_vpc” thus causing the apply to fail. This wasn’t a problem until the last couple of weeks. Everything seems to try to create out of order.

As long as you reference resources in other resources, the dependency order is maintained.
By default, Terraform tries to do “maximum parallelization”, so if you are not referencing parent resources inside child resources, then things could fail.

It would be good to know the versions of Terraform and the AWS provider. Also a minimal hcl config of what you are attempting might be helpful to debug.

The version of terraform being used is 0.12.13. The aws provider is terraform-provider-aws_v2.36.0_x4

If you’re not already I’d add the depends_on attribute to resources you want to run in a specific order. Terraform does a good job of knowing what should build in what order but as a standard practice I always use depends_on when possible.

1 Like

Thank you! That worked perfectly!

1 Like