Skip to content

AndreuJove/serverless_training

Repository files navigation

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/<org_id>

    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/<org_id>/<favourite_org_id>

    Delete the item of the database with the org_id and the favourite_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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages