Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support merging the "skip" attribute from included files. #3225

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rodrigorfk
Copy link

Description

Fixes #3224.

This PR is introducing support for merging the content of the skip attribute from include blocks, in the same way of many other attributes and blocks are already being merged.

TODOs

Read the Gruntwork contribution guidelines.

  • Update the docs.
  • Run the relevant tests successfully, including pre-commit checks.
  • Ensure any 3rd party code adheres with our license policy or delete this line if its not applicable.
  • Include release notes. If this PR is backward incompatible, include a migration guide.

Release Notes (draft)

Added / Removed / Updated [X].

@denis256
Copy link
Member

-- FAIL: TestResolveTerraformModulesReadConfigFromParentConfig (0.02s)

Expected :config.TerragruntConfig{Catalog:(*config.CatalogConfig)(nil), Terraform:(*config.TerraformConfig)(0xc0006abf10), TerraformBinary:"", TerraformVersionConstraint:"", TerragruntVersionConstraint:"", RemoteState:(*remote.RemoteState)(nil), Dependencies:( ...

Actual   :config.TerragruntConfig{Catalog:(*config.CatalogConfig)(nil), Terraform:(*config.TerraformConfig)(0xc000129260), TerraformBinary:"", TerraformVersionConstraint:"", TerragruntVersionConstraint:"", RemoteState:(*remote.RemoteState)(nil), Dependencies:( ...

@denis256
Copy link
Member

Integration test TestApplyAllSkipTrue also seems to fail

    integration_test.go:4314: Copying fixture-skip/ to /tmp/terragrunt-test2863889219
    integration_test.go:4268: [terragrunt apply-all --terragrunt-non-interactive --terragrunt-working-dir /tmp/terragrunt-test2863889219/fixture-skip/skip-true --terragrunt-log-level info]
    integration_test.go:2010: [TestApplyAllSkipTrue] Full contents of show stdout:
    integration_test.go:2010: [TestApplyAllSkipTrue] 
    integration_test.go:2011: [TestApplyAllSkipTrue] Full contents of show stderr:
    integration_test.go:2011: [TestApplyAllSkipTrue] time=2024-06-24T15:42:21+01:00 level=warning msg='apply-all' is deprecated. Running 'terragrunt run-all apply' instead. Please update your workflows to use 'terragrunt run-all apply', as 'apply-all' may be removed in the future!
    integration_test.go:2011: [TestApplyAllSkipTrue] 
    integration_test.go:2011: [TestApplyAllSkipTrue] time=2024-06-24T15:42:21+01:00 level=info msg=The stack at /tmp/terragrunt-test2863889219/fixture-skip/skip-true will be processed in the following order for command apply:
    integration_test.go:2011: [TestApplyAllSkipTrue] Group 1
    integration_test.go:2011: [TestApplyAllSkipTrue] - Module /tmp/terragrunt-test2863889219/fixture-skip/skip-true
    integration_test.go:2011: [TestApplyAllSkipTrue] - Module /tmp/terragrunt-test2863889219/fixture-skip/skip-true/resource1
    integration_test.go:2011: [TestApplyAllSkipTrue] - Module /tmp/terragrunt-test2863889219/fixture-skip/skip-true/resource2
    integration_test.go:2011: [TestApplyAllSkipTrue] 
    integration_test.go:2011: [TestApplyAllSkipTrue] 
    integration_test.go:2011: [TestApplyAllSkipTrue] time=2024-06-24T15:42:21+01:00 level=info msg=Skipping terragrunt module /tmp/terragrunt-test2863889219/fixture-skip/skip-true/terragrunt.hcl due to skip = true. prefix=[/tmp/terragrunt-test2863889219/fixture-skip/skip-true] 
    integration_test.go:2011: [TestApplyAllSkipTrue] time=2024-06-24T15:42:21+01:00 level=info msg=Skipping terragrunt module /tmp/terragrunt-test2863889219/fixture-skip/skip-true/resource2/terragrunt.hcl due to skip = true. prefix=[/tmp/terragrunt-test2863889219/fixture-skip/skip-true/resource2] 
    integration_test.go:2011: [TestApplyAllSkipTrue] time=2024-06-24T15:42:21+01:00 level=info msg=Skipping terragrunt module /tmp/terragrunt-test2863889219/fixture-skip/skip-true/resource1/terragrunt.hcl due to skip = true. prefix=[/tmp/terragrunt-test2863889219/fixture-skip/skip-true/resource1] 
    integration_test.go:2011: [TestApplyAllSkipTrue] 
    integration_test.go:2018: 
        	Error Trace:	/home/denis256/projects/gruntwork/terragrunt/test/integration_test.go:2018
        	Error:      	"" does not contain "hello, Ernie"
        	Test:       	TestApplyAllSkipTrue
    integration_test.go:2019: 
        	Error Trace:	/home/denis256/projects/gruntwork/terragrunt/test/integration_test.go:2019
        	Error:      	"" does not contain "hello, Bert"
        	Test:       	TestApplyAllSkipTrue

The `skip` flag must be set explicitly in terragrunt modules that should be skipped. If you set `skip = true` in a
`terragrunt.hcl` file that is included by another `terragrunt.hcl` file, only the `terragrunt.hcl` file that explicitly
set `skip = true` will be skipped.
The `skip` flag can be inherited from an included `terragrunt.hcl` file if `skip` is defined there, unless it is
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think may be helpful to add an integration test for this case, when the skip flag is inherited from include

Copy link
Author

@rodrigorfk rodrigorfk Jun 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your suggestion @denis256 , I've updated the TestApplyAllSkipTrue integration test to cover this scenario as well, it was already using an partial terragrunt file there with a skip = true defined, so now one of the child modules is inheriting the skip and the other is overwriting it.

…handle the case where skip is inherited from the included terragrunt file

Signed-off-by: Rodrigo Fior Kuntzer <[email protected]>
@rodrigorfk
Copy link
Author

Thanks for publishing the failed tests here @denis256 and sorry for not catching them initially, I've fixed them.

@rodrigorfk
Copy link
Author

Hi @denis256 , could you please share the reason why the test_signing job failed? looking into it's definition it seems to only be related to binary signing and not really related to the specific change I am doing in this PR, right? thanks in advance.

@denis256
Copy link
Member

Hi,
it is an internal issue with Apple... I hope will be fixed soon

🍎 🪱

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Merge the "skip" attribute from included terragrunt files is not supported
2 participants