Difference between revisions of "Terraform best practices"

From wikieduonline
Jump to navigation Jump to search
Tags: Mobile web edit, Mobile edit
Line 2: Line 2:
 
* https://www.terraform.io/cloud-docs/guides/recommended-practices
 
* https://www.terraform.io/cloud-docs/guides/recommended-practices
  
== Best practices from Google Cloud team ==
+
=== Best practices from Google Cloud team ===
 
https://cloud.google.com/docs/terraform/best-practices-for-terraform
 
https://cloud.google.com/docs/terraform/best-practices-for-terraform
 
* Protect [[stateful resources]]: <code>[[lifecycle]] { [[prevent_destroy]] = true }</code>
 
* Protect [[stateful resources]]: <code>[[lifecycle]] { [[prevent_destroy]] = true }</code>
Line 18: Line 18:
 
* Use <code>[[for_each]]</code> for iterated resources.
 
* Use <code>[[for_each]]</code> for iterated resources.
 
* Publish [[modules]] to a [[registry]].
 
* Publish [[modules]] to a [[registry]].
 +
 +
 +
== Operations ===
 +
* Don't modify [[Terraform state]] manually.
 +
* Always plan first.
 +
* Implement an automated pipeline.
 +
* Use service account credentials for CI.
 +
* Avoid importing existing resources.
 +
* Regularly review version pins.
 +
* Use application default credentials when running locally.
 +
* Set aliases to Terraform.
  
 
== Related ==
 
== Related ==

Revision as of 07:16, 18 July 2022

Best practices from Google Cloud team

https://cloud.google.com/docs/terraform/best-practices-for-terraform


Operations =

  • Don't modify Terraform state manually.
  • Always plan first.
  • Implement an automated pipeline.
  • Use service account credentials for CI.
  • Avoid importing existing resources.
  • Regularly review version pins.
  • Use application default credentials when running locally.
  • Set aliases to Terraform.

Related

See also

Advertising: