Skip to content

Instantly share code, notes, and snippets.

@rudolphjacksonm
Last active April 12, 2020 16:00
Show Gist options
  • Save rudolphjacksonm/c764842ac03740ba4307d702b0b8c18d to your computer and use it in GitHub Desktop.
Save rudolphjacksonm/c764842ac03740ba4307d702b0b8c18d 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.SourceVersion) | ${{ 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