0% found this document useful (0 votes)
318 views

Terraform Cheatsheet 1

This document provides a cheatsheet for common Terraform commands. It summarizes initializing Terraform to apply configuration, producing a plan to preview changes, and managing the Terraform state. Key commands include "terraform init" to initialize working directory, "terraform plan" to preview changes, and "terraform apply" to apply the configuration. It also lists commands for viewing, importing, pulling, and pushing the Terraform state.

Uploaded by

jhixs blake
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
318 views

Terraform Cheatsheet 1

This document provides a cheatsheet for common Terraform commands. It summarizes initializing Terraform to apply configuration, producing a plan to preview changes, and managing the Terraform state. Key commands include "terraform init" to initialize working directory, "terraform plan" to preview changes, and "terraform apply" to apply the configuration. It also lists commands for viewing, importing, pulling, and pushing the Terraform state.

Uploaded by

jhixs blake
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

initilize terraform apply terraform

the essential
initialize terraform in the current working directory apply the current state of terraform code
Terraform terraform init terraform apply

Cheatsheet
skip plugin installation specify a previously generated plan to apply
terraform init -get-plugins=false terraform apply current.tfplan
by justin o’connor force plugin installation from a directory enable auto-approval or automation
terraform init -plugin-dir=PATH terraform apply -auto-approve

upgrade modules and plugins at initilization


general commands terraform init -upgrade

update backend configuration


destroy terraform
get the terraform version terraform init -migrate-state -force-copy
terraform version destroy resources managed by terraform state
skip backend configuration terraform destroy
download and update root modules terraform init -backend=false
terraform get -update=true enable auto-approval or automation
use a local backend configuration terraform destroy -auto-approve
open up a terraform interactive terminal terraform init -backend-config=FILE
terraform console
change state lock timeout (default is zero seconds)
create a dot diagram of terraform dependencies terraform init -lock-timeout=120s manage terraform state
terraform graph | dot -Tpng > graph.png

format terraform code to HCL standards list all resources in terraform state
terraform fmt plan terraform terraform state list

validate terraform code syntax show details about a specific resource


terraform validate produce a plan with diff between code and state terraform state show ADDRESS
terraform plan
enable tab auto-completion in the terminal track an existing resource in state under new name
terraform -install-autocomplete output a plan file for reference during apply terraform state mv SOURCE DESTINATION
terraform plan -out current.tfplan
show infromation about provider requirements import a manually created resource into state
terraform providers output a plan to show effect of terraform destroy terraform state import ADDRESS ID
terraform plan -destroy
login and logout of terraform cloud pull state and save to a local file
terraform login and terraform logout target a specific resource for deployment terraform state pull > terraform.tfstate
terraform plan -target=ADDRESS
push state to a remote location
note that the -target option is also available for the terraform state push PATH
workspaces terraform apply and terraform destroy commands.
replace a resource provider
terraform state replace-provider A B
list the available workspaces
taint a resource to force redeployment on apply
outputs
terraform workspace list
terraform taint ADDRESS
create a new workspace
terraform workspace new development list available outputs untaint a prevoiusly tainted resource
terraform output terraform untaint ADDRESS
select an existing workspace
terraform workspace select default output a specific value
terraform output NAME Version 1 https://justinoconnor.codes

You might also like