(ecs-patterns): Expose arrays of load balancers, listeners, and targetGroups as properties in ApplicationMultipleTargetGroupsFargateService and other patterns constructs
See original GitHub issueI want to utilize the construct ApplicationMultipleTargetGroupsFargateService for creating a Fargate service fronted by an Application Load Balancer. I need the Application Load Balancer to have 2 listeners and each listener to forward traffic to a distinct ApplicationTargetGroup.
The problem I run is after I instantiate the construct, and want to configure health checks for each individual target group. The ApplicationMultipleTargetGroupsFargateService provides a targetGroup property, however, according to the CDK documentation, this only contains a reference to the default Target Group. Ideally, this would contain a list of references to the different ApplicationTargetGroups configured within the construct. Is there any method for getting a reference to these additional target groups in the CDK from the construct for configuring health checks?
const service = new ApplicationMultipleTargetGroupsFargateService(this, 'ALBFargateService', {
cluster: this.ecsALBCluster,
taskDefinition: taskDefinition,
desiredCount,
assignPublicIp: true, // needed for outbound network connectivity in a public subnet
serviceName: 'ALBFargateService',
loadBalancers: [
{
name: 'ApplicationLoadBalancer',
listeners: [
{
name: 'TrafficListener',
port: 443,
protocol: ApplicationProtocol.HTTP
},
{
name: 'HealthCheckListener',
port: 8050,
protocol: ApplicationProtocol.HTTP
}
]
}
],
targetGroups: [
{
listener: 'TrafficListener',
containerPort: 443,
protocol: Protocol.TCP
},
{
listener: 'HealthCheckListener',
containerPort: 8050,
protocol: Protocol.TCP
}
]
});
service.targetGroup.configureHealthCheck({
port: '8050',
protocol: elbv2.Protocol.HTTP,
healthyThresholdCount: 2,
unhealthyThresholdCount: 2,
timeout: Duration.seconds(10),
interval: Duration.seconds(30),
healthyHttpCodes: '200'
});
// TODO: Configure Health Checks for second target group on port 8050
As shown above, I am configuring the service with 2 listeners and 2 target groups associated with a respective listener. Only the first target group’s reference is accessible via the targetGroup property.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:8 (5 by maintainers)
Top GitHub Comments
You can work around this by using escape hatches
x
is whatever number child your ApplicationLoadBalancer is. You can see this by doingconsole.log(service.node.children)
⚠️COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.