Serverless Framework Python Flask API service backed by DynamoDB on AWS
Python Flask API service, backed by DynamoDB, running on AWS Lambda using the traditional Serverless Framework.
Requested endpoints :
-
GET/favourite_company/
List all items with the
org_id
provided.Example:
curl -H "Content-Type: application/json" -u username:apikey -X GET https://woo6lrrukc.execute-api.eu-west-1.amazonaws.com/api/favourite_company/amazon
-
POST/favourite_company/create
Method to create an item in the database.
Example:
curl -H "Content-Type: application/json" -u username:apikey -X POST https://woo6lrrukc.execute-api.eu-west-1.amazonaws.com/api/favourite_company/create -d '{"org_id": "amazon", "favourite_org_id": "facebook"}'
Extra endpoints:
-
GET/favourite_companies
List all items of the table.
Example:
curl -H "Content-Type: application/json" -u username:apikey -X GET https://woo6lrrukc.execute-api.eu-west-1.amazonaws.com/api/favourite_companies
-
DELETE/favourite_company/delete/
/ Delete the item of the database with the
org_id
and thefavourite_org_id
provided.Example:
curl -H "Content-Type: application/json" -u username:apikey -X DELETE https://woo6lrrukc.execute-api.eu-west-1.amazonaws.com/api/favourite_company/delete/amazon/facebook
DynamoDB design:
- partition key -> org_id
- sort key -> favourite_org_id
Development
sls wsgi serve
Deploy:
sls deploy
Configuration AWS credentials for serverless framework:
serverless config credentials --provider aws --key {key} --secret {secret}
Check the credentials:
cat ~/.aws/credentials
Serverless plugins used:
To install them:
serverless plugin install -n serverless-python-requirements
serverless plugin install -n serverless-wsgi
serverless plugin install -n serverless-basic-authentication