Skip to content

Instantly share code, notes, and snippets.

View rudolphjacksonm's full-sized avatar

Jack Morris rudolphjacksonm

View GitHub Profile
trigger:
- none
pool:
vmImage: 'ubuntu-latest'
stages:
- stage: DevPlan
displayName: Dev Plan
jobs:
- job:
steps:
- task: Cache@2
displayName: 'Register TF cache'
inputs:
key: terraform | $(Agent.OS) | "$(Build.BuildNumber)" | $(Build.SourceVersion) | $(tfComponent) | "$(tfVarFileName)"
path: $(tfExecutionDir)
- task: TerraformInstaller@0
displayName: 'Install Terraform'
inputs:
terraformVersion: '$(terraformVersion)'
variables:
- name: PROJECT_PATH
value: terraform
- name: tfComponent
value: cluster
- name: tfExecutionDir
value: '$(PROJECT_PATH)/src/$(tfComponent)'
- name: terraformVersion
value: 0.12.21
- name: serviceConnectionName
trigger:
- none
pool:
vmImage: 'ubuntu-latest'
stages:
- stage:
displayName: 'Terraform Plan'
jobs:
- job: TFPlan
---
parameters:
- name: serviceConnectionName
type: string
- name: backendAzureRmResourceGroupName
type: string
- name: backendAzureRmStorageAccountName
type: string
- name: backendAzureRmContainerName
type: string
---
...
stages:
- stage:
displayName: 'Terraform Plan'
jobs:
- job: TFPlan
variables: # <--Variables are now scoped to this job and all steps within it
- template: vars/dev_vars.yml
steps:
variables:
- name: terraformVersion
value: 0.12.23
trigger: none
pool:
vmImage: 'ubuntu-latest'
stages:
- stage:
parameters:
- name: tfVarFileName
type: string
default: '' # foo.tfvars, for example
stages:
- stage:
displayName: 'Terraform Apply'
jobs:
- deployment: Deploy
parameters:
- name: serviceConnectionName
type: string
- name: backendAzureRmResourceGroupName
type: string
- name: backendAzureRmStorageAccountName
type: string
- name: backendAzureRmContainerName
type: string
- name: backendAzureRmKey
@rudolphjacksonm
rudolphjacksonm / azdevops-terraform-apply.yml
Last active June 6, 2020 20:49
azdevops-terraform-apply
---
- task: Cache@2
displayName: 'Get Cache for TF Artifact'
inputs:
key: terraform | $(Agent.OS) | "$(Build.BuildNumber)" | $(Build.SourceVersion) | $(tfComponent) | "$(tfVarFileName)"
path: $(tfExecutionDir)
- task: TerraformInstaller@0
displayName: 'Install Terraform'
inputs:
terraformVersion: '$(terraformVersion)'