Terraform State Best Practices
1. Terraform State Best Practices
Let’s explore some best practices for Terraform state optimization and security. First, use remote state for team environments, so that you can lock and version state files. Google Cloud customers should use the Cloud Storage state backend to lock the state, separate sensitive information from version control, and ensure that only the build system and highly privileged administrators have access to the remote state bucket. To prevent accidentally committing development state to source control, use gitignore for Terraform state files. Don't store secrets in a state. Many resource and data providers store secret values in plain text in the state file. Where possible, avoid storing secrets in a state file. To add an extra layer of defense, always encrypt the state file. Even though Cloud Storage buckets are encrypted at rest, customer-supplied encryption keys provide an added layer of protection. Don’t modify Terraform state manually. The state file is critical for maintaining mapping between the Terraform configuration and Google Cloud resources. Corruption can lead to major infrastructure problems.2. Let's practice!
Create Your Free Account
or
By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.