terragrunt-atlantis-config icon indicating copy to clipboard operation
terragrunt-atlantis-config copied to clipboard

Fails when there is a dependency in a before/after hook

Open tx-kstav opened this issue 3 years ago • 4 comments

Running terragrunt-atlantis-config on a file that has a before_hook or an after_hook that contains a reference to a terragrunt dependency fails with error message: Unknown variable; There is no variable named "dependency"..

$ terragrunt-atlantis-config version                                                                                                                                                                    
terragrunt-atlantis-config '1.6.0'

running with:

$ terragrunt-atlantis-config generate --create-workspace --create-project-name --output "atlantis.yaml" --parallel --autoplan                                                                       

Example file and error:

terraform {
  source = "{my_module_path}"
  before_hook "before_hook" {
    commands = ["apply"]
    execute = [
      "packer",
      "build",
      "-var", "assumed_role=${local.account_vars.locals.iam_role}",
      "-var", "vpc_id=${dependency.vpc.outputs.vpc_id}",
      "image/main.pkr.hcl",
    ]
  }
}

locals {
  account_vars = read_terragrunt_config(find_in_parent_folders("account.hcl"))
}

dependency "vpc" {
  config_path = "../../vpc/vpc-shared"
}

include {
  path = find_in_parent_folders()
}

inputs = {
  {various_inputs_for_my_module}
}
terragrunt.hcl:9,25-35: Unknown variable; There is no variable named "dependency".
FAIL: 1

Other info: Local terragrunt version: v0.28.18 Local terraform version: v0.14.9 Similar to https://github.com/transcend-io/terragrunt-atlantis-config/issues/102

fyi @jeromepin @dmattia

tx-kstav avatar May 30 '21 18:05 tx-kstav

We're running into this issue as well. Makes us sad pandas.

chris-lee-parsable avatar Dec 08 '21 20:12 chris-lee-parsable

Noted 😢

I use Terragrunt's parser for this part, but I use a partial parse in many cases, which doesn't evaluate all of the terragrunt blocks, and might be why this is happening?

Can you confirm that terragrunt can normally apply this type of file?

dmattia avatar Dec 09 '21 04:12 dmattia

just ran into this as well when setting an env var in a terraform block's extra_argments input. confirmed that terragrunt will happily apply this configuration without issue

userhas404d avatar Oct 12 '23 13:10 userhas404d

same in 1.18.0, it fails for both hooks and extra_arguments :(

slenky avatar May 09 '24 11:05 slenky