How to handle the situation when you have a functi...
# help
d
How to handle the situation when you have a function that is an trigger event of a bucket and needs the name of the bucket as env? Is there a way to do this without a cyclic reference error? Part of the same stack, it works, but in a different stack it won’t work.
f
but in a different stack it won’t work
You mean the bucket and the function are in different stacks? Added using
bucket.addNotifications()
?
d
StackA has a function StackB has a bucket with the function as notification How to add the name of the bucket to function in StackA ? Currently, I keep both in StackA and create the bucket, then the function then use addNotifications. Works but it is not ideal
f
Ah yeah that is cyclic reference
You could store the bucket name in an SSM param in StackB. And in StackA, have the function’s environment load from the param.
This way StackA won’t depend on StackB.
The downside of this is that function’s environment will be unavailable after the very first time u deploy, b/c the SSM param does not exist yet.
d
I’ll keep it that way for this one, but thank you!