I need to create multiple target groups for an ECS service. Does anyone have an example of how I can do this via AWS CLI or API? As it is a recent functionality I have not found many examples.
This is a relatively new feature at ECS , I have not had the opportunity to test it in a project but just reading the documentation, it looks like pretty straight forward: Just add multiple load balancer (target groups) definitions inside the service. For example, if you're using Terraform , just add multiple load_balancer
blocks:
resource "aws_ecs_service" "my_service" {
name = "my_service"
cluster = "${aws_ecs_cluster.foo.id}"
task_definition = "${aws_ecs_task_definition.my_task.arn}"
... # other arguments
ordered_placement_strategy {
...
}
load_balancer {
target_group_arn = "${aws_lb_target_group.one.arn}"
container_name = "my_container_name"
container_port = 1234
}
load_balancer {
target_group_arn = "${aws_lb_target_group.two.arn}"
container_name = "my_container_name"
container_port = 4321
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.