我有一个 AWS ALB,它应该前端是一个用 Angular 编写的 ECS Fargate 前端应用程序和一个用 NestJS 编写的后端。我打算对前端和后端使用单个 ALB,因此,我设置了一个侦听器规则,该规则应采用大约 7 个后端条件规则,这些规则是路径模式。
当我尝试部署此应用程序时遇到的错误是:-
updating ECS Service InvalidParameterException: load balancers can have at most 5 items.
我知道 AWS 文档中的限制约为 100 个项目。
我有这个 Terraform 代码,应该配置基础设施:-
resource "aws_ecs_service" "ecs_service_def" {
name = "backend-service"
task_definition = "${aws_ecs_task_definition.ecs_task_def.family}"
desired_count = 1
force_new_deployment = true
health_check_grace_period_seconds = 300
launch_type = "FARGATE"
cluster = data.aws_ecs_cluster.this.id
depends_on = [
aws_iam_role_policy.ecs_service_role_policy,
data.aws_alb_listener.selected443
]
deployment_circuit_breaker {
enable = true
rollback = true
}
network_configuration {
security_groups = ["sg-0233333337779"]
subnets = var.db_subnet_ids
}
load_balancer {
target_group_arn = aws_alb_target_group.upload.arn
container_name = "backend"
container_port = "3000"
}
load_balancer {
target_group_arn = aws_alb_target_group.search-logs.arn
container_name = "backend"
container_port = "3000"
}
load_balancer {
target_group_arn = aws_alb_target_group.log-file-info.arn
container_name = "backend"
container_port = "3000"
}
dynamic "load_balancer" {
for_each = local.ecs_load_balancers
content {
container_name = load_balancer.value.container_name
container_port = load_balancer.value.container_port
target_group_arn = load_balancer.value.target_group_arn
}
}
}
locals {
ecs_load_balancers = [
{
container_name = "backend"
container_port = "3000"
target_group_arn = aws_alb_target_group.download.arn
},
{
container_name = "backend"
container_port = "3000"
target_group_arn = aws_alb_target_group.update-log-status.arn
},
{
container_name = "backend"
container_port = "3000"
target_group_arn = aws_alb_target_group.log-upload-info.arn
},
{
container_name = "backend"
container_port = "3000"
target_group_arn = aws_alb_target_group.recent-logs.arn
}]
}
我正在使用动态块来配置剩余的规则,但无论我对 Terraform 逻辑进行什么更改,“应用”操作总是会错误地显示给定的消息。
如果有人可以分享此问题的解决方案,我们将不胜感激。