Unsupported Attribute Error When Executing Terraform Plan

Hello Guys,

When running the terraform plan command, my Terraform environment encountered an issue with the terraform-aws-modules/alb/aws module. The specific error is as follows:

Error: Unsupported attribute

  on .terraform/modules/its_alb/main.tf line 527, in resource "aws_lb_target_group_attachment" "this":
 527:   target_id         = each.value.target_id
    │ each.value is object with 4 attributes

This object does not have an attribute named "target_id".

I am using version 9.4.1 of the AWS ALB module, and when creating instances of type aws_lb_target_group_attachment according to the module documentation, I am facing difficulties due to the mentioned error.

my terraform code alb.tf:

module "its_alb" {
  source                = "terraform-aws-modules/alb/aws"
  version               = "9.4.1"
  name                  = "its-alb"
  subnets               = module.its_vpc_us_east_2.private_subnets
  create_security_group = false
  security_groups       = [module.its_alb_sg.security_group_id]
  vpc_id                = module.its_vpc_us_east_2.vpc_id
  listeners = {
    http-https-redirect = {
      port        = 80
      protocol    = "HTTP"
      redirect = {
        port        = "443"
        protocol    = "HTTPS"
        status_code = "HTTP_301"

    https_listeners = {
      port               = 443
      protocol           = "HTTPS"
      certificate_arn    = aws_acm_certificate.cert.arn

      forward = {
        target_groups_key = "ex-target"

  target_groups = {
    ex-target = {
      name_prefix      = "its-"
      backend_protocol = "HTTP"
      backend_port     = var.http_port
      target_type      = "ip"
      health_check = {
        enabled             = true
        interval            = 30
        path                = "/"
        port                = var.http_port
        healthy_threshold   = 5
        unhealthy_threshold = 2
        timeout             = 5
        protocol            = "HTTP"
        matcher             = "200"


Steps Taken So Far:

  1. Checked the module documentation, and the syntax used is according to the guidelines.
  2. Confirmed that subnets and security groups are correct and accessible.

Request for Help:

  • Has anyone encountered this issue before, or does anyone have any suggestions on how to resolve it?
  • Is there any additional configuration that may be required?

I appreciate any guidance or assistance you can provide.

Thank you

The error you’re encountering indicates that within the aws_lb_target_group_attachment resource, the target_id attribute is being referenced, but it’s not present in the each.value object. This can happen if the data structure you’re iterating over in your Terraform configuration doesn’t include a target_id attribute. It’s important to ensure that the target_groups definition in your ALB module correctly includes target_id in its structure, and that it aligns with how the aws_lb_target_group_attachment resource expects it. Check the structure of your target_groups and ensure it’s consistent with the module’s requirements and Terraform’s resource specifications.