Open weiluo8791 opened 1 year ago
Yes I can reproduce this bug. Thank you for your report.
Having the same issue today. I think we need to add a unique container name as a property of ApplicationTargetProps to identify which TargetGroup the container maps to. But it requires breaking changes. https://github.com/aws/aws-cdk/blob/2bb49bf58361fbf382a03644021b123a69d5badf/packages/aws-cdk-lib/aws-ecs-patterns/lib/base/application-multiple-target-groups-service-base.ts#L213
I'm running into the same issue currently. See this issue describing the same bug as well: https://github.com/aws/aws-cdk/issues/24013. Is there any progress?
I am also having this issue. Anyone found a work-around for this? Seems to me having multiple containers using different ports would be a pretty common use-case. Not sure why there is not more ppl flagged this issue...
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