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.72k stars 3.94k forks source link

aws-ecs-patterns: can't deploy switch from `ApplicationLoadBalancedEc2Service` to `NetworkLoadBalancedEc2Service` #24219

Closed scottlamb closed 1 year ago

scottlamb commented 1 year ago

Describe the bug

Imagine this scenario:

  1. You set up an ecs_patterns.ApplicationLoadBalancedEc2Service
  2. You realize you need an ecs_patterns.NetworkLoadBalancedEc2Service instead. In my case, this was because I needed to put it behind a CfnVPCEndpointService, which apparently only supports NLBs, not ALBs.
  3. Deploy.

Expected Behavior

cdk deploy just works.

Current Behavior

cdk deploy fails, with an error involving The following target groups cannot be associated with more than one load balancer

Reproduction Steps

Unsure what to put in here: the CDK snippet is trivial. The important part is the diff: s/ApplicationLoadBalancedEc2Service/NetworkLoadBalancedEc2Service/

Possible Solution

I found this re:Post question with a solution: the target group's name should contain the load balancer's name, so the deploy won't set up two load balancers at once pointing to the same target group (an invalid change).

My workaround was to comment out the service, deploy, uncomment with the new config, deploy. I didn't need a zero-downtime deploy so this was workable, just an extra paper-cut to figure out why the deploy failed and go through extra steps.

Additional Information/Context

No response

CDK CLI Version

2.42.1 (build 48a95f1)

Framework Version

"aws-cdk": "2.42.1"

Node.js Version

8.19.3

OS

macOS

Language

Typescript

Language Version

TypeScript (4.8.4)

Other information

No response

scottlamb commented 1 year ago

Oops, failed to see an existing issue about this (#15233), closed in favor of https://github.com/aws-cloudformation/cloudformation-coverage-roadmap/issues/780

github-actions[bot] commented 1 year ago

⚠️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.