Terraform-provider-aws: Support for ECS service registration w/ multiple target groups

Created on 9 Jul 2019  ·  5Comments  ·  Source: hashicorp/terraform-provider-aws

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

The AWS team has just announced support for ECS services which can register w/ multiple target groups is in developer preview:

https://github.com/aws/containers-roadmap/tree/master/preview-programs/ecs-multipletg-service

As such, it'd be good to have support for this in Terraform. However, currently only a single load_balancer can be attached to an aws_ecs_service, see: https://www.terraform.io/docs/providers/aws/r/ecs_service.html#load_balancer-1

I'm opening this issue now before digging into the code, but based on the discussions in #4089 this may _just work_ :tm: if the validation logic is based solely on AWS responses. I'll update this issue w/ additional comments after I've looked into the provider code (which I'm not terribly familiar with, so that may take some time).

At a minimum, once this feature leaves developer preview the aws_ecs_service documentation will need to be updated.

New or Affected Resource(s)

  • aws_ecs_service

Potential Terraform Configuration

The easiest solution from a backwards-compat/developer experience perspective would be to support multiple load_balancer sections in the aws_ecs_service HCL. For example to expand on the example provided from the documentation:

resource "aws_ecs_service" "mongo" {
  name            = "mongodb"
  cluster         = "${aws_ecs_cluster.foo.id}"
  task_definition = "${aws_ecs_task_definition.mongo.arn}"
  desired_count   = 3
  iam_role        = "${aws_iam_role.foo.arn}"
  depends_on      = ["aws_iam_role_policy.foo"]

  ordered_placement_strategy {
    type  = "binpack"
    field = "cpu"
  }

  load_balancer {
    target_group_arn = "${aws_lb_target_group.foo.arn}"
    container_name   = "mongo"
    container_port   = 8080
  }

 # also attach to bar TG on port 8181
 load_balancer {
    target_group_arn = "${aws_lb_target_group.bar.arn}"
    container_name   = "mongo"
    container_port   = 8181
  }

  placement_constraints {
    type       = "memberOf"
    expression = "attribute:ecs.availability-zone in [us-west-2a, us-west-2b]"
  }
}

References

enhancement servicecs

Most helpful comment

Support for this has been tested and merged. It will release with version 2.22.0 of the Terraform AWS Provider, later this week. Thanks to @sunilkumarmohanty for the implementation. 👍

All 5 comments

Looks like the validation is currently done in the provider, so this line would need to be updated:

https://github.com/terraform-providers/terraform-provider-aws/blob/ca1bfac87548248c8a4812b502fee739a96e608b/aws/resource_aws_ecs_service.go#L155

Unfortunately, this cannot be released now as the feature is in developer preview.

Support for this has been tested and merged. It will release with version 2.22.0 of the Terraform AWS Provider, later this week. Thanks to @sunilkumarmohanty for the implementation. 👍

This has been released in version 2.22.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

Was this page helpful?
0 / 5 - 0 ratings