aws-autoscaling-hooktargets: "Topic" already exists (can only use FunctionHook once per stack) #29010
Labels
@aws-cdk/aws-autoscaling-hooktargets
bug
This issue is a bug.
effort/medium
Medium work item – several days of effort
p2
Describe the bug
If you try to use
FunctionHook
more than once in a stack, or you use it once but try to attach it to more than one lifecycle event, you get this error:Expected Behavior
I expected all lifecycle events to be attached to the Lambda function hook without any errors.
Current Behavior
The stack fails to synth with an error saying the name
Topic
is used more than once.Reproduction Steps
The problem still exists if you create only one
FunctionHook
and pass it to bothaddLifecycleHook()
calls.Possible Solution
The problem appears to be in lambda-hook.ts:28 where it creates an SNS topic with the hard-coded name
Topic
. So you can only create a single one or the name conflicts.I guess using something like
cdk.Names.nodeUniqueId()
is needed here?Additional Information/Context
I'm using a loop to create four hooks - launch and terminate, for AMD and ARM architectures. So even if the events were somehow combined into an array, I'd still have to call
addLifecycleHook()
once for each architecture's auto scaling group.CDK CLI Version
2.126.0 (build fb74c41)
Framework Version
No response
Node.js Version
v21.6.0
OS
Arch Linux
Language
TypeScript
Language Version
TypeScript (5.3.3)
Other information
No response
The text was updated successfully, but these errors were encountered: