Debug and fix failing Terraform GitHub Actions workflows...
This skill helps you debug and fix failing Terraform GitHub Actions workflows for Azure infrastructure deployments.
- name: Azure Login
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
Common Issues:
Fix:
# Create federated credential
az ad app federated-credential create \
--id <app-object-id> \
--parameters '{
"name": "github-actions",
"issuer": "https://token.actions.githubusercontent.com",
"subject": "repo:org/repo:ref:refs/heads/main",
"audiences": ["api://AzureADTokenExchange"]
}'
Error: Error acquiring the state lock
Fix:
terraform force-unlock <LOCK_ID>
Fixes:
Error: Failed to query available provider packages
Fixes:
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: "1.6.0"
- name: Terraform Init
run: terraform init -upgrade
env:
ARM_SKIP_PROVIDER_REGISTRATION: "true"
Fix:
terraform import azurerm_resource_group.main /subscriptions/.../resourceGroups/rg-name
env:
TF_LOG: DEBUG
TF_LOG_PATH: terraform.log
- name: Debug Azure Context
run: |
az account show
az account list-locations -o table
For complete workflow templates and detailed debugging guides, see the reference guide.