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
| # Convert uppercased Terraform environment variables to their original casing expected by Terraform | |
| foreach ($tfvar in $(Get-ChildItem -Path Env: -Recurse -Include TF_VAR_*)) { | |
| $upperCaseName = $tfvar.Name + "_UC" | |
| $properCaseName = $tfvar.Name.Substring(0,7) + $tfvar.Name.Substring(7).ToLowerInvariant() | |
| $null = New-Item -Path env:$upperCaseName -Value $tfVar.Value | |
| Remove-Item -Path env:$($tfvar.Name) | |
| $null = New-Item -Path env:$properCaseName -Value $tfVar.Value | |
| Set-Item -Path env:$upperCaseName -Value $null | |
| } | |
| # List environment variables |
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
| variable foo { | |
| type = string | |
| default = "notbar" | |
| } |
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
| - name: Detect desired Terraform version | |
| id: terraform-version-check | |
| run: | | |
| $terraformVersion = (Get-Content .terraform-version) | |
| Write-Output "::set-output name=TERRAFORM_VERSION::${terraformVersion}" | |
| shell: pwsh | |
| - name: Get Terraform | |
| uses: hashicorp/setup-terraform@v1 | |
| with: |
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
| - pwsh: | | |
| $terraformVersion = (Get-Content .terraform-version) | |
| Write-Host "##vso[task.setvariable variable=version;isOutput=true]${terraformVersion}" | |
| displayName: 'Get preferred Terraform version' | |
| - task: TerraformInstaller@0 | |
| displayName: 'Use preferred Terraform version' | |
| inputs: | |
| terraformVersion: '$(terraformVersion)' |
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
| - task: AzureCLI@2 | |
| displayName: 'Terraform init' | |
| enabled: ${{ not(parameters.testMode) }} | |
| inputs: | |
| azureSubscription: '$(subscriptionConnection)' | |
| scriptType: pscore | |
| scriptLocation: inlineScript | |
| inlineScript: | | |
| Copy-Item backend.tf.example backend.tf | |
| # Run Terraform |
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
| - 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 |
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
| { | |
| "clientId": "00000000-0000-0000-0000-000000000000", | |
| "clientSecret": "00000000-0000-0000-0000-000000000000", | |
| "subscriptionId": "00000000-0000-0000-0000-000000000000", | |
| "tenantId": "00000000-0000-0000-0000-000000000000", | |
| "objectId": "00000000-0000-0000-0000-000000000000", | |
| (...) | |
| } |
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
| az login | |
| az account set --subscription 00000000-0000-0000-0000-000000000000 | |
| $env:ARM_SUBSCRIPTION_ID=$(az account show --query "id" -o tsv) | |
| $env:ARM_TENANT_ID=$(az account show --query "tenantId" -o tsv) |
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
| $env:ARM_SUBSCRIPTION_ID=00000000-0000-0000-0000-000000000000 | |
| $env:ARM_TENANT_ID=00000000-0000-0000-0000-000000000000 | |
| az login -t $env:ARM_TENANT_ID | |
| az account set --subscription $env:ARM_SUBSCRIPTION_ID |
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
| - 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 |