transcend-io / terragrunt-atlantis-config

Generate Atlantis config for Terragrunt projects.
https://transcend.io/blog/why-we-use-terragrunt
MIT License
627 stars 99 forks source link

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

Open tx-kstav opened 3 years ago

tx-kstav commented 3 years ago

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

chris-lee-parsable commented 2 years ago

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

dmattia commented 2 years ago

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?

userhas404d commented 1 year ago

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

slenky commented 6 months ago

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