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

Upgrading from Terragrunt version 0.28.12 to 0.34.3 and onwards errors out with no variable named "dependency" #2298

Closed
atalwar-sephora opened this issue Oct 2, 2022 · 6 comments
Labels
awaiting response Waiting for a response or more data from issue reporter question stale Stale

Comments

@atalwar-sephora
Copy link

I am trying to upgrade terragrunt from version 0.28.12 to latest but seems there are some breaking change from 0.28.12 to 0.39.0. Therefore I started upgrading version by version checking all the changelogs.
The terragrunt plan works well till version 0.33.2 but as soon as I upgrade to version 0.34.0 and above I start getting below error on plan

terragrunt.hcl:64,28-38: Unknown variable; There is no variable named "dependency"., and 1 other diagnostic(s) 
ERRO[0000] Unable to determine underlying exit code, so Terragrunt will exit with error code 1 

I noticed that there are some breaking changes from v0.35.0 but that is on dependencies I am not using dependencies rather using dependency block.

My terragrunt.hcl looks like below:

terraform {
  source = "<module_source>"
}

include {
  path = "${find_in_parent_folders()}"
}

dependency "cert" {
  config_path = "../certificate"
  mock_outputs = {
    this_certificate_arn = ""
  }
}

dependency "svc" {
  config_path = "../svc"
}

dependency "network" {
  config_path = "../netwrok"
}

dependency "user" {
  config_path = "${get_parent_terragrunt_dir()}/../user"
}

dependency "dns" {
  config_path = "${get_parent_terragrunt_dir()}/dns"
}

dependency "registry" {
  config_path = "${get_parent_terragrunt_dir()}/../registry"
}

PS: I tried giving a label to include block as well. Still same issue.

@denis256
Copy link
Member

denis256 commented Oct 2, 2022

Hi,
from posted HCL file I don't see any issue, it may be caused from included HCL file or used dependencies

  • try upgrading to v0.38.5 or later to get the source file from where error occurs
  • try running Terragrunt with --terragrunt-log-level debug to get more insights about processed files

@denis256 denis256 added question awaiting response Waiting for a response or more data from issue reporter labels Oct 2, 2022
@atalwar-sephora
Copy link
Author

atalwar-sephora commented Oct 3, 2022

@denis256
Thanks for your response.
I tried running with debug, but did not help much, however giving a closer look to the error, I noticed that the error is not from the the hcl file that I shared but from the root hcl file which defines the common provider and common variables config.
Checking the file in question I found that I have below structure:

terraform {
  extra_arguments "common_vars" {
    commands = get_terraform_commands_that_need_vars()

    optional_var_files = [
      "${find_in_parent_folders("account.tfvars", "skip-account-if-does-not-exist")}",
      "${find_in_parent_folders("region.tfvars", "skip-region-if-does-not-exist")}",
      "${find_in_parent_folders("env.tfvars", "skip-env-if-does-not-exist")}",
      "${find_in_parent_folders("common.tfvars", "skip-common-if-does-not-exist")}",
      "${get_terragrunt_dir()}/terraform.tfvars"
    ]
  }
}

generate "common_variables" {
  path      = "common_variables.tf"
  if_exists = "overwrite_terragrunt"
  contents  = file("${get_parent_terragrunt_dir()}/../../common/common_variables.tf")
}

generate "common_providers" {
  path      = "common_providers.tf"
  if_exists = "overwrite_terragrunt"
  contents  = file("${get_parent_terragrunt_dir()}/../../common/common_providers.tf")
}

dependency "org" {
  config_path = "${get_parent_terragrunt_dir()}/../_global/org"
}

remote_state {
  // remote_state config
  //
}

inputs = {
  account_id = dependency.org.outputs.id
}

 iam_role = "arn:aws:iam::${dependency.org.outputs.id}:role/terragrunt"

In above config, if you notice role is out of all the blocks and that is where it was erroring out. I moved it to input block and it worked but I wonder how this was working with versions < 0.33.2

@denis256
Copy link
Member

denis256 commented Oct 3, 2022

Hi,
I need to dig more but I think handling of undeclared variables improved over versions...
Maybe the intention was to use iam_role? https://terragrunt.gruntwork.io/docs/reference/config-blocks-and-attributes/#iam_role

@atalwar-sephora
Copy link
Author

atalwar-sephora commented Oct 6, 2022

Hi @denis256
yes it is iam_role I think I edited it while pasting the code. (edited it above)

I think there was some fix for the similar issue in version 0.35.1 https://github.com/gruntwork-io/terragrunt/releases/tag/v0.35.1. on iam_role causing issues with dependency, but I am not able to figure our the what change is needed.

So, the setup work well if I hard code the account_id in iam_role = "arn:aws:iam::${dependency.org.outputs.id}:role/terragrunt" but with dependecy it does not work.

I tried running this with 0.36.12, 0.35.2 it fails with same error

@atalwar-sephora
Copy link
Author

PS: looks like there is already issue raised for this #1870 and seems there is a PR being worked on #1840 Can you confirm if this is the same issue?

Copy link

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.

@github-actions github-actions bot added the stale Stale label Dec 25, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting response Waiting for a response or more data from issue reporter question stale Stale
Projects
None yet
Development

No branches or pull requests

2 participants