The index.py file is very simple. We just read incoming messages and then write them as SQS. The following shows the code for index.py:
import boto3def handler(event,context): for message in event['Records']: client = boto3.client('sqs') sqsAddress = client.get_queue_url(QueueName='WriteSQS') response = client.send_message(QueueUrl=sqsAddress['QueueUrl'], MessageBody=message['body']) return
We will see the preceding index.py and serverless.yml files in the command line:
First of all, we need to install plugin, serverless-pseudo-parameters:
npm install serverless-pseudo-parameters
The output is as follows:
Next, we will deploy Lambda ...