Difference between revisions of "Terraform best practices"

From wikieduonline
Jump to navigation Jump to search
Line 15: Line 15:
 
* Use built-in formatting: <code>[[terraform fmt]]</code>
 
* Use built-in formatting: <code>[[terraform fmt]]</code>
 
* Limit the complexity of expressions.
 
* Limit the complexity of expressions.
* Use <code>[[count]]</code> for conditional values.
+
* Use <code>[[Terraform meta argument: count|count]]</code> for conditional values.
 
* 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]].

Revision as of 14:49, 22 January 2023

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: