Terraform is a source-available Infrastructure as Code (IaC) tool that allows users to define, provision, and manage infrastructure comments like virtual machines, networks, databases, DNS entries, Kubernetes (K8s), and SaaS integrations using Declarative Configuration files rather than manual setup processes.
Note: Hashicorp switched Terraform to a Business Source License 1.1
Useful Commands
terraform initis required to initialize the directoryterraform fmtwill clean up the code visuallyterraform validatewill validate the code to ensure it’s functional, checking for invalid or missing requirementsterraform planprints what’ll be created, destroyed, or modified on deployment- Add argument
-out <PATH>to create a plan file - IMPORTANT: The saved plan doesn’t encrypt data like API keys, and should be encrypted if shared
- Add argument
terraform applyto apply what’s planned- Add argument
<PATH>to apply from a create plan
- Add argument
Note: Any
terraformcommand can use-chdir=path/to use configs in sub directories while still accessing files in the current directory, such as secrets.