terragrunt
                                
                                
                                
                                    terragrunt copied to clipboard
                            
                            
                            
                        Plan only on changed modules
According to the docs, when the command
terragrunt run-all plan
is applied,
This will recursively search the current working directory for any folders that contain Terragrunt modules and run
planin each one, concurrently, while respecting ordering defined via dependency and dependencies blocks. Describe alternatives you've considered
As plan on large infrastructures could be costly, Is there a way to plan only on the changed modules.
As far as I know the best way is outlined in this document.
https://terragrunt.gruntwork.io/docs/features/keep-your-terragrunt-architecture-dry/#considerations-for-cicd-pipelines
You'd use git-diff to collect all changed files in a PR, and run terragrunt plan on each one using -terragrunt-config in a CI script.
I'd love for this kind of "change detection" to be incorporated into terragrunt itself. Something based on a "git committish", e.g. git diff --name-only {{ COMMITISH }}. A commitish is something like 1.0.0...HEAD, and when passed to git diff --name-only, would list all the files changed between the branch HEAD and the 1.0.0 ref/tag. Terragrunt would then have some logic to walk the dependency tree and note which "included" working-dirs would be impacted by any of those changed files and filter in only those things impacted (or filter out and exclude, depending on perspective)...
We use Terramate in our Terragrunt repos to add change detection. E.g., instead of terragrunt apply-all we run terramate run --changed -- terragrunt apply, which runs the apply command on changed modules only.
What I like about Terramate is that it can be onboarded to any Terragrunt repository with a single command and without introducing any changes to our code. The team over at Terramate came up with an example also: https://github.com/terramate-io/terramate-terragrunt-infrastructure-live-example
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for raising this issue.
Bad stalebot. You're dismissed.