terraform

abstract

Terraform is a program which tracks and updates cloud-computing resources.

basics

commands

terraform apply [FOLDER] update all resources declared in [FOLDER]
terraform console [FOLDER] start interactive console (for debugging)
terraform destroy [FOLDER] deactivate every resource declared in [FOLDER]
terraform fmt [FOLDER] autoformat all .tf files in [FOLDER]
terraform init [FOLDER] install modules and do any necessary initialization
terraform output [VARIABLE] show output variable(s)
terraform plan [FOLDER] predict what apply [FOLDER] will do
terraform show show current state (might include secrets!)
terraform taint [RESOURCE] mark [RESOURCE] as broken, stale, and/or unsafe
terraform untaint [RESOURCE] undo terraform taint [RESOURCE]

dependencies

examples

Autoformat staging folder and check for errors.

terraform fmt staging
terraform validate staging

Save an execution plan for the staging folder, then show the plan in JSON format.

terraform plan -out myplan staging
terraform show -json myplan

Destroy and rebuild some_resource which was declared in the staging folder.

terraform taint some_resource
terraform apply staging

Apply changes to staging folder without being prompted to confirm.

terraform apply -auto-approve staging

faq

Where are the official docs?
Terraform Commands (CLI)
Email GitHub LinkedIn
return
© Sam Kennerly 2023. Licensed under a CC BY 4.0 license.
Built by a Quarto
with icons by Simple Icons.
samkennerly@gmail.com