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
Azure DevOps Marketplace extension:
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 tonone.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 HeadersExtract App Config as File- Uses Azure CLI to fetch tfvars from App Configuration using theapp-config-endpointpipeline 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 artifactPost 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 tomaster.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 HeadersDownload 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.