Running Plan/Apply with Pipelines
When changes are made to your committed IaC, Pipelines detects these infrastructure changes and runs Terragrunt Plan/Apply on your units. Changes that occur in commits that are included in Pull Requests targeting your Deploy Branch (e.g. main
or master
) will trigger Terragrunt Plan. Changes in commits on your Deploy Branch will trigger a Terragrunt Apply.
The recommended workflow when working with Pipelines is to create a new Pull Request with the desired changes, then review the output of Terragrunt Plan to confirm that the resulting infrastructure changes are expected. We recommend enforcing Branch Protection and especially the Require branches to be up to date status check on your repository as this will restrict the PR from being merged if the Plan may be out of date.
Running Plan
To trigger a Plan, create an infrastructure change such as adding or modify a terragrunt.hcl
unit on a new branch, then open a new Pull Request to merge this branch into your Deploy Branch. Once the Pull Request is open Pipelines will add a comment to the PR including the output of the Plan.
Screenshot of Plan Comment
Running Apply
To run an Apply, merge your changes into the Deploy Branch. All commits including Merge commits on the Deploy Branch will trigger an apply if infrastructure changes are detected.
Pipelines will add a comment to the (merged) Pull Request with the output of the Apply.
Skipping Pipelines Plan/Apply
You may occasionally need to skip Pipelines on particular commits. This can be done by adding one of the workflow skip messages such as [no ci]
into your commit message.
You can also modify the paths-ignore
filter in .github/workflows/pipelines.yml
within your repository to exclude an entire directory from triggering Pipelines.
For example, to exclude a directory with the name local-testing
you would modify the workflow
on:
push:
branches:
- main
paths-ignore:
# Workflow does not run only if ALL filepaths match the pattern. See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-excluding-paths
- ".github/**"
- "local-testing/**"
pull_request:
types:
- opened
- synchronize
- reopened
paths-ignore:
- "local-testing/**"
Destroying Infrastructure
To Destroy infrastructure create a commit deleting the Terragrunt unit. Pipelines will detect the deletion and trigger Terragrunt to run a plan -destroy
on pull requests or destroy
on your Deploy Branch. Pipelines automatically checks out the previous committed version of the infrastructure so that Terragrunt can run in the (now deleted) directory.