microsoft / azure-pipelines-terraform

Azure Pipelines tasks for installing Terraform and running Terraform commands in a build or release pipeline.
MIT License
95 stars 59 forks source link

Support for passing in a backend config file in init command #225

Open katelewis13 opened 1 week ago

katelewis13 commented 1 week ago

Our terraform projects are setup for multi environments where we have a separate tfvars and backend files for each environment. In the init step we pass the backend file using the -backend-config flag.

Example dev.backend file:

resource_group_name  = "our-azure-resource-group"
storage_account_name = "somestorageaccount"
container_name       = "dev-tfstate"
key                  = "terraform.tfstate"

We wanted to use the terraform init task, but it requires you to specify the backend manually. I tried to just add the --backend-config to the commandOptions but it still required the other fields. It would be great if this functionality was added. Otherwise, if anyone has any suggestions for an alternate solution, I am all ears!