-
Notifications
You must be signed in to change notification settings - Fork 1
/
azure-pipelines-terraform-release.yml
48 lines (44 loc) · 1.48 KB
/
azure-pipelines-terraform-release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
parameters:
azureSubscription:
storageAccountRg:
storageAccountName:
storageAccountKey:
name:
environment:
workingDirectory:
jobs:
- job: Deploy
pool:
vmImage: 'Ubuntu-16.04'
steps:
# Terraform Init
- task: TerraformTaskV1@0
displayName: Terraform Init
inputs:
provider: 'azurerm'
command: 'init'
commandOptions: '-input=false'
backendServiceArm: ${{ parameters.azureSubscription }}
backendAzureRmResourceGroupName: ${{ parameters.storageAccountRg }}
backendAzureRmStorageAccountName: ${{ parameters.storageAccountName }}
backendAzureRmContainerName: 'tfstate'
backendAzureRmKey: ${{ parameters.storageAccountKey }}
workingDirectory: ${{ parameters.workingDirectory }}
# Terraform plan
- task: TerraformTaskV1@0
displayName: Terraform Plan
inputs:
provider: 'azurerm'
command: 'plan'
commandOptions: '-input=false -out ${{ parameters.rg }}.tfplan -var name="${{ parameters.name }}" -var environment="${{ parameters.environment }}"'
environmentServiceNameAzureRM: ${{ parameters.azureSubscription }}
workingDirectory: ${{ parameters.workingDirectory }}
# Terraform apply
- task: TerraformTaskV1@0
displayName: Terraform Apply
inputs:
provider: 'azurerm'
command: 'apply'
commandOptions: '${{ parameters.rg }}.tfplan'
environmentServiceNameAzureRM: ${{ parameters.azureSubscription }}
workingDirectory: ${{ parameters.workingDirectory }}