Last active
April 6, 2021 18:12
-
-
Save geekzter/8b01c8f76c47f7d14e63258dd3d1169e to your computer and use it in GitHub Desktop.
Terraform authentication inherits Azure Pipeline Service Connection 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
- task: AzureCLI@2 | |
displayName: 'Terraform init' | |
inputs: | |
azureSubscription: '$(subscriptionConnection)' | |
scriptType: pscore | |
scriptLocation: inlineScript | |
inlineScript: | | |
# Propagate pipeline Service Principal as Terraform variables | |
$env:ARM_CLIENT_ID ??= $env:servicePrincipalId | |
$env:ARM_CLIENT_SECRET ??= $env:servicePrincipalKey | |
$env:ARM_TENANT_ID ??= $env:tenantId | |
# Propagate from Azure CLI context | |
$env:ARM_TENANT_ID ??= $(az account show --query tenantId -o tsv) | |
$env:ARM_SUBSCRIPTION_ID ??= $(az account show --query id -o tsv) | |
# Put Terraform commands after this line | |
addSpnToEnvironment: true | |
useGlobalConfig: true | |
failOnStandardError: true | |
powerShellIgnoreLASTEXITCODE: false | |
workingDirectory: '$(terraformDirectory)' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment