Reputation: 421
Im new to AWS SQS and Im trying to create dynamic a SQS with triggers a lambda function. I could not find in AWS documentationcreateQueue
something that connects this method with my lambda. I need to create a SQS Queue (With parameters - their apiKey for example) for each user in my website, because they will be able to create emails campaigns and I want to use SQS to manage then. So my users will be able to stop their campaigns because they will be connect to their SQS and the SQS with trigger lambda function to send the emails. Is it possible to do ? How can I do this?
Upvotes: 1
Views: 2344
Reputation: 200722
You would create the SQS queue, and the Lambda function. Then you would call the Lambda createEventSourceMapping
API to register the queue as an event source for the Lambda function. For example in Python (you didn't say what language you were using):
lambda_client.create_event_source_mapping(
EventSourceArn='ARN:OF:YOUR:SQS:QUEUE',
FunctionName='YOUR_LAMBDA_FUNCTION_NAME')
or in Java:
lambdaClient.createEventSourceMapping(
new CreateEventSourceMappingRequest()
.withEventSourceArn("ARN:OF:YOUR:SQS:QUEUE")
.withFunctionName("YOUR_LAMBDA_FUNCTION_NAME")
Upvotes: 3