Simulating infrastructure changes using Terraform
In an earlier recipe, you learned how to manage different environments with Terraform, which is great. But how do we test for changes before applying them?
Terraform has a great internal mechanism that allows us to plan for changes by comparing what our infrastructure code wants and what the remote state includes. That way, we can safely check whether what we thought was a minor modification in our code has in fact a destructive impact (sometimes, some parameters in a resource trigger a full destruction of the resource!).
We'll cover different ways of anticipating, simulating, and targeting changes in our infrastructure, as an added safety check before applying the changes for good.
Getting ready
To step through this recipe, you will need the following:
A working Terraform installation
An AWS account with an SSH key configured in Terraform (refer to the Chapter 2, Provisioning IaaS with Terraform recipes)
An Internet connection
How to do it…
Let's...