Skip to content

Lab 10: Auto Approval For Terraform Apply

himanshumudgal08 edited this page Jun 15, 2022 · 2 revisions

Auto Approval For Terraform Apply

Step 1: Pre-deployment conditions

Under Pre-deployment conditions we will go with After Release.

Apply Pipeline will be triggered as soon as Release Artifact will be generated.

image

Step 2: Deploy Pipeline

It will contain following steps:

image

Step 3: Install Terraform

This will install the dependency of Terraform with 1.1.8 version.

image

steps:

- task: ms-devlabs.custom-terraform-tasks.custom-terraform-installer-task.TerraformInstaller@0

  displayName: 'Install Terraform 1.1.8'

  inputs:

    terraformVersion: 1.1.8

Step 4: Terraform : INIT

This step will initialize the terraform code in our system

It will fetch the information from remote state file stored in Blob Storage. We also need an Active Azure Subscription Id for this step.

image

steps:

- task: ms-devlabs.custom-terraform-tasks.custom-terraform-release-task.TerraformTaskV2@2

  displayName: 'Terraform : INIT'

  inputs:

    workingDirectory: '$(System.DefaultWorkingDirectory)/_IAC-CI/release'

    backendServiceArm: 'Opstree-PoCs (4c9****************3c)'

    backendAzureRmResourceGroupName: 'ADOagent_rg'

    backendAzureRmStorageAccountName: ter*********ort

    backendAzureRmContainerName: statefile

    backendAzureRmKey: terraform.tfstate

Step 5: Terraform : APPLY

This step will auto apply all the desired configuration into our cloud

image

steps:

- task: ms-devlabs.custom-terraform-tasks.custom-terraform-release-task.TerraformTaskV2@2

  displayName: 'Terraform : APPLY'

  inputs:

    command: apply

    workingDirectory: '$(System.DefaultWorkingDirectory)/_IAC-CI/release'

    commandOptions: '-auto-approve'

    environmentServiceNameAzureRM: 'Opstree-PoCs (4c93****************3c)'