Testing-best-practices Idempotent Terraform

A Terraform configuration is idempotent when a second apply results in 0 changes. A idempotent configuration ensures that:

  1. What you define in Terraform is exactly what is being deployed.
  2. Detection of bugs in Terraform resources and providers that might affect your configuration.

You can use Terratest’s terraform.ApplyAndIdempotent() function to both apply your Terraform configuration and test its idempotency.

terraform.ApplyAndIdempotent(t, terraformOptions)

If a second apply of your Terraform configuration results in changes then your test will fail.

Built by Gruntwork

Your entire infrastructure. Defined as code. In about a day.