Reputation: 2452
I am using workspaces to separate environments in AWS like that:
terraform init
terraform workspace new dev
terraform workspace select dev
terraform validate --var-file $(terraform workspace show).tfvars
terraform apply --var-file $(terraform workspace show).tfvars
The command $(terraform workspace show).tfvars
is used to select as --var-file
the file with the same name as the workspace, in this case, dev.tfvars
will be used.
There are a better option?
Upvotes: 0
Views: 141
Reputation: 141
In my team, we decided to follow the per-folder environment pattern, similar to what is recommended by Terragrunt https://github.com/gruntwork-io/terragrunt-infrastructure-live-example
Upvotes: 1