Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rudolphjacksonm/a0315cf41d17aea21f5999fe304fda97 to your computer and use it in GitHub Desktop.
Save rudolphjacksonm/a0315cf41d17aea21f5999fe304fda97 to your computer and use it in GitHub Desktop.
parameters:
- name: tfVarFileName
type: string
default: '' # foo.tfvars, for example
stages:
- stage:
displayName: 'Terraform Apply'
jobs:
- deployment: Deploy
displayName: 'Terraform Apply'
pool:
vmImage: 'ubuntu-latest'
environment: 'terraform'
strategy:
runOnce:
deploy:
steps:
- checkout: none
- task: Cache@2
displayName: 'Get Cache for TF Artifact'
inputs:
key: terraform | $(Agent.OS) | $(Build.SourceVersion) | $(tfComponent)
path: $(tfExecutionDir)
- task: TerraformInstaller@0
displayName: 'Install Terraform'
inputs:
terraformVersion: '$(terraformVersion)'
- task: TerraformTaskV1@0
displayName: 'Terraform Apply'
inputs:
provider: 'azurerm'
command: 'apply'
commandOptions: '${BUILD_BUILDNUMBER}.tfplan' # pass plan file to terraform apply
workingDirectory: '$(tfExecutionDir)'
environmentServiceNameAzureRM: '$(serviceConnectionName)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment