It is possible to configure an application load balancer to authenticate the user using Cognito service and forward requests to any application available in private subnets.
You need to create a listener rule with 2 actions:
authenticate-cognito
action to redirect user to your SSO provider login page (a cognito user pool must be configured);
forward
action to your target group with the application.
See an example of terraform aws_lb_listener_rule
definition:
resource "aws_lb_listener_rule" "listener_rule" {
listener_arn = your_alb_listener_443_arn
action {
type = "authenticate-cognito"
authenticate_cognito {
user_pool_arn = your_cognito_user_pool.cognito_user_pool.arn
user_pool_client_id = your_user_pool_client_id
user_pool_domain = your_cognito_user_pool_domain
}
}
action {
type = "forward"
target_group_arn = your_lb_target_group_arn
}
condition {
host_header {
values = [
"your_domain" # resolves ALB endpoint
]
}
}
lifecycle {
create_before_destroy = true
}
}
As Patrick and Leo mentioned in comments, AWS OpenSearch provides fine-grained access control and has embedded SSO authentication mechanisms that lets you use your existing identity provider:
It works very well if your cluster is publicly available
However, documentation does not bring the light how it works when a cluster provisioned in VPC, in private subnets).
Refer to this question.