OnCallReady

Commands

terraform - build, change and destroy infrastructure as code

terraform [-chdir=DIR] <init|validate|plan|apply|destroy|fmt|console|output|show|state|import|workspace|test|graph|providers|version|force-unlock|get> [options]

Options you will use

init [-upgrade] [-reconfigure|-migrate-state] [-backend-config=...]
providers, modules, backend
plan [-out=FILE] [-var ...] [-var-file ...] [-target=ADDR] [-replace=ADDR] [-refresh-only] [-destroy] [-detailed-exitcode] [-lock-timeout=DUR]
show the changes
apply [FILE] [-auto-approve]
make the changes (a saved plan applies exactly that plan)
state list|show|mv|rm|pull|push|replace-provider
inspect and change state
workspace list|new|select|show|delete
CLI workspaces
test [-filter=FILE] [-verbose]
run *.tftest.hcl tests
-chdir=DIR
Switch to a different working directory before executing the given subcommand (must come BEFORE the subcommand).
-help
Show this help output, or the help for a specified subcommand.
-version
An alias for the "version" subcommand.

Examples

$ terraform plan -out=tfplan && terraform apply tfplan

review, then apply exactly that plan

$ terraform show -json tfplan | jq ...

the plan as JSON, for gates

$ TF_LOG=DEBUG TF_LOG_PATH=tf.log terraform plan

debug logging to a file

Taught in

Try terraform in a real terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.