Skip to content

Instantly share code, notes, and snippets.

@jungopro
Created December 16, 2019 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jungopro/2ac9f850a9ea544953489212e6d2093e to your computer and use it in GitHub Desktop.
Save jungopro/2ac9f850a9ea544953489212e6d2093e to your computer and use it in GitHub Desktop.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
name: Build-$(Build.BuildId)
trigger: none
pr: [dev]
pool:
vmImage: 'ubuntu-latest'
steps:
- task: TerraformInstaller@0
displayName: 'Install Terraform version $(TF-Version)'
inputs:
terraformVersion: '$(TF-Version)'
- script: terraform init -get=true -upgrade=true -backend-config='storage_account_name=$(sa-name)' -backend-config='container_name=$(blob-name)' -backend-config='access_key=$(sa-key)' -backend-config='key=$(key)'
workingDirectory: '$(Build.SourcesDirectory)'
displayName: 'Terraform Init'
- script: terraform workspace select '$(Dev-WS)' || terraform workspace new '$(Dev-WS)'
workingDirectory: '$(Build.SourcesDirectory)'
displayName: 'Switch to Environment $(Dev-WS)'
- script: 'terraform validate'
workingDirectory: '$(Build.SourcesDirectory)'
displayName: 'Validate Terraform Code'
- script: 'terraform plan -lock=true -var="subscription_id=$(subscription-id)" -var="client_id=$(client-id)" -var="client_secret=$(client-secret)" -var="tenant_id=$(tenant-id)" -var="repo_name=$(repo-name)" -var="repo_username=$(repo-username)" -var="repo_password=$(repo-password)"'
workingDirectory: '$(Build.SourcesDirectory)'
displayName: 'Terraform Dry Run (Plan)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment