Reputation: 1762
I'm using CDK to instantiate a Queue and a Lambda Function.
Lambda function requires QueueURL in order to push messages into it.
QueueURL is not fixed, it changes when the stack is re-created.
I have two options:
If I use option 2, Lambda will have to make an API call every time it runs to get the URL.
Are these the only options? What is the recommended approach for this?
Thanks!
Upvotes: 2
Views: 1600
Reputation: 11492
Option 1 is recommended. If the value changes for any reason, the lambda will also be updated accordingly automatically. It also ensures that the lambda will be created after the queue, as it creates an implicit dependency.
Don't forget to grant your lambda access to the queue with myQueue.grantSendMessages(myLambda);
Upvotes: 0