Terraform
Terraform tracks your infrastracture with state files. These state files are the source of truth of your infrastructure.
Sources
- https://github.com/devops-cheat-sheets/terraform-cheat-sheet
- https://www.pluralsight.com/resources/blog/cloud/the-ultimate-terraform-cheatsheet
- https://developer.hashicorp.com/terraform/intro
- https://developer.hashicorp.com/terraform/language/state
Commands
| Command | Description | Example |
|---|---|---|
| terraform init | Initialize working directory (install modules, providers) | |
| terraform login | Login to Terraform Cloud | |
| terraform plan | Create execution plan | |
| terraform apply | Applies changes to reach desired state | |
| terraform apply -target= | Apply specific resource/target | |
| terraform apply -auto-approve | Applies changes, no approval required | |
| terraform fmt | Format .tf files | |
| terraform import | Import existing infrastracture into Terraform State | terraform import aws_s3_bucket.bucket mybucket |
| terraform output | Show output variables from Terraform State | |
| terraform apply -var ‘variable=value’ | Set variable from CLI | |
| terraform apply -var-file=file | Set variables via File (prod.tfvars) | |
| terraform state | Advanced Terraform State Management | |
| terraform state list | List resources in state |