Skip to content

Commit a156e9b

Browse files
committed
fix(terragrunt): update deploy workflow to run from root, skip dev, and remove stray lockfiles
- run Terragrunt from terragrunt/ instead of live/website - switch CI commands to `run-all init/plan/apply` - read outputs via `terragrunt output --terragrunt-include-dir live` - delete incorrectly generated .terraform.lock.hcl in dev - add `skip = true` to dev environment until DNS is ready - update module source paths to ../../modules/website - remove legacy before_hook and lockfile suppression hacks from live
1 parent ae216a4 commit a156e9b

21 files changed

Lines changed: 318 additions & 56 deletions

.github/workflows/deploy.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ on:
1616
# user must select a branch when triggering workflow manually
1717

1818
env:
19-
working_dir: terragrunt/live/website
19+
working_dir: terragrunt
2020

2121
concurrency:
2222
group: ${{ github.workflow }}
@@ -50,30 +50,31 @@ jobs:
5050
TERRAGRUNT_DISABLE_COPY: true
5151
with:
5252
tg_dir: ${{ env.working_dir }}
53-
tg_command: init
53+
tg_command: "run-all init"
5454

5555
- name: Terragrunt Plan
5656
uses: gruntwork-io/terragrunt-action@v3
5757
env:
5858
TERRAGRUNT_DISABLE_COPY: true
5959
with:
6060
tg_dir: ${{ env.working_dir }}
61-
tg_command: plan
61+
tg_command: "run-all plan"
62+
6263

6364
- name: Terragrunt Apply
6465
uses: gruntwork-io/terragrunt-action@v3
6566
env:
6667
TERRAGRUNT_DISABLE_COPY: true
6768
with:
6869
tg_dir: ${{ env.working_dir }}
69-
tg_command: apply
70+
tg_command: "run-all apply"
7071

7172
- name: Read Values
7273
id: terragrunt_output
7374
run: |
74-
cd terragrunt/live/website
75-
printf "distribution_id=%s\n" $(terragrunt output distribution_id) >> "$GITHUB_OUTPUT"
76-
printf "bucket_name=%s\n" $(terragrunt output bucket_name) >> "$GITHUB_OUTPUT"
75+
cd terragrunt
76+
printf "distribution_id=%s\n" $(terragrunt output --terragrunt-include-dir live distribution_id) >> "$GITHUB_OUTPUT"
77+
printf "bucket_name=%s\n" $(terragrunt output --terragrunt-include-dir live bucket_name) >> "$GITHUB_OUTPUT"
7778
7879
- name: Build Jekyll project
7980
run: |

mise.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ run = [
1717

1818
# Terraform lint
1919
"tflint --init",
20-
"tflint --chdir terraform/website/ -c ../../.tflint.hcl",
20+
"tflint --chdir terragrunt/modules/website -c ../../../.tflint.hcl",
21+
2122

2223
# HTML linting
2324
"bundle exec htmlproofer ./_site --check-external-hash"

terragrunt/dev/website/.terraform.lock.hcl

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1+
2+
# TODO(j4y): dev.colorcop.net DNS isn't there and needs some work
3+
skip = true
4+
15
include "root" {
2-
path = find_in_parent_folders()
6+
path = find_in_parent_folders("terragrunt.hcl")
37
}
48

59
terraform {
6-
source = "../../../terraform/website/"
10+
source = "../../modules/website"
711
}
812

913
inputs = {
1014
env = "dev"
11-
# FIXME: need new strategy for dev/staging domain
1215
domain = "dev.colorcop.net"
13-
}
16+
}
17+

terragrunt/live/website/terragrunt.hcl

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,13 @@
11
include "root" {
2-
path = find_in_parent_folders()
2+
path = find_in_parent_folders("terragrunt.hcl")
33
}
44

5-
terraform {
6-
# Prevent OpenTofu/Terraform from generating a .terraform.lock.hcl file
7-
# inside the live Terragrunt directory. Live folders do not own provider
8-
# versions — the module lockfile in terraform/website/ is the single
9-
# source of truth. Without this flag, `terragrunt init` would create a
10-
# local lockfile here, causing CI to detect uncommitted changes.
11-
extra_arguments "disable_lockfile" {
12-
commands = ["init"]
13-
arguments = ["-lockfile=readonly"]
14-
}
15-
16-
# Force initialization before plan/apply, but run *terraform init*
17-
# instead of terragrunt init. Running terragrunt init inside the
18-
# .terragrunt-cache causes include recursion and breaks.
19-
before_hook "force_init" {
20-
commands = ["plan", "apply"]
21-
execute = ["terraform", "init", "-lockfile=readonly"]
22-
}
235

24-
source = "../../../terraform/website/"
6+
terraform {
7+
# Point Terragrunt at the module inside terragrunt/modules/website.
8+
# This ensures Terraform runs ONLY inside .terragrunt-cache and NEVER
9+
# writes .terraform.lock.hcl into the live folder.
10+
source = "../../modules/website"
2511
}
2612

2713
inputs = {
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)