I want to create container from which I will run my terraform commands. My dockerfile looks like this:
FROM mcr.microsoft.com/azure-cli
RUN apk add curl
ENV TERRAFORM_VERSION 0.12.21
RUN curl -sL https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip -o tf.zip \
&& unzip tf.zip \
&& mv terraform /sbin/ \
&& rm -rf tf.zip
My main.tf
looks like:
provider "azurerm" {
version = "~>1.44"
subscription_id = "xxx"
}
provider "azuread" {
version = "~>0.6.0"
}
terraform {
backend "azurerm" {}
}
What I usually do on my Windows
host is az login
and then
terraform init \
-backend-config=storage_account_name=xxx \
-backend-config=container_name=terraform-state \
-backend-config=access_key="xxx" \
-backend-config=key=app.tfstate
The problem is that when I do same inside the docker container run as follows docker run --rm -ti <IMAGE_ID> bash
instead of successful initialization I get weird error like:
Error: Failed to get existing workspaces: storage: service returned error: StatusCode=403, ErrorCode=AuthenticationFailed, ErrorMessage=Server failed to authenticate the request. Make sure the value of
Authorization header is formed correctly including the signature.
Is this somehow related to