serverless invoke sqs 1

serverless invoke sqs

functions:
  hello:
    handler: handler.hello
    events:
    	# Provide the ARN of your queue
      - sqs: arn:aws:sqs:us-east-1:123456789012:queue1

Here is what the above code is Doing:
1. The hello function is the function that will be executed when a message is received on the queue.
2. The handler.hello is the name of the file and the function that will be executed.
3. The arn:aws:sqs:us-east-1:123456789012:queue1 is the ARN of the queue that you created in the previous step.

Now, let’s create the handler.py file.

handler.py

import json

def hello(event, context):
print(“Received event {}”.format(json.dumps(event)))
return “Hello World”

Similar Posts