'Terragrunt ignores newly added outputs in a project
I've inherited a terraform project set up to deploy to the Elastic Container Service on AWS.
So far, I've greatly enjoyed working with it, and have managed to change a few things despite being very new to terraform.
Our project uses terragrunt to martial the environments and I've made changes tot he files to add environment specific settings before and it's gone great.
However, I've tried to add a whole new shiny module and... terragrunt hates it.
This is the code I've tried to add:
terraform {
source = "${path_relative_from_include()}/../modules//auto_scaling"
}
dependency "analytics_cluster" {
config_path = "../analytics_cluster"
}
dependency "analytics_app" {
config_path = "../analytics_app"
}
include {
path = find_in_parent_folders()
}
inputs = {
ecs_cluster_name = dependency.analytics_cluster.outputs.name
ecs_app_service_name = dependency.analytics_app.outputs.app_service_name
ecs_sidecar_service_name = dependency.analytics_app.outputs.sidecar_service_name
}
dependencies {
paths = [
"../analytics_cluster",
"../analytics_app",
]
}
and the error I'm getting is:
terragrunt.hcl:19,62-79: Unsupported attribute; This object does not have an attribute named "app_service_name"., and 1 other diagnostic(s)
This is a variable I added into the outputs of the module whose dependency I have set.
This is what the outputs look like:
# output "service_name" {
# value = module.analytics_app.service_name
# }
output "app_service_name" {
value = module.analytics_app.app_service
}
output "sidecar_service_name" {
value = module.analytics_app.sidecar_service
}
The weirdest thing is if I change the .hcl file to the commented out output, like so:
inputs = {
ecs_cluster_name = dependency.analytics_cluster.outputs.name
ecs_app_service_name = dependency.analytics_app.outputs.service_name
}
then this is a valid input, despite the fact that service_name is now commented out.
Why are the new output variables not being picked up? And why is the old variable which I've removed still present?
Solution 1:[1]
My guess is that you are only picking up the outputs
of previously applied modules. This is because when a module is applied, its contents (along with an outputs.tf
definition) are created in the .terragrunt-cache
directory.
When you add a new variable but do not apply it, that file won't be regenerated as well, hence the missing attribute.
Try running tg apply
on the dependency before running tg init
on the target module.
I had this problem when I tried to run-all apply
on a new repository with dependencies. Terragrunt said no outputs exist for the dependencies, but this also was because dependency modules were not applied yet. After I manually applied them - it worked.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Nexaspx |