I’m facing an issue with Terraform Authentication to Azure while deployment while using a GitHub workflow. I’m attempting to authenticate with a service principal passed through to the providers.tf
at my root module level.
My understanding is that Terraform requires ARM_ to authenticate with a service principal.
Terraform, Credentials in a terraform provider block.
Microsoft, Service Principal client secret
In my GitHub environment, there is a secret called AZURE_CREDENTIALS
which is a standard convention to authenticate using the azure/login action. I’ve attempted to perform a JQL query to extract these values, but am having no value be returned. Here is the configuration specified in the documentation of this AZURE_CREDENTIAL
secret:
{
"clientSecret": "******",
"subscriptionId": "******",
"tenantId": "******",
"clientId": "******"
}
JQL that I’ve attempted to use:
echo "${{ secrets.AZURE_CREDENTIALS }}" > credentials.json
export ARM_CLIENT_SECRET=$(jq -r '.clientSecret' credentials.json)
export ARM_TENANT_ID=$(jq -r '.tenantId' credentials.json)
export ARM_CLIENT_ID=$(jq -r '.clientId' credentials.json)
echo "ARM_CLIENT_SECRET=${ARM_CLIENT_SECRET}"
echo "ARM_TENANT_ID=${ARM_TENANT_ID}"
echo "ARM_CLIENT_ID=${ARM_CLIENT_ID}"
echo "::add-mask::$ARM_CLIENT_SECRET"
echo "::add-mask::$ARM_TENANT_ID"
echo "::add-mask::$ARM_CLIENT_ID"
echo "ARM_CLIENT_SECRET=${ARM_CLIENT_SECRET}" >> $GITHUB_ENV
echo "ARM_TENANT_ID=${ARM_TENANT_ID}" >> $GITHUB_ENV
echo "ARM_CLIENT_ID=${ARM_CLIENT_ID}" >> $GITHUB_ENV
Does anyone have a method of accessing the AZURE_CREDENTIALS
values or should I just go ahead and create individual secrets i.e clientId
, tenantId
, clientSecret
etc..
edit: I should mention that in my workflow the following error message is being returned:
│ Error: Error building ARM Config: Authenticating using the Azure CLI is only supported as a User (not a Service Principal).