Having this dependency declaration in module example-app:
dependency "infra_base" {
config_path = "../stack-infra-base"
}
inputs = {
public_subnets_ids = dependency.infra_base.outputs.public_subnets_ids
}
running terragrunt plan-all for the first time fails with this error:
example-app/terragrunt.hcl:14,53-72: Unsupported attribute; This object does not have an attribute named "public_subnets_ids".
[terragrunt] 2019/08/16 09:54:37 Unable to determine underlying exit code, so Terragrunt will exit with error code 1
If you run terragrunt apply-all the error is gone.
Is this an expected behavior?
When you say "plan-all for the first time fails", by "first time," do you mean _before_ stack-infra-base has been applied?
Exactly, stack-infra-base is not applied yet.
@yorinasub17 The dependency block should probably detect if a module hasn't been applied and show a clear error to indicate this.
Opened PR to handle report better error messages: https://github.com/gruntwork-io/terragrunt/pull/840
In general, plan-all is not expected to work cleanly on a completely new infrastructure build if you have dependencies, because we don't have advanced features that stitch terraform plans together.
Internally in terraform, there is a concept of computable outputs which are then used to seed the inputs of other resources and modules, which "taint" and propagate through to predict if a resource would be created or not. In terragrunt, when you cross modules, we can't use that same terraform system to taint the plan across the modules because it is a completely different terraform module, and it is a huge overhead to implement something like that.
However, to allow you to simulate something like this, I also implemented a new feature: default_outputs. This is a static map that you can use as dummy outputs if no module has been applied, so that terraform can compute a plan or run validate. Otherwise, terragrunt can't compute the inputs so it will error out. Check out the PR and updated README for more info.
Resolved and released in https://github.com/gruntwork-io/terragrunt/releases/tag/v0.19.23 (binaries should show up shortly). See the relevant section of the README for more info.
Most helpful comment
Opened PR to handle report better error messages: https://github.com/gruntwork-io/terragrunt/pull/840
In general,
plan-allis not expected to work cleanly on a completely new infrastructure build if you have dependencies, because we don't have advanced features that stitch terraform plans together.Internally in terraform, there is a concept of computable outputs which are then used to seed the inputs of other resources and modules, which "taint" and propagate through to predict if a resource would be created or not. In terragrunt, when you cross modules, we can't use that same terraform system to taint the plan across the modules because it is a completely different terraform module, and it is a huge overhead to implement something like that.
However, to allow you to simulate something like this, I also implemented a new feature:
default_outputs. This is a static map that you can use as dummy outputs if no module has been applied, so that terraform can compute aplanor runvalidate. Otherwise, terragrunt can't compute theinputsso it will error out. Check out the PR and updated README for more info.