Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tp199314/c5a37eb3962b48a69d8275a41c6c7adb to your computer and use it in GitHub Desktop.
Save tp199314/c5a37eb3962b48a69d8275a41c6c7adb to your computer and use it in GitHub Desktop.
Terraform authentication re-uses GitHub Azure Action credentials
- name: Get Azure CLI
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Get Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 'latest'
terraform_wrapper: false
- name: Prepare environment variables
env:
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
run: |
# Parse Azure secret into Terraform variables
echo "ARM_CLIENT_ID=$( jq -r '.clientId' <<< $AZURE_CREDENTIALS )" >> $GITHUB_ENV;
echo "ARM_CLIENT_SECRET=$( jq -r '.clientSecret' <<< $AZURE_CREDENTIALS )" >> $GITHUB_ENV;
echo "ARM_SUBSCRIPTION_ID=$( jq -r '.subscriptionId' <<< $AZURE_CREDENTIALS )" >> $GITHUB_ENV;
echo "ARM_TENANT_ID=$( jq -r '.tenantId' <<< $AZURE_CREDENTIALS )" >> $GITHUB_ENV
shell: bash
- name: Terraform Init
run: terraform init
shell: bash
@tp199314
Copy link
Author

Updated for bash. Needs package jq

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment