You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using version 8.7.0, The listener rule is updated only with target-group-1 and not with target-group-2 together,
Manually via the AWS console- we can add up to 4 target groups to the same listener rule.
My code in terraform is:
module "alb" {
source = "terraform-aws-modules/alb/aws"
version = "~> 8.0"
│ Error: Unsupported attribute
│
│ on .terraform/modules/alb/main.tf line 597, in resource "aws_lb_target_group_attachment" "this":
│ 597: target_id = each.value.target_id
│ ├────────────────
│ │ each.value is object with 5 attributes
│
│ This object does not have an attribute named "target_id".
The text was updated successfully, but these errors were encountered:
Description
When using version 8.7.0, The listener rule is updated only with target-group-1 and not with target-group-2 together,
Manually via the AWS console- we can add up to 4 target groups to the same listener rule.
My code in terraform is:
module "alb" {
source = "terraform-aws-modules/alb/aws"
version = "~> 8.0"
name = "${var.customer}-alb"
load_balancer_type = "application"
vpc_id = var.vpc_id
subnets = var.public_subnets_ids
security_groups = [module.lb_sg.security_group_id]
create_security_group = false
preserve_host_header = true
drop_invalid_header_fields = true
https_listeners = [
{
port = 443
protocol = "HTTPS"
certificate_arn = var.load_balancer_acm_arn
target_group_index = 0
ssl_policy = "ELBSecurityPolicy-TLS13-1-2-2021-06"
}
]
https_listener_rules = [
{
https_listener_index = 0
actions = [{
type = "fixed-response"
content_type = "text/html"
status_code = 403
message_body = "<img src="https://media.giphy.com/media/l0ErQ2UfBNFEIlqjC/giphy.gif" alt="this slowpoke moves" width="100%" height="100%" alt="404 image"/>"
}]
]
target_groups = [
{
name = "${var.customer}-target-group-1"
backend_protocol = "HTTP"
backend_port = 44
target_type = "instance"
health_check = {
enabled = true
path = "/ping"
port = "traffic-port"
protocol = "HTTP"
}
},
{
name = "${var.customer}-target-group-2"
backend_protocol = "HTTP"
backend_port = 44
target_type = "instance"
health_check = {
enabled = true
path = "/ping"
port = "traffic-port"
protocol = "HTTP"
}
}
]
Enable access logging
access_logs = {
bucket = var.access_logs_bucket
prefix = var.access_logs_bucket_prefix
enabled = true
}
tags = {
Environment = var.customer
}
}
resource "aws_lb_target_group_attachment" "ggr_attachments_1" {
count = var.ggr_count
target_group_arn = module.alb.target_groups["target_group_1"].arn
target_id = module.ggr_instance_1[count.index].id
port = 44
}
resource "aws_lb_target_group_attachment" "ggr_attachments_2" {
count = var.ggr_count
target_group_arn = module.alb.target_groups["target_group_2"].arn
target_id = module.ggr_instance_2[count.index].id
port = 44
}
Versions
Your version of Terraform is out of date! The latest version
is 1.10.5. You can update by downloading from https://www.terraform.io/downloads.html
I tried to use the latest version 9.13.0
module "alb" {
source = "terraform-aws-modules/alb/aws"
version = "~> 9.0"
name = "${var.customer}-alb"
load_balancer_type = "application"
vpc_id = var.vpc_id
subnets = var.public_subnets_ids
security_groups = [module.lb_sg.security_group_id]
create_security_group = false
preserve_host_header = true
drop_invalid_header_fields = true
target_groups = {
target_group_1 = {
name = "${var.customer}-target-group-1"
backend_protocol = "HTTP"
backend_port = 44
target_type = "instance"
health_check = {
enabled = true
path = "/ping"
port = "traffic-port"
protocol = "HTTP"
}
}
target_group_2 = {
name = "${var.customer}-target-group-2"
backend_protocol = "HTTP"
backend_port = 44
target_type = "instance"
health_check = {
enabled = true
path = "/ping"
port = "traffic-port"
protocol = "HTTP"
}
}
}
listeners = {
https = {
port = 443
protocol = "HTTPS"
certificate_arn = var.load_balancer_acm_arn
ssl_policy = "ELBSecurityPolicy-TLS13-1-2-2021-06"
forward = {
target_group_key = "instance"
}
}
Enable access logging
access_logs = {
bucket = var.access_logs_bucket
prefix = var.access_logs_bucket_prefix
enabled = true
}
tags = {
Environment = var.customer
}
}
resource "aws_lb_target_group_attachment" "ggr_attachments_1" {
count = var.ggr_count
target_group_arn = module.alb.target_groups["target_group_1"].arn
target_id = module.ggr_instance_1[count.index].id
port = 44
}
resource "aws_lb_target_group_attachment" "ggr_attachments_2" {
count = var.ggr_count
target_group_arn = module.alb.target_groups["target_group_2"].arn
target_id = module.ggr_instance_2[count.index].id
port = 44
}
====================================================
The error that I get is
│ Error: Unsupported attribute
│
│ on .terraform/modules/alb/main.tf line 597, in resource "aws_lb_target_group_attachment" "this":
│ 597: target_id = each.value.target_id
│ ├────────────────
│ │ each.value is object with 5 attributes
│
│ This object does not have an attribute named "target_id".
The text was updated successfully, but these errors were encountered: