Terraform 0.11 has been released... and is backwards incompatible

Terraform 0.11 has been released and while it has some nice improvements, it also has two major backwards incompatibilities:

  1. The apply command is now interactive by default. It actually first runs plan and then prompts the user to manually approve the plan before applying the changes. If you are using Terraform as part of an automated CI/CD process (and if you’re a Gruntwork customer, you probably are!), this will cause problems. The workaround is to add -auto-approve to the apply call.

  2. Terraform will now exit with an error if you have a resource with a count parameter set to anything other than 1 and you try to reference that resource using the syntax TYPE.NAME.ATTRIBUTE, as opposed to TYPE.NAME.*.ATTRIBUTE. The old syntax used to work fine, so this breaks a lot of code, including many Gruntwork modules. Worse yet, it’s very hard to find this error, as using count is a very common pattern in Terraform, and the error only happens at runtime and only if count happens to not be set to 1. We’ve filed a bug with the hopes that HashiCorp either reverts this behavior, or at the very least, provides tooling to find these errors via validate or plan, instead of waiting for things to blow up after running apply.

In the meantime, we do NOT recommend users upgrade to Terraform 0.11.

Update: In response to the bug we filed, HashiCorp has released Terraform 0.11.1, with a couple improvements:

  1. Using “singleton” syntax with any resource that has a count parameter will now issue a warning no matter what value count is set to. This will make it easier to track these cases down.

  2. You can now set the TF_WARN_OUTPUT_ERRORS environment variable to 1 so that instead of an error, you get a warning.

We will begin going through our modules and updating them to the 0.11 syntax and will report back when we’re done. If you desperately need to use Terraform 0.11 before we’re done with this process, use the workaround in (2).