Skip to content

Latest commit

 

History

History
77 lines (52 loc) · 3.67 KB

File metadata and controls

77 lines (52 loc) · 3.67 KB

Pipelines

Azure DevOps pipeline integration (see pipelines folder):

  • Generate Terraform pipeline plan on PR creation
  • Apply Terraform pipeline plan on PR merge
  • Agnostic multi-environment (eg. development, staging, prod1, prod2)
  • Connected with the service connection
  • DevOps Pool integration
  • App config integration
  • Simple one-time setup using Variable(s) (groups)

It will connect everything automatically:

  • TFVARS pre-filled in the app config (with key vault compatibility)
  • Example backend config pre-filled (for state migration)
  • DevOps pools using alias

Terraform-git-automation

Requirements

Azure DevOps Marketplace extension:

Pipelines

The following pipelines are used by this module:

Description: The Plan stage in this pipeline can be configured to trigger on the creation of a PR to generate a Terraform plan for those changes. Will be used in conjunction with the service connection that was provisioned by the module.

Jobs

  • Generate - Job for generating and posting a plan based on the Terraform config changes in the PR.

Variables:

  • environment_name - (Required) The source folder for the Terraform configuration, used to make the pipeline multi-environment.
  • trigger - (Optional) The trigger is configured through branch policies. Defaults to none.
  • pool - (Optional) The agent pool where the pipeline will be deployed. Defaults to $(environment_name)-motte-pipeline.

Steps:

  • Configure git authentication header - Uses Git CLI to set OIDC WIP Authentication Headers
  • Extract App Config as File - Uses Azure CLI to fetch tfvars from App Configuration using the app-config-endpoint pipeline variable.
  • Terraform Init - Uses Terraform Extension task to initialize Terraform.
  • Terraform Plan - Uses Terraform Extension task to generate a plan and convert it to a text format.
  • Publish Artifact - Uses Azure task to publish the plan as artifact
  • Post Comment - Uses Azure CLI to post the plan as a comment to the connected PR.

Description: This pipeline can be configured to trigger when changes are merged to a branch that manages Terraform configurations. Will be used in conjunction with the service connection that was provisioned by the module.

Jobs:

  • Apply - Job for applying a Terraform plan after the PR is approved and merged.
  • Comment - Job for retrieving and posting apply output from applying a Terraform Plan.

Variables:

  • environment_name - (Required) The source folder for the Terraform configuration, used to make the pipeline multi-environment.
  • trigger - (Optional) The trigger is configured on branch merge and can be overridden for secondary staging environments. Defaults to master.
  • pool - (Optional) The agent pool where the pipeline will be deployed. Defaults to $(environment_name)-motte-pipeline.

Steps:

  • Configure git authentication header - Uses Git CLI to set OIDC WIP Authentication Headers
  • Download Artifact - Download the Artifact from the Plan pipeline.
  • Terraform Init - Uses Terraform Extension task to initialize Terraform.
  • Terraform Apply - Uses Terraform Extension task to apply a plan and convert the output to a text format.
  • Get PR ID - Uses Azure CLI to retrieve the PR ID.
  • Post Comment - Uses Azure CLI to post the output as a comment to the connected PR.