It seems there's something weird going on with resource resolution in the case where I create an aws_ecs_task_definition and then reference it in a variable to be passed to another module, like this:
resource "aws_ecs_task_definition" "kibana" {
family = "kibana"
container_definitions = "${template_file.kibana-container-definitions.rendered}"
}
module "kibana" {
source = "./app"
task_definition = "${aws_ecs_task_definition.kibana.arn}"
}
(app is a module that creates ECS service + autoscaling group + ELB + Route53 record + security groups and all the other necessary evils of actually getting the thing running)
If I try to run terraform plan with this, I get the following error message:
Error configuring: 1 error(s) occurred:
* Resource 'aws_ecs_task_definition.kibana' does not have attribute 'arn' for variable 'aws_ecs_task_definition.kibana.arn'
Now, if I replace module "kibana" { ... } with output "kibana_arn" { value = "${aws_ecs_task_definition.kibana.arn}" }, terraform is able to plan correctly. terraform apply is also successful, creating the task definition.
After the task definition is successfully created, if I put the module "kibana" { ... } bit back, plan and apply both start to work. However, if I delete the task definition resource and try again with both task def + module, it fails.
Might this be a bug?
A wild guess, that this might be related to #2694.
Seems that this only occurs when adding a module with resource interpolation to an existing infrastructure, and not when applying to empty environment. And I can also reproduce it with template_file resource, so it's probably not AWS provider specific.
May be related: #2830
This issue has been fixed, along with issues like #2830!
anybody having similar issues use TF_LOG=TRACE terraform plan 2>&1 | grep JSON to find out until terraform gets fixed xD
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
anybody having similar issues use
TF_LOG=TRACE terraform plan 2>&1 | grep JSONto find out until terraform gets fixed xD