bcosta12
bcosta12

Reputation: 2452

How can I separete environments (dev, prod, staging) in AWS using terraform?

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

Answers (1)

Igor Marcelo
Igor Marcelo

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

Related Questions