Hi!
We were inspired the news that terraform support was added to 2018.3
We use the octopus as our main deployment tools and we hope to deploy an aws infrastructure for our projects with octopus.
But i found 2 things that do the “Apply a terraform template” template useless for us
Variables
Octopus provides Variable Replacement ( described in https://octopus.com/docs/deploying-applications/terraform-deployments/apply-terraform). And one possible way is: keep variables in octopus and replace it as described in Variable Replacement.
But we have around 60 variables in our terraform configuration. And we have => 3 environments (1 dev, 1 stage, 1+ prod). So i must fill values for variables 180 times. And when i want add a new environment, i must add values to 60 variables.
Keeping values for variables in terraform.tfvars and use dedicated terraform.tfvars file for each environment looks much easer, but the template doesn’t support “var-file” flag for apply command.
Is it possible to add var-file flag to the “Apply a terraform template” in future releases?
Environment isolation
You provide workspace option. ( described in https://octopus.com/docs/deploying-applications/terraform-deployments/apply-terraform). But workspace isn’t good for environment isolation.
From terrafrom documentation (State: Workspaces | Terraform | HashiCorp Developer)
Workspaces can be used to manage small differences between development, staging, and production, but they should not be treated as the only isolation mechanism
<…>
For each smaller configuration, you can use workspaces to model the differences between development, staging, and production. However, if you have one large Terraform configuration, it is riskier and not recommended to use workspaces to handle those differences.
We prefer to use a dedicated state file for each environment and re-initialize backend with code like follow:
terraform init -backend-config="region=$terraform_bucket_region" \
-backend-config="bucket=$terraform_bucket_name" \
-backend-config="key=$(basename $module_path)/$environment.tfstate"
And use backend configuration like:
terraform {
required_version = "~> 0.10"
backend "s3" {
encrypt = true
}
}
So, is it possible to add backend-config flag to the “Apply a terraform template” in future releases?