Skip to content

Terraform

Terraform tracks your infrastracture with state files. These state files are the source of truth of your infrastructure.

Sources

Commands

CommandDescriptionExample
terraform initInitialize working directory (install modules, providers)
terraform loginLogin to Terraform Cloud
terraform planCreate execution plan
terraform applyApplies changes to reach desired state
terraform apply -target=Apply specific resource/target
terraform apply -auto-approveApplies changes, no approval required
terraform fmtFormat .tf files
terraform import Import existing infrastracture into Terraform Stateterraform import aws_s3_bucket.bucket mybucket
terraform outputShow output variables from Terraform State
terraform apply -var ‘variable=value’Set variable from CLI
terraform apply -var-file=fileSet variables via File (prod.tfvars)
terraform stateAdvanced Terraform State Management
terraform state listList resources in state