cloudposse / terraform-aws-ecs-container-definition

Terraform module to generate well-formed JSON documents (container definitions) that are passed to the aws_ecs_task_definition Terraform resource
https://cloudposse.com/accelerate
Apache License 2.0
339 stars 244 forks source link

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

Closed ladung closed 8 months ago

ladung commented 8 months ago

Describe the Feature

Here is my code:

module "alb" {
  source = "terraform-aws-modules/alb/aws"

  name    = "my-alb"
  vpc_id  = "vpc-abcde012"
  subnets = ["subnet-abcde012", "subnet-bcde012a"]

  # Security Group
  security_group_ingress_rules = {
    all_http = {
      from_port   = 80
      to_port     = 80
      ip_protocol = "tcp"
      description = "HTTP web traffic"
      cidr_ipv4   = "0.0.0.0/0"
    }
    all_https = {
      from_port   = 443
      to_port     = 443
      ip_protocol = "tcp"
      description = "HTTPS web traffic"
      cidr_ipv4   = "0.0.0.0/0"
    }
  }
  security_group_egress_rules = {
    all = {
      ip_protocol = "-1"
      cidr_ipv4   = "10.0.0.0/16"
    }
  }

  access_logs = {
    bucket = "my-alb-logs"
  }

  listeners = {
    ex-http-https-redirect = {
      port     = 80
      protocol = "HTTP"
      redirect = {
        port        = "443"
        protocol    = "HTTPS"
        status_code = "HTTP_301"
      }
    }
    ex-https = {
      port            = 443
      protocol        = "HTTPS"
      certificate_arn = "arn:aws:iam::123456789012:server-certificate/test_cert-123456789012"

      forward = {
        target_group_key = "ex-instance"
      }
    }
  }

  target_groups = {
    ex-instance = {
      name_prefix      = "h1"
      protocol         = "HTTP"
      port             = 80
      target_type      = "ip"
    }
  }

  tags = {
    Environment = "Development"
    Project     = "Example"
  }
}

I have a problem:

Error: Unsupported attribute
│ 
│   on .terraform/modules/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".
╵
Releasing state lock. This may take a few moments...

Why?

Expected Behavior

1

Use Case

1

Describe Ideal Solution

1

Alternatives Considered

No response

Additional Context

No response