Skip to content

Instantly share code, notes, and snippets.

@rudolphjacksonm
Last active June 6, 2020 20:53
Show Gist options
  • Save rudolphjacksonm/932789e6054e0274fd43a11ff68924c0 to your computer and use it in GitHub Desktop.
Save rudolphjacksonm/932789e6054e0274fd43a11ff68924c0 to your computer and use it in GitHub Desktop.
---
parameters:
- name: serviceConnectionName
type: string
- name: backendAzureRmResourceGroupName
type: string
- name: backendAzureRmStorageAccountName
type: string
- name: backendAzureRmContainerName
type: string
- name: backendAzureRmKey
type: string
- name: tfComponent
type: string
- name: tfExecutionDir
type: string
- name: tfVarFileName
type: string
steps:
- task: Cache@2
displayName: Register TF cache
inputs:
key: terraform | $(Agent.OS) | "$(Build.BuildNumber)" | $(Build.SourceVersion) | "$(Build.BuildNumber)" | ${{ parameters.tfComponent }} | "${{ parameters.tfVarFileName }}"
path: '${{ parameters.tfExecutionDir }}'
- task: TerraformInstaller@0
displayName: 'Install Terraform v$(terraformVersion)'
inputs:
terraformVersion: '$(terraformVersion)'
- task: TerraformTaskV1@0
displayName: 'Terraform Init'
inputs:
provider: 'azurerm'
command: 'init'
workingDirectory: '${{ parameters.tfExecutionDir }}'
backendServiceArm: '${{ parameters.serviceConnectionName}}'
backendAzureRmResourceGroupName: '${{ parameters.backendAzureRmResourceGroupName }}'
backendAzureRmStorageAccountName: '${{ parameters.backendAzureRmStorageAccountName }}'
backendAzureRmContainerName: '${{ parameters.backendAzureRmContainerName }}'
backendAzureRmKey: '${{ parameters.backendAzureRmKey }}'
- task: TerraformTaskV1@0
displayName: 'Run Terraform Plan'
inputs:
provider: 'azurerm'
command: 'plan'
commandOptions: '-var-file=${{ parameters.tfVarFileName }} -out=${BUILD_BUILDNUMBER}.tfplan'
workingDirectory: '${{ parameters.tfExecutionDir }}'
environmentServiceNameAzureRM: '${{ parameters.serviceConnectionName }}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment