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

fix(init): do not require re-init after explicit init on clean directory #2949

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

Conversation

jaymecd
Copy link

@jaymecd jaymecd commented Feb 19, 2024

Description

Running terragrunt plan --terragrunt-no-auto-init on clean directory just after terragrunt init, raises confusing warning that init is needed.

On 1st clean init previousVersion is always empty, therefore no need to mark it as init required again and this warning is misleading.

How-to reproduce:

$ rm -rf .terragrunt-cache/

$ terragrunt init
INFO[0000] Downloading Terraform configurations from ...
Initializing the backend...
... 
Terraform has been successfully initialized!
...

$ terragrunt plan --terragrunt-no-auto-init
WARN[0000] Detected that init is needed, but Auto-Init is disabled. Continuing with further actions, but subsequent terraform commands may fail.  prefix=[/path/to/stack]
...

Workaround:

terraform {
  after_hook "cleanup_init_required_file" {
    commands = ["init"]
    execute  = ["sh", "-ec", "find . -type f -name .terragrunt-init-required -delete"]
  }
}

TODOs

Read the Gruntwork contribution guidelines.

  • Run the relevant tests successfully, including pre-commit checks.
  • Include release notes. If this PR is backward incompatible, include a migration guide.

Release Notes (draft)

Added / Removed / Updated [X].

Removed warning when using no-auto-init flag after explicit init on clean directory.

@denis256
Copy link
Member

Noticed failing test:

    download_source_test.go:378: 
        	Error Trace:	/home/circleci/project/cli/commands/terraform/download_source_test.go:378
        	            				/home/circleci/project/cli/commands/terraform/download_source_test.go:238
        	Error:      	Should be true
        	Test:       	TestDownloadTerraformSourceIfNecessaryRemoteUrlOverrideSource
--- FAIL: TestDownloadTerraformSourceIfNecessaryRemoteUrlOverrideSource (2.72s)

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.

None yet

2 participants