Created
May 24, 2022 20:01
-
-
Save Mikej81/2fc03916bfd9b3af49e623b95da2e576 to your computer and use it in GitHub Desktop.
Map Azure Vars
This file contains hidden or 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
| # get the current default subscription(s) | |
| az account show --output table | |
| # set the current default subscription | |
| az account set --subscription <name or id> | |
| #Map Subscription | |
| export ARM_SUBSCRIPTION_ID=`az account show | jq -r '.id'` | |
| export TF_VAR_azure_subscription_id=`az account show | jq -r '.id'` | |
| #Create ServicePrincipal for ClientID and Secret | |
| spn=`az ad sp create-for-rbac --role="Contributor" --scopes="/subscriptions/$ARM_SUBSCRIPTION_ID" --name http://voltspn` | |
| echo "Setting environment variables for Terraform" | |
| unset ARM_CLIENT_ID | |
| #export ARM_CLIENT_ID=`echo $spn | jq -r '.appId'` | |
| export TF_VAR_azure_client_id=`echo $spn | jq -r '.appId'` | |
| #echo $spn | jq -r '.appId' | |
| unset ARM_CLIENT_SECRET | |
| #export ARM_CLIENT_SECRET=`echo $spn | jq -r '.password'` | |
| export TF_VAR_azure_client_secret=`echo $spn | jq -r '.password'` | |
| #echo $spn | jq -r '.password' | |
| unset ARM_TENANT_ID | |
| export ARM_TENANT_ID=`az account show | jq -r '.tenantId'` | |
| export TF_VAR_azure_tenant_id=`az account show | jq -r '.tenantId'` | |
| #az account show | jq -r '.tenantId' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment