Forked from geekzter/terraform-authentication-github-actions.yml
Last active
June 13, 2023 12:13
-
-
Save tp199314/c5a37eb3962b48a69d8275a41c6c7adb to your computer and use it in GitHub Desktop.
Terraform authentication re-uses GitHub Azure Action credentials
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated for bash. Needs package jq