(aws-ecspatterns): ApplicationMultipleTargetGroupsFargateService generate incorrect CF template when use multiple container in a task #24582
Labels
@aws-cdk/aws-ecs-patterns
Related to ecs-patterns library
bug
This issue is a bug.
effort/medium
Medium work item – several days of effort
p1
Describe the bug
When creating task with multiple container bind to multiple port when creating targetGroups with ApplicationMultipleTargetGroupsFargateService it incorrectly generated cloudformation template matching wrong container and port.
Consider the following code
this will generate the following cloudformation template
Note that container first should not have PortMappings of 8002
Expected Behavior
It should generate something like
or have flexibility in ApplicationMultipleTargetGroupsFargateService targetGroups to specific which port mapped to which container
Current Behavior
Seems like when using the ApplicationMultipleTargetGroupsFargateService construct, you can specify an array of ApplicationTargetProps objects to create multiple target groups. Each ApplicationTargetProps object specifies the container name and port to use for the target group.
However, the construct incorrectly uses the first containerPort value specified in the array for all target groups, instead of using the containerPort value specified for each individual target group. As a result, the CloudFormation template generated by the CDK has the wrong containerPort values assigned to each target group, which can cause issues when the service is deployed because it will complain about
Reproduction Steps
cdk synth
outputPossible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.38.0
Framework Version
No response
Node.js Version
16.15.0
OS
Mac OS 13.2.1
Language
Typescript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: