aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.41k stars 3.8k forks source link

ApplicationMultipleTargetGroupsFargateService: allow modify healthcheck path on each targetgroup #20943

Open weiluo8791 opened 2 years ago

weiluo8791 commented 2 years ago

Describe the bug

There is no ability to change or modify the healthcheck path or port for each targetgroup it created. I can only modify the first targetgroup (default).

Expected Behavior

be able to change and modify each targetgroup's healthcheck setting

Current Behavior

const fargateService = new ecs_patterns.ApplicationMultipleTargetGroupsFargateService(this, "MyFargateService", { serviceName: "ecs-service-name", desiredCount: 2, cluster, taskDefinition, assignPublicIp: false, loadBalancers: [applicationLoadBalancerProps], targetGroups: [ { containerPort: 8081, protocol: ecs.Protocol.TCP, }, { containerPort: 8082, pathPattern: "/route1/", priority: 2, protocol: ecs.Protocol.TCP, }, { containerPort: 8082, pathPattern: "/route2/", priority: 3, protocol: ecs.Protocol.TCP, }, ], healthCheckGracePeriod: Duration.seconds(300), });

fargateService.targetGroup.configureHealthCheck({
  path: "/8081-health-check-endpoint",
  timeout: Duration.seconds(30),
  interval: Duration.seconds(120),
  unhealthyThresholdCount: 5,
  healthyThresholdCount: 3,
})

Reproduction Steps

use the example code

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.12

Framework Version

No response

Node.js Version

14.17.3

OS

Mac OS 11.6.7

Language

Typescript

Language Version

No response

Other information

No response

peterwoodworth commented 2 years ago

Thanks for reporting this! Our ECS Patterns constructs can often leave behind some configurability in favor of creating higher level abstractions. If you, or anyone can find a way to configure this setting better for each target group, we'd be happy to review a PR. The team probably won't be able to get to this soon. Check out the contributing guide if you're interested!

joshbalfour commented 1 year ago

i've found the service.targetGroups array's ordering to be consistent with how you configured it initially, so you can go service.targetGroups[0].configureHealthCheck() as a workaround