Skip to content

(ecs-patterns): unnecessary breaking target group port change introduced after upgrading cdk #19411

@aaaeeeo

Description

@aaaeeeo

What is the problem?

We recently upgraded the cdk version from 1.13x to 1.147 and noticed a breaking change prevent us from deploying.

The change is introduced by this commit: #18157 from #18073

In ecs-patterns, target group was generated with hard-coded port 80, and now changed to containerPort that in our case is 8080.
This triggered a replacement of the target group, and in production, we certainly cannot replace the target group or LB.

The service is currently working fine, and my understanding is when used with ECS and dynamic port mapping, the port in target group is meaningless as ECS host ports are dynamically opened:
https://stackoverflow.com/questions/42715647/whats-the-target-group-port-for-when-using-application-load-balancer-ec2-con
https://aws.amazon.com/premiumsupport/knowledge-center/dynamic-port-mapping-ecs/
Looks like even ECS is hard coding target group port to 80 when create service in console.

So what is the exact issue of #18073, what is it trying to fix? #18157 says "Fix Network Load Balancer Port assignments" but actaully changed the target group port instead? Looks like the change is meaningless and introduced breaking replacement to people who are already using the construct.

Currently, we have to patch the L1 target group to get this around. Could we revert #18157?

Reproduction Steps

Upgrade the cdk version from 1.130 to 1.147 and compare the generated TargetGroup from NetworkLoadBalancedEc2Service without any code change

What did you expect to happen?

Generated template should remain unchanged without any code change:

      "Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
      "Properties": {
        "HealthCheckPort": "traffic-port",
        "HealthCheckProtocol": "TCP",
        "HealthyThresholdCount": 10,
        "Port": 80,
        "Protocol": "TCP",

What actually happened?

Target group port changed to container port triggered a replacement of the target group for our service that is working fine.

      "Type": "AWS::ElasticLoadBalancingV2::TargetGroup",
      "Properties": {
        "HealthCheckPort": "traffic-port",
        "HealthCheckProtocol": "TCP",
        "HealthyThresholdCount": 10,
        "Port": 8080,
        "Protocol": "TCP",

CDK CLI Version

1.147

Framework Version

No response

Node.js Version

14

OS

Mac

Language

Typescript

Language Version

No response

Other information

No response

Metadata

Metadata

Labels

@aws-cdk/aws-ecs-patternsRelated to ecs-patterns librarybugThis issue is a bug.effort/smallSmall work item – less than a day of effortp1

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions