The purpose of the lambda function is aggregate aspect scores of a hotel whenever there is new/updated/deleted aspect score of a hotel
- It triggers on S3 event
- Aggregate scores per aspect for a hotel
- Inserts/updates/deletes the scores in dynamodb
The following resources will be created on deploying the function
- S3 event notification
- Lambda Role
- Lambda Function
- Dynamodb ( with AutoScaling )
- Dynamodb Scaling Role
Note: This project includes AWS Lambda layer as part of the lambda function . Ideally , it is not a good practice to have it tightly coupled with the lambda function.
$ cd layers/pandas_boto3
$ ./get_layer_packages.sh
This will download the packages required to be part of lambda layer . Please make sure that Docker is installed in your system to run this shell script
Please make sure that npm is installed.
$ npm install -g serverless
Before deploying the lambda function using serverless framework , make sure that serverless.yml
file is updated with respective AWS account number and S3 bucket names ( or any other infra related )
$ sls deploy -v --stage staging
This will deploy with lambda function onto AWS and will also create CF for resources mentioned in resources part of serverless.yml file.
It is important to note that serverless has no provision to omit resources during the further deployments ( lets say , we changed some logic in lambda function and deploying the lambda changes ) .In that case, it is going to throw us an error that the resources already exist . So , it would be better to deploy only lambda functions in such cases , using the following command ,
$ serverless deploy function --function {function-name} --update-config