Terraform code:
module "alb" {
source = "terraform-aws-modules/alb/aws"
version = "8.1.0"
// ...
target_groups = [
{
// ...
}
},
{
name = "lb-number-one"
backend_port = 80
backend_protocol = "HTTPS"
target_type = "ip"
}
]
https_listeners = [
{
port = 443
protocol = "HTTPS"
certificate_arn = aws_acm_certificate.this[0].arn
target_group_index = 0
}
]
// ...
https_listener_rules = [
{
actions = [{
// ...
}]
conditions = [{
// ...
}]
},
]
}
resource "aws_lb_listener_rule" "https_listener_rules" {
listener_arn = module.alb.https_listeners[0].arn
priority = 100
action {
type = "forward"
target_group_arn = module.alb.target_groups[1].arn
}
condition {
host_header {
// ...
}
}
}
For some reason, when I try to apply the code above, I get the error, that module.alb
is an object:
╷
│ Error: Unsupported attribute
│
│ on alb.tf line 92, in resource "aws_lb_listener_rule" "https_listener_rules":
│ 92: listener_arn = module.alb.https_listeners[0].arn
│ ├────────────────
│ │ module.alb is a object
│
│ This object does not have an attribute named "https_listeners".
╵
╷
│ Error: Unsupported attribute
│
│ on alb.tf line 97, in resource "aws_lb_listener_rule" "https_listener_rules":
│ 97: target_group_arn = module.alb.target_groups[1].arn
│ ├────────────────
│ │ module.alb is a object
│
│ This object does not have an attribute named "target_groups".
But why is he not able to access this attributes? And why does the fact, that module.alb
is an object avoid accessing the attribute?