cvwiki

Terraform Wiki

Nov 5, 2022

# Terraform Resources

# When to use Multiple Workspaces

Named workspaces allow conveniently switching between multiple instances of a single configuration within its single backend. They are convenient in a number of situations, but cannot solve all problems. A common use for multiple workspaces is to create a parallel, distinct copy of a set of infrastructure in order to test a set of changes before modifying the main production infrastructure. For example, a developer working on a complex set of infrastructure changes might create a new temporary workspace in order to freely experiment with changes without affecting the default workspace.

# Automation

# Pass terraform plan output to terraform apply in CI

When running in an orchestration tool, it can be difficult or impossible to ensure that the plan and apply subcommands are run on the same machine, in the same directory, with all of the same files present.

# Terraform Commands

1
terraform output $RESOURCE_NAME

# Terraform Tips and Tricks

1
terraform apply -target=aws_security_group.my_sg
1
export TF_LOG=1
1
2
3
4
brew install tfenv
tfenv install 1.0.0
tfenv use 1.0.0
terraform version # verify you're using the right version