I try to set up lb for alertmanager via terraform and have some difficulties with code. Could you please help with it? There you can find a code from terraform : I use my code before for creation lb without cognito module, but after i added cognito auth i can't use it any more.
Lb with alertmanager:
source = "../../modules/aws-lb"
vpc_id = module.vpc.id
default_security_group_id = module.vpc.default_security_group_id
tags = local.tags
prefix = "${var.environment}-euc1"
target_groups = {
alertmanager = {
connect = "HTTP:9093"
target_type = "ip"
health_check = {
path = "/-/healthy"
matcher = 200
}
}
}
listeners = {
"HTTP:80" = {
actions = {
default = {
type = "redirect"
}
}
}
"HTTPS:443" = {
certificates_arns = [module.certificate_lb.arn]
actions = {
default = [{
type = "forward"
group = "alertmanager"
},
{
type = "authenticate-cognito"
authenticate_cognito = {
user_pool_arn = module.aws_cognito_user_pool.arn
user_pool_client_id = module.aws_cognito_user_pool.id["alertmanager"]
user_pool_domain = module.aws_cognito_user_pool.domain
}
}]
}
}
}
} ```
Error from terraform output:
│ Error: Invalid function argument
│
│ on ../../modules/aws-lb/lb.tf line 25, in resource "aws_lb_listener" "listener":
│ 25: type = lookup(default_action.value, "type", "forward")
│ ├────────────────
│ │ default_action.value is tuple with 2 elements
│
│ Invalid value for "inputMap" parameter: lookup() requires a map as the first argument.
on ../../modules/aws-lb/lb.tf line 26, in resource "aws_lb_listener" "listener":
│ 26: target_group_arn = lookup(default_action.value, "type", "forward") == "forward" ? aws_lb_target_group.tg[default_action.value.group].id : null
│ ├────────────────
│ │ default_action.value is tuple with 2 elements
│
│ Invalid value for "inputMap" parameter: lookup() requires a map as the first argument.
If you need more details, I can add.