4
votes

Experiencing terraform for the very time, I'm following the document from this link to put in my terraform files in a release pipeline that I have with Azure DevOps. Everything runs perfectly fine until the step where it initializes the terraform. It fails with the following error message:

enter image description here

The storage account itself is provisioned and the key of that also is persisted successfully in the environment variables as per the document.

The YAML I have for terraform init in Azure DevOps Release pipeline is: enter image description here

And the terraform script for the backend service is: enter image description here

The variables are stored as environment variables inside the release pipeline and there is a replace token task that replaces __ with string empty: enter image description here

Her is the step in the pipeline that create the resource group and storage account: enter image description here

And finally, the PS scripts that store the storage key in the ENV vars: enter image description here

Also, I can't understand why the get http from the error message has env appended to the terraform.tformstate.

I'm running out of ideas why it fails with that exception and what is expecting actually.

I've been Googling around but have been failing so far to resolve the issue. Appreciate your help/thoughts on this.

1
Share your Terraform script and where do you deploy the Terraform script? DevOps? give the YAML file.Charles Xu
added them to the question. Yes, it is Azure DevOps Release pipelines I'm using just per the document link in the question.Ali
I don't see variables for the storage name and access key, where do you define them?Charles Xu
they are in the env vars in the release pipeline and there is a powershell script that creates the storage account, reads the key, and persist the keyAli
All the things work fine on my side in the release. Can you check if the value of workingDirectory in the init task is right and make sure the key value is really right.Charles Xu

1 Answers

6
votes

Looks like you misspelled storageaccount for your variable. So the value is not substituted. You have sotrageaccount. The t and o are swapped.