【问题标题】:ECS Service can't attach target group from different regionECS 服务无法附加来自不同区域的目标组
【发布时间】:2022-02-15 00:42:27
【问题描述】:

我有一个 ECS 服务,我想将两个负载均衡器附加到该服务,其中一个负载均衡器位于 ECS 集群的不同区域。当我尝试应用更改时,出现以下错误。

 InvalidParameterException: Unable to assume role and validate the specified targetGroupArn. Please verify that the ECS service role being passed has the proper permissions.

这是我正在使用的 terraform 代码和 terraform 计划的输出:

resource "aws_ecs_service" "monitoring_grafana_service" {
  name            = "grafana"
  cluster         = module.ecs.ecs_cluster_arn  
  task_definition = aws_ecs_task_definition.monitoring_grafana_task.arn
  desired_count   = 1

  network_configuration{
    subnets = module.monitoring_vpc.private_subnets  
    security_groups = [ module.grafana_sg.security_group_id ]
  }

  load_balancer {
    target_group_arn = module.frontend_alb.target_group_arns[0]
    container_name   = "grafana"
    container_port   = 3000
  }


  load_balancer {
    target_group_arn = data.terraform_remote_state.ireland_vpc.outputs.oss_target_group_arns[0]
    container_name   = "grafana"
    container_port   = 3000
  }
  
  lifecycle {
    ignore_changes = [
      capacity_provider_strategy
    ]
  }
}

输出:

      + load_balancer {
      + container_name   = "grafana"
      + container_port   = 3000
      + target_group_arn = "arn:aws:elasticloadbalancing:eu-central-1:myAcc:targetgroup/grafna20220202125410761200000016/1cdafdd8e73c1d9a"
    }
  + load_balancer {
      + container_name   = "grafana"
      + container_port   = 3000
      + target_group_arn = "arn:aws:elasticloadbalancing:eu-west-1:myAcc:targetgroup/grafna20220203130531009700000004/ff91959dcf50287e"
    }

ECS 使用的服务角色是 AWS 创建的“默认”角色。它具有 AWS 托管策略:AmazonECSServiceRolePolicy

【问题讨论】:

    标签: amazon-web-services terraform amazon-iam amazon-ecs


    【解决方案1】:

    集群是特定于区域的。可能是这个原因。

    网络负载均衡器现在支持从客户端连接到跨不同 AWS 区域的对等 VPC 中基于 IP 的目标。

    确保您的 VPC 已与目标资源建立对等连接

    https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-load-balancing.html

    【讨论】:

    • 我在两个 VPC 之间建立了连接。中转网关对等工作正常
    • 然后我会检查跨区域的 IAM 权限。错误说它不能承担这个角色,我没有对 terraform 做任何事情,只是原始 aws,如果某些东西不能承担这个角色,角色要么配置错误,而且 sts:assumeRole 不允许该服务承担这个角色或角色在不同的账户上,您可能需要跨账户策略,这里似乎不是这种情况。检查它创建的 iam 角色并在 aws 控制台上检查 Trusted entities
    【解决方案2】:

    事实证明这不受 ECS 支持。 (2021 年 2 月)

    【讨论】:

      猜你喜欢
      • 2019-11-28
      • 2019-05-15
      • 1970-01-01
      • 2020-04-29
      • 1970-01-01
      • 2020-11-28
      • 2022-10-06
      • 2012-03-14
      • 1970-01-01
      相关资源
      最近更新 更多