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

Since v0.56.4, touch terragrunt.hcl causes init to run despite no other changes (possibly introduced by provider cache option) #3121

Closed
lorengordon opened this issue May 6, 2024 · 8 comments · Fixed by #3167
Assignees
Labels
bug Something isn't working

Comments

@lorengordon
Copy link
Contributor

Describe the bug

init is running every time I touch the terragrunt config, even though nothing has actually changed.

Steps To Reproduce

  1. Install terragrunt v0.56.3
  2. Run plan
  3. touch terragrunt.hcl
  4. Run plan.
  5. See init does not run on the second plan
  6. Install terragrunt v0.56.4
  7. touch terragrunt.hcl
  8. Run plan
  9. See init runs despite no changes needing init to run
  10. Repeat with terragrunt v0.58.3 to confirm problem still on latest version

Expected behavior

init should not run unless it needs to.

Versions

  • Terragrunt version: v0.56.4-v0.58.3
  • OpenTofu/Terraform version: Terraform 1.5.6
  • Environment details (Ubuntu 20.04, Windows 10, etc.): WSL/Ubuntu 22.04

Additional context

v0.56.4 introduced the Terragrunt Provider Cache, so that's my first suspect for this new behavior...

@lorengordon lorengordon added the bug Something isn't working label May 6, 2024
@lorengordon lorengordon changed the title Since v0.56.5, touch terragrunt.hcl causes init to run despite no other changes Since v0.56.4, touch terragrunt.hcl causes init to run despite no other changes May 6, 2024
@lorengordon lorengordon changed the title Since v0.56.4, touch terragrunt.hcl causes init to run despite no other changes Since v0.56.4, touch terragrunt.hcl causes init to run despite no other changes (possibly introduced by provider cache option) May 8, 2024
@levkohimins levkohimins self-assigned this May 27, 2024
@levkohimins
Copy link
Contributor

levkohimins commented May 27, 2024

Hi @lorengordon,
I tried to reproduce the issue but was unable to. I used the latest release v0.58.10 on MacOS.

Could you provide me with the configuration to reproduce the issue?

@lorengordon
Copy link
Contributor Author

Still happens for me on latest terragrunt version, 0.58.11, on Ubuntu. I'll see if I can create a minimal config. But I don't feel like I am doing anything special. Just include and terraform blocks (with a remote source), and a remote_state block in the parent config that uses s3 and the generate functionality.

@lorengordon
Copy link
Contributor Author

Actually where I first encountered this, I wasn't even using an include block with a parent config. It was all just baked into the one terragrunt.hcl.

@lorengordon
Copy link
Contributor Author

Oh, and the source wasn't actually remote either. But the source was using a local relative path and the double-slash notation... Hmm...

@lorengordon
Copy link
Contributor Author

Ok, that was it. Here's the setup:

❯ tree
.
└── terragrunt
    └── touch-init
        ├── main.tf
        └── terragrunt.hcl
❯ cat terragrunt/touch-init/main.tf
module "vpc" {
  source = "git::https://github.com/plus3it/terraform-aws-vpc.git?ref=v5.2.0"
}
❯ cat terragrunt/touch-init/terragrunt.hcl
terraform {
  source = "../..//terragrunt/touch-init"
}

Then:

  1. terragrunt plan --terragrunt-working-dir terragrunt/touch-init/
  2. touch terragrunt/touch-init/terragrunt.hcl
  3. terragrunt plan --terragrunt-working-dir terragrunt/touch-init/

And notice that init runs on the second plan:

❯ terragrunt plan --terragrunt-working-dir terragrunt/touch-init/
INFO[0000] Downloading Terraform configurations from file:///home/x/test into /home/x/.terragrunt-cache/cEJNhv9tZEaQzy00QSa56_XmMQU/3ugff0VcAJwSUgE8bxVCyDVxsYI
[terragrunt/touch-init/]
[terragrunt/touch-init/] Initializing the backend...
[terragrunt/touch-init/] Initializing modules...
[terragrunt/touch-init/]
[terragrunt/touch-init/] Initializing provider plugins...
[terragrunt/touch-init/] - Reusing previous version of hashicorp/aws from the dependency lock file
[terragrunt/touch-init/] - Using previously-installed hashicorp/aws v5.51.1
[terragrunt/touch-init/]
[terragrunt/touch-init/] Terraform has been successfully initialized!
[terragrunt/touch-init/]
[terragrunt/touch-init/] You may now begin working with Terraform. Try running "terraform plan" to see
[terragrunt/touch-init/] any changes that are required for your infrastructure. All Terraform commands
[terragrunt/touch-init/] should now work.
[terragrunt/touch-init/]
[terragrunt/touch-init/] If you ever set or change modules or backend configuration for Terraform,
[terragrunt/touch-init/] rerun this command to reinitialize your working directory. If you forget, other
[terragrunt/touch-init/] commands will detect it and remind you to do so if necessary.
[terragrunt/touch-init/]

@lorengordon
Copy link
Contributor Author

And again, this does not happen if I downgrade to terragrunt 0.56.3. The behavior starts in 0.56.4, and continues through the current terragrunt release 0.56.11.

@levkohimins
Copy link
Contributor

Hi @lorengordon, thanks for the example, I was finally able to reproduce the issue. I will let you know once the issue is fixed.

@lorengordon
Copy link
Contributor Author

Tested 0.58.12 and can confirm the problem is resolved! Thanks @levkohimins!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants