"Unsupported attribute" This object does not have an attribute named "this_ecs_cluster_id"

I’ve been trying to figure out this issue for months now with no success, I can’t help but feel it is something minor/dumb. Possibly something to do with upgrading TF to a later version? our pipeline did this automatically and I didn’t realize it. I’ve since tried to roll back the TF version with no success though.

I’m thinking its one of these issues…

  1. A version change bump was increased and could have caused unwanted behavior? (both TF version or possibly module(s))
  2. The state somehow got unhealthy (I’ve manually removed all new resources since it last ran successfully by using terraform state rm command, then I commented out the code so it does not try to add it back in again.

I can successfully run terraform init, however running terraform plan or even terraform apply will result in the following error.

│ Error: Unsupported attribute
│ 
│   on ../modules/ecs/output.tf line 2, in output "this_ecs_cluster_id":
│    2:   value = module.ecs.this_ecs_cluster_id
│     ├────────────────
│     │ module.ecs is a object, known only after apply
│ 
│ This object does not have an attribute named "this_ecs_cluster_id".
╵
╷
│ Error: Unsupported attribute
│ 
│   on ../modules/ecs/output.tf line 2, in output "this_ecs_cluster_id":
│    2:   value = module.ecs.this_ecs_cluster_id
│     ├────────────────
│     │ module.ecs is a object, known only after apply
│ 

This is my outputs.tf file in the ecs module.

output "this_ecs_cluster_id" {
  value = module.ecs.this_ecs_cluster_id
}

output "ec2_instance_iam_role_id" {
  value = aws_iam_role.this.id
}

Then in the main config, I’m setting the cluster_id by calling cluster_id = module.ecs.this_ecs_cluster_id in multiple locations.

I’m wondering if I have a chicken/egg situation, and need to possibly declare a depends on somewhere after a version change?

I believe the modules you are using recently made some breaking changes, so you’ll need to check their current documentation and update your code accordingly.

1 Like

There is a bunch, but I’ll give them a read! I’m pretty sure there is no module version limit I set, and this would make sense as to what could have happened. Thank you for the tip, i’ll do some digging at the ECS module today.

I added a version constraint in the ECS module and it appears to have resolved the issue for now.

module "ecs" {
  source = "terraform-aws-modules/ecs/aws"
  version = "2.9.0"
  name   = var.cluster_name
}

I guess I need to go through the code and check out the big changes in 3.X to see what changed and how to adapt our code for it. Thank you @stuart-c for the tip!