I am using a serverless framework, with a triggering function hello
with SQS and this is done correctly with the following config.
functions:
hello:
handler: handler.hello
events:
# Provide the ARN of your queue
- sqs: arn:aws:sqs:us-east-1:abc:sqs_input
after adding the destination to the config
destinations:
onSuccess: arn:aws:sqs:us-east-1:abc:sqs_output
onFailure: arn:aws:sqs:us-east-1:abc:sqs_output
it works fine only if I call it from AWS CLI with adding --invocation-type Event
parameter
aws lambda invoke --function-name testdestination-dev-hello --invocation-type Event response.json
but in my case, the input will be triggered by input SQS and I can not add the --invocation-type Event
option, so How can I always active the SQS destination?
Unfortunately, Lambda destinations only work with asynchronous Lambda invocations. SQS invokes Lambda synchronously, so Lambda destinations do not work/apply here.
See https://aws.amazon.com/blogs/compute/introducing-aws-lambda-destinations/
You are going to have to post a message to SQS programmatically within your Lambda in this case.