You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/2.0/docs/pipelines/guides/handling-broken-iac.md
+17-17Lines changed: 17 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Handling Broken Infrastructure as Code
2
2
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.
4
4
5
5
This guide presents several strategies for handling broken IaC while keeping your pipelines operational.
6
6
@@ -16,13 +16,13 @@ Common causes of broken IaC include:
16
16
- Temporary or experimental code
17
17
- Resources or modules that have are work in progress
18
18
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.
20
20
21
21
## Resolution Strategies
22
22
23
23
Here are several approaches to manage broken IaC, presented in order of preference:
24
24
25
-
### 1. Fix the Invalid Code (Preferred Solution)
25
+
### Fix the Invalid Code (Preferred Solution)
26
26
27
27
The ideal solution is to fix the underlying issues:
28
28
@@ -41,7 +41,7 @@ git push
41
41
42
42
Then create a merge/pull request to apply the fix to your main branch.
43
43
44
-
### 2. Remove the Invalid IaC
44
+
### Remove the Invalid IaC
45
45
46
46
If you can't fix the issue immediately but the infrastructure is no longer needed, you can remove the problematic code:
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:
61
61
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:
63
63
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
+
```
70
70
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.
72
72
73
-
### 4. Configure Exclusions with Pipelines Environment Variables
73
+
### Configure Exclusions with Pipelines Environment Variables
74
74
75
75
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:
76
76
@@ -94,14 +94,14 @@ repository {
94
94
When excluding modules, be aware of dependencies:
95
95
96
96
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.
98
98
99
99
## Best Practices
100
100
101
101
1.**Document exclusions**: Add comments to your `.terragrunt-excludes` file explaining why each directory is excluded.
102
102
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.
103
103
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 hclvalidate` or `terragrunt validate` locally before committing changes.
105
105
106
106
## Troubleshooting
107
107
@@ -112,4 +112,4 @@ If you're still experiencing issues after excluding directories:
112
112
- Review pipeline logs to confirm exclusions are being applied
113
113
- Verify you don't have conflicting environment variable settings
114
114
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