All Projects → techjacker → python-serverless-api

techjacker / python-serverless-api

Licence: MIT License
Boilerplate flask app that is portable between different serverless platforms (AWS, Azure, GCP).

Programming Languages

shell
77523 projects
python
139335 projects - #7 most used programming language
HCL
1544 projects
Makefile
30231 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to python-serverless-api

Serverless
⚡ Serverless Framework – Build web, mobile and IoT applications with serverless architectures using AWS Lambda, Azure Functions, Google CloudFunctions & more! –
Stars: ✭ 41,584 (+218763.16%)
Mutual labels:  aws-lambda, azure-functions
faaskit
A lightweight middleware framework for functions as a service
Stars: ✭ 24 (+26.32%)
Mutual labels:  aws-lambda, azure-functions
Jazz
Platform to develop and manage serverless applications at an enterprise scale!
Stars: ✭ 254 (+1236.84%)
Mutual labels:  aws-lambda, azure-functions
Guide
Serverless Guide - An open-source definitive guide to serverless architectures.
Stars: ✭ 421 (+2115.79%)
Mutual labels:  aws-lambda, azure-functions
Prisma-Enhanced-Remediation
Create custom auto-remediation solutions using serverless functions in the cloud.
Stars: ✭ 31 (+63.16%)
Mutual labels:  aws-lambda, azure-functions
lambda-cron
LambdaCron - serverless cron tool
Stars: ✭ 22 (+15.79%)
Mutual labels:  aws-lambda
jlik.me
URL Shortener project.
Stars: ✭ 31 (+63.16%)
Mutual labels:  azure-functions
DurableDungeon
A game designed to teach and learn serverless durable functions in C#
Stars: ✭ 55 (+189.47%)
Mutual labels:  azure-functions
serverless-recipes
Compendium of Serverless samples with Azure Cosmos DB
Stars: ✭ 30 (+57.89%)
Mutual labels:  azure-functions
chalice-extended-action
Automated deployment of your Chalice application via Github Actions
Stars: ✭ 18 (-5.26%)
Mutual labels:  aws-lambda
redis-examples
Sample applications implemented with serverless Redis
Stars: ✭ 44 (+131.58%)
Mutual labels:  aws-lambda
splunk handler
Python logging handler for sending logs to Splunk Enterprise
Stars: ✭ 44 (+131.58%)
Mutual labels:  aws-lambda
ruby-vips-lambda
AWS Lambda Layer for Ruby Libvips Gem
Stars: ✭ 34 (+78.95%)
Mutual labels:  aws-lambda
twitter-bot-python-aws-lambda
A simple twitter bot using Python and an AWS Lambda function
Stars: ✭ 23 (+21.05%)
Mutual labels:  aws-lambda
trackit
Trackit helps you understand and improve your use of AWS
Stars: ✭ 91 (+378.95%)
Mutual labels:  aws-lambda
backend
Easily host entire web applications on a single AWS Lambda function using Serverless Components
Stars: ✭ 16 (-15.79%)
Mutual labels:  aws-lambda
aws-lambda-firewall
Securely and conveniently support IP address whitelists for your publicly routable services.
Stars: ✭ 16 (-15.79%)
Mutual labels:  aws-lambda
polyfill-lambda
Generates polyfills based on user agent strings
Stars: ✭ 83 (+336.84%)
Mutual labels:  aws-lambda
aws-appsync-session-manager
AWS AppSync Session Manager - a sample AppSync project
Stars: ✭ 18 (-5.26%)
Mutual labels:  aws-lambda
aws-lambda-edge-basic-auth-terraform
A Terraform module that creates AWS Lambda@Edge resources to protect CloudFront distributions with Basic Authentication.
Stars: ✭ 18 (-5.26%)
Mutual labels:  aws-lambda

Python Serverless API

Boilerplate Flask app that is portable between different serverless platforms.


Platforms

Deployment and application code adaptors are being added for the following:


Platform Deployment Status
AWS Lambda AWS SAM ✔️
AWS Lambda Terraform ✔️
Azure Functions Terraform
Google Cloud Functions Terraform
Google Kubernetes Engine gcloud & kubectl
Platform Adaptor Code/Config
Local Development None 💾
AWS Lambda Python >= 3.6 Flask-Lambda-Python36 💾
AWS Lambda Python <= 3.6 Flask-Lambda 💾
Azure Functions
Google Cloud Functions

Setup

1. Create .env file and update contents

This is used to set the environment variables required for deployment and local development.

$ cp .env.example .env
$ vim .env

2. Create a virtualenv then install requirements:

$ make env
$ source env/bin/activate
$ make deps

Example Usage

1. Set Environment

Ensure you have created your virtualenv and have the necessary environment variables set (see setup instructions above).

$ source env/bin/activate
$ source .env

2. Run server

On host
$ make server-debug
In docker
$ docker-compose up

3. Manually test development server

$ http-prompt localhost:5000
GET /artists

AWS Lambda

Terraform Deployment

Ensure you have created your virtualenv and have the necessary environment variables set (see setup instructions above).

Setup

Create terraform state bucket.

$ aws s3 mb --region eu-west-2 s3://<bucket_name>

Update bucket name in /terraform/main.tf.

terraform {
  backend "s3" {
    bucket = "<bucket_name>"
    key    = "terraform.tfstate"
    region = "eu-west-2"
  }
}

Deploy

Bundle the app into a zip and deploy it using terraform.

$ ./bin/deploy

Manually Test API

$ http-prompt $(cd terraform && terraform output api_url)
GET artists

AWS Serverless Application Model (SAM) Deployment

Unlike Terraform SAM doesn't upload the zip bundle so do this using the aws-cli tool.

$ aws s3 mb s3://<mybucket>
$ aws s3 cp terraform/dist/python-serverless-api.zip s3://<mybucket>/python-serverless-api.zip

Update the S3 bucket value in the SAM config.

# template.yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: 'Boilerplate Python 3.6 Flask App.'
Resources:
  FlaskAPI:
    Type: 'AWS::Serverless::Function'
    Properties:
      CodeUri: s3://<mybucket>/flask-app.zip

Deploy the SAM template with Cloudformation.

$ aws cloudformation deploy \
		--template-file template.yaml \
		--stack-name python-serverless-stack-sam
		--capabilities CAPABILITY_IAM

Test

$ make test
$ make lint
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].