Using Terraform State Files

Link dynamic parameter values to Terraform State Files within S3

One practical use of CloudTruth dynamic values is the ability to automatically reference Terraform state outputs. These outputs are normally generated and stored by the Terraform tool in a file named terraform.tfstate.HashiCorp provides the ability for Terraform state files to be stored remotely. AWS S3 is a common choice for remote storage, and is often considered a best practice, especially when working with multiple users that may depend upon Terraform state outputs for CI/CD.

Using dynamic values allows you to manage parameters within CloudTruth and populate them from external sources, in this case terraform state files stored in AWS S3. Once dynamic parameter references have been created, any parameter access will fetch the the value from the latest Terraform state on-demand. This includes parameter references from within the Template mechanism that enables you to generate configuration files per-environment as needed.

Use the following steps to begin using Terraform state with CloudTruth:

  1. Setup S3 as the remote state backend for terraform. Details from HashiCorp can be found here.

  2. Add outputs to Terraform, and apply. Learn about Terraform outputs here.

  3. Setup an AWS role to grant access to your S3 bucket. Learn about this here

  4. Setup an S3 Integration in CloudTruth and create dynamic parameter references to outputs within your state file. Learn about this here

Once these steps are complete, you can begin to simplify your configuration by eliminating static configuration files which require frequent updates. You will be able to keep up-to-date with the latest TF state, without writing specialized configuration code.