Skip to content

Instantly share code, notes, and snippets.

@amontalban
Created April 19, 2024 18:08
Show Gist options
  • Save amontalban/dcd106a55390203bd30cb706e96698e6 to your computer and use it in GitHub Desktop.
Save amontalban/dcd106a55390203bd30cb706e96698e6 to your computer and use it in GitHub Desktop.
# Make sure you escape $ sign otherwise you will get a Terraform error
version: 3
automerge: true
delete_source_branch_on_merge: true
repos:
- id: github.com/ACME/terraform
workflow: terragrunt
pre_workflow_hooks:
- run: |
terragrunt hclfmt --terragrunt-check --terragrunt-diff
description: Checking Terragrunt HCL formatting
- run: |
terragrunt-atlantis-config generate --output atlantis.yaml --autoplan --parallel --create-workspace --execution-order-groups --filter provider/aws --automerge
description: Generating atlantis.yaml
apply_requirements:
- approved
workflows:
terragrunt:
init:
steps:
- env:
name: TERRAGRUNT_DOWNLOAD
command: 'echo "$HOME/.cache/terragrunt/modules"'
- env:
name: TERRAGRUNT_FETCH_DEPENDENCY_OUTPUT_FROM_STATE
value: "true"
- env:
name: TERRAGRUNT_PROVIDER_CACHE
value: "1"
- env:
name: TERRAGRUNT_NON_INTERACTIVE
value: "true"
- env:
name: TERRAGRUNT_INCLUDE_EXTERNAL_DEPENDENCIES
value: "true"
- env:
name: CI
value: "true"
- env:
name: ATLANTIS_REPO_PATH
command: 'echo "$HOME/.atlantis/repos/$BASE_REPO_OWNER/$BASE_REPO_NAME/$PULL_NUM/$WORKSPACE"'
- run: terragrunt init
plan:
steps:
- env:
name: TERRAGRUNT_DOWNLOAD
command: 'echo "$HOME/.cache/terragrunt/modules"'
- env:
name: TERRAGRUNT_FETCH_DEPENDENCY_OUTPUT_FROM_STATE
value: "true"
- env:
name: TERRAGRUNT_PROVIDER_CACHE
value: "1"
- env:
name: TERRAGRUNT_NON_INTERACTIVE
value: "true"
- env:
name: TERRAGRUNT_INCLUDE_EXTERNAL_DEPENDENCIES
value: "true"
- env:
name: CI
value: "true"
- env:
name: ATLANTIS_REPO_PATH
command: 'echo "$HOME/.atlantis/repos/$BASE_REPO_OWNER/$BASE_REPO_NAME/$PULL_NUM/$WORKSPACE"'
# Use Tailscale running in a side container as proxy so we can connect to internal services
- env:
name: ALL_PROXY
value: "socks5://127.0.0.1:1055/"
- env:
name: HTTP_PROXY
value: "http://127.0.0.1:1055/"
- env:
name: HTTPS_PROXY
value: "http://127.0.0.1:1055/"
- run: terragrunt plan -input=false -no-color -out=$PLANFILE
- run: terragrunt show -no-color -json $PLANFILE > $SHOWFILE
apply:
steps:
- env:
name: TERRAGRUNT_DOWNLOAD
command: 'echo "$HOME/.cache/terragrunt/modules"'
- env:
name: TERRAGRUNT_FETCH_DEPENDENCY_OUTPUT_FROM_STATE
value: "true"
- env:
name: TERRAGRUNT_PROVIDER_CACHE
value: "1"
- env:
name: TERRAGRUNT_NON_INTERACTIVE
value: "true"
- env:
name: TERRAGRUNT_INCLUDE_EXTERNAL_DEPENDENCIES
value: "true"
- env:
name: CI
value: "true"
- env:
name: ATLANTIS_REPO_PATH
command: 'echo "$HOME/.atlantis/repos/$BASE_REPO_OWNER/$BASE_REPO_NAME/$PULL_NUM/$WORKSPACE"'
# Use Tailscale running in a side container as proxy so we can connect to internal services
- env:
name: ALL_PROXY
value: "socks5://127.0.0.1:1055/"
- env:
name: HTTP_PROXY
value: "http://127.0.0.1:1055/"
- env:
name: HTTPS_PROXY
value: "http://127.0.0.1:1055/"
- run: terragrunt apply -input=false $PLANFILE -no-color
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment