Terraform CLI Cheat sheet
terraform init
terraform init --backend
terraform fmt
terraform validate
terraform graph > graph.dot
terraform refresh
Fetches the current state of the resources and updates the state file.
terraform plan
terraform plan --out=file_obs_path
terraform plan --refresh=false # will disable querying the current state during plan
terraform plan --target=aws_instance.myec2 #only ec2 resourece named myec2 will be refreshed
Generally displays what changes are going to take place to achieve the desired state.
Apply the desired state from the module.
terraform apply
Apply the desired state from plan output.
terraform apply file_obs_path
terraform import
Reads the state file and displays output_variable_name
value
terraform output output_variable_name
Get the list of resources created and stored in statefile
terraform state list
Move resource name within a state.
terraform state mv aws_vpc.this aws_vpc.eks_vpc