Skip to content

Commit bbbce7f

Browse files
committed
docs: Fixing handling broken IaC
1 parent 869b4f2 commit bbbce7f

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

docs/2.0/docs/pipelines/guides/handling-broken-iac.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Handling Broken Infrastructure as Code
22

3-
When working with Infrastructure as Code (IaC) at scale, you may occasionally encounter broken or invalid configuration files that prevent Terragrunt from successfully running operations. These issues can block entire CI/CD pipeline, preventing even valid infrastructure changes from being deployed.
3+
When working with Infrastructure as Code (IaC) at scale, you may occasionally encounter broken or invalid configuration files that prevent Terragrunt from successfully running operations. These issues can block the entire CI/CD pipeline, preventing even valid infrastructure changes from being deployed.
44

55
This guide presents several strategies for handling broken IaC while keeping your pipelines operational.
66

@@ -16,13 +16,13 @@ Common causes of broken IaC include:
1616
- Temporary or experimental code
1717
- Resources or modules that have are work in progress
1818

19-
Depending on the type of run pipeline is executing, broken IaC can fail a pipeline and prevent other, legitimate changes from being deployed. Especially in circumstances where pipelines will trigger a `terragrunt run-all` it is important that all IaC is valid or properly excluded.
19+
Depending on the type of run pipeline is executing, broken IaC can fail a pipeline and prevent other, legitimate changes from being deployed. Especially in circumstances where pipelines will trigger a `terragrunt run --all` it is important that all IaC is valid or properly excluded.
2020

2121
## Resolution Strategies
2222

2323
Here are several approaches to manage broken IaC, presented in order of preference:
2424

25-
### 1. Fix the Invalid Code (Preferred Solution)
25+
### Fix the Invalid Code (Preferred Solution)
2626

2727
The ideal solution is to fix the underlying issues:
2828

@@ -41,7 +41,7 @@ git push
4141

4242
Then create a merge/pull request to apply the fix to your main branch.
4343

44-
### 2. Remove the Invalid IaC
44+
### Remove the Invalid IaC
4545

4646
If you can't fix the issue immediately but the infrastructure is no longer needed, you can remove the problematic code:
4747

@@ -55,22 +55,22 @@ git commit -m "Remove deprecated infrastructure module"
5555
git push
5656
```
5757

58-
### 3. Use a `.terragrunt-excludes` File
58+
### Use a `.terragrunt-excludes` File
5959

6060
If you wish to keep the broken code as is and simply have it ignored by pipelines and Terragrunt, you can use a `.terragrunt-excludes` file to skip problematic units:
6161

62-
1. Create a `.terragrunt-excludes` file in the root of your repository:
62+
Create a `.terragrunt-excludes` file in the root of your repository:
6363

64-
```
65-
# .terragrunt-excludes
66-
# One directory per line (no globs)
67-
account/region/broken-module1
68-
account/region/broken-module2
69-
```
64+
```text
65+
# .terragrunt-excludes
66+
# One directory per line (no globs)
67+
account/region/broken-module1
68+
account/region/broken-module2
69+
```
7070

71-
2. Commit this file to your repository, and Terragrunt will automatically exclude these directories when using `run-all`. Note, if you make a change to the code in those units and pipelines triggers a `run` in that directory itself, then the exclude will not be applied.
71+
Commit this file to your repository, and Terragrunt will automatically exclude these directories when using `run --all`. Note, if you make a change to the code in those units and pipelines triggers a `run` in that directory itself, then the exclude will not be applied.
7272

73-
### 4. Configure Exclusions with Pipelines Environment Variables
73+
### Configure Exclusions with Pipelines Environment Variables
7474

7575
If you don't wish to use `.terragrunt-excludes` in the root of the repository, you can create another file in a different location and set the `TG_QUEUE_EXCLUDES_FILE` environment variable to that path. You then use the Pipelines [`env` block](/2.0/reference/pipelines/configurations-as-code/api#env-block) in your `.gruntwork/pipelines.hcl` configuration to set environment variables that control Terragrunt's behavior:
7676

@@ -94,14 +94,14 @@ repository {
9494
When excluding modules, be aware of dependencies:
9595

9696
1. If module B depends on module A, and module A is excluded, you may need to exclude module B as well.
97-
2. Use `terragrunt graph-dependencies` to visualize your dependency tree.
97+
2. Use `terragrunt dag graph` to visualize your dependency tree.
9898

9999
## Best Practices
100100

101101
1. **Document exclusions**: Add comments to your `.terragrunt-excludes` file explaining why each directory is excluded.
102102
2. **Track in issue system**: Create tickets for excluded modules that need to be fixed, including any relevant dates/timelines for when they should be revisited.
103103
3. **Regular cleanup**: Periodically review and update your excluded directories.
104-
4. **Validate locally**: Run `terragrunt hcl-validate` or `terragrunt validate` locally before committing changes.
104+
4. **Validate locally**: Run `terragrunt hcl validate` or `terragrunt validate` locally before committing changes.
105105

106106
## Troubleshooting
107107

@@ -112,4 +112,4 @@ If you're still experiencing issues after excluding directories:
112112
- Review pipeline logs to confirm exclusions are being applied
113113
- Verify you don't have conflicting environment variable settings
114114

115-
By implementing these strategies, you can keep your infrastructure pipelines running smoothly while addressing underlying issues in your codebase.
115+
By implementing these strategies, you can keep your infrastructure pipelines running smoothly while addressing underlying issues in your codebase.

0 commit comments

Comments
 (0)