O'Reilly logo

Hands-On Serverless Deep Learning with TensorFlow and AWS Lambda by Rustem Feyzkhanov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

index.py

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required