Skip to content

Commit 6f6aebd

Browse files
committed
feat: add Terragrunt Apply workflow for CI/CD integration
1 parent aee8818 commit 6f6aebd

1 file changed

Lines changed: 73 additions & 0 deletions

File tree

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Terragrunt Apply
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "terragrunt/**"
9+
- ".github/workflows/terragrunt-apply.yml"
10+
workflow_dispatch:
11+
12+
permissions:
13+
id-token: write
14+
contents: read
15+
16+
env:
17+
AWS_REGION: us-east-1
18+
TERRAFORM_VERSION: 1.14.5
19+
TERRAGRUNT_VERSION: 0.99.4
20+
21+
concurrency:
22+
group: terragrunt-apply
23+
cancel-in-progress: false
24+
25+
jobs:
26+
terragrunt-apply:
27+
name: Terragrunt Apply
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Checkout code
31+
uses: actions/checkout@v4
32+
33+
- name: Setup Terraform
34+
uses: hashicorp/setup-terraform@v3
35+
with:
36+
terraform_version: ${{ env.TERRAFORM_VERSION }}
37+
terraform_wrapper: false
38+
39+
- name: Setup Terragrunt
40+
run: |
41+
wget -q https://github.com/gruntwork-io/terragrunt/releases/download/v${{ env.TERRAGRUNT_VERSION }}/terragrunt_linux_amd64
42+
chmod +x terragrunt_linux_amd64
43+
sudo mv terragrunt_linux_amd64 /usr/local/bin/terragrunt
44+
terragrunt --version
45+
46+
- name: Configure AWS credentials
47+
uses: aws-actions/configure-aws-credentials@v4
48+
with:
49+
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/github-actions-terragrunt-role
50+
aws-region: ${{ env.AWS_REGION }}
51+
role-session-name: github-terragrunt-apply
52+
53+
- name: Terragrunt Init All
54+
working-directory: terragrunt/environments/prod
55+
run: |
56+
terragrunt run --all init
57+
58+
- name: Terragrunt Apply All Modules
59+
working-directory: terragrunt/environments/prod
60+
run: |
61+
terragrunt run --all apply -auto-approve
62+
63+
- name: Output Route53 Nameservers
64+
if: success()
65+
working-directory: terragrunt/environments/prod/route53-zone
66+
run: |
67+
echo "## ✅ Infrastructure Deployed Successfully" >> $GITHUB_STEP_SUMMARY
68+
echo "" >> $GITHUB_STEP_SUMMARY
69+
echo "**Update your domain registrar with these nameservers:**" >> $GITHUB_STEP_SUMMARY
70+
echo "" >> $GITHUB_STEP_SUMMARY
71+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
72+
terragrunt output -raw nameservers_string >> $GITHUB_STEP_SUMMARY
73+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)