lapozzo / aws-sam-example

Simple AWS Serverless Application Model example

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Introduction

Simple AWS Serverless Application Model example with Layer and a SQS destination

Requirements

  • aws-cli/2.0.56
  • Python/3.7.3
  • aws sam cli 1.15.0

calculation-layer

AWS Lambda Layer with a simple sum function in the calculation module

sum-app

AWS Lambda Function that references the calculation-layer and SQS destination that receives a message in case of failures (event with a simulate_error property)

Start Environment

1 Deploy the layer:

cd calculation-layer
sam deploy --guided

2 Deploy the lambda with destination configuration and SQS:

cd sum-app
sam deploy --guided

3 Test

3.1. Unit Test (pytest)

cd sum-app
make test

3.2. Local Test with SAM

cd sum-app
make invoke

3.2. AWS Test with AWS Cli

aws lambda invoke --cli-binary-format raw-in-base64-out --function-name sum-app-SumAppFunction-xxxxxxxxxxxxx --invocation-type Event --payload '{"n1":1,"n2":3}' response.json

About

Simple AWS Serverless Application Model example


Languages

Language:Python 92.9%Language:Makefile 7.1%