Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for ECS service registration w/ multiple target groups #9285

Closed
ryanschneider opened this issue Jul 9, 2019 · 5 comments · Fixed by #9411
Closed

Support for ECS service registration w/ multiple target groups #9285

ryanschneider opened this issue Jul 9, 2019 · 5 comments · Fixed by #9411
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/ecs Issues and PRs that pertain to the ecs service.
Milestone

Comments

@ryanschneider
Copy link

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 ™️ 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

@ryanschneider ryanschneider added the enhancement Requests to existing resources that expand the functionality or scope. label Jul 9, 2019
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Jul 9, 2019
@ryanschneider
Copy link
Author

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

@aeschright aeschright added the service/ecs Issues and PRs that pertain to the ecs service. label Jul 11, 2019
@sunilkumarmohanty
Copy link
Contributor

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

@bflad bflad removed the needs-triage Waiting for first response or review from a maintainer. label Jul 18, 2019
@bflad bflad added this to the v2.22.0 milestone Jul 30, 2019
@bflad
Copy link
Contributor

bflad commented Jul 30, 2019

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. 👍

@ghost
Copy link

ghost commented Aug 1, 2019

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!

@ghost
Copy link

ghost commented Nov 2, 2019

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!

@ghost ghost locked and limited conversation to collaborators Nov 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/ecs Issues and PRs that pertain to the ecs service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants