Function-as-a-Service
AWS Lambda | Azure Functions | Google Cloud Functions |
---|---|---|
JS, PY, Java, C# | JS, PY, C#, F#, PHP, Batch, PowerShell | JS |
S3, SNS, SES, DynamoDB, Kinesis, CloudWatch, Cognito, API Gateway, CodeCommit ... | Cloud Pub/Sub or Cloud Storage Object Change Notifications | Blob, EventHub, Generic WebHook, GitHub WebHook, Queue, Http, ServiceBus Queue, Service Bus Topic, Timer triggers |
aws lambda update-function-code --function-name
arn:aws:lambda:region:your-lambda-function
--zip-file fileb://dist/function.zip --publish
serverless deploy
chalice deploy
zappa deploy prod
def post_tweet(event, context):
poster = Poster()
poster.post()
{
"prod": {
"aws_region": "eu-central-1",
"s3_bucket": "realgrickitop",
"remote_env": "s3://realgrickitop/secrets.json",
"apigateway_enabled": false
}
}
zappa deploy prod
zappa invoke prod 'main.post_tweet'
app = Flask(__name__)
@app.route('/blank', methods=['GET'])
def blank():
with open(os.path.join(dir_path, 'blank_excuse.png'), 'rb') as blank:
return send_file(BytesIO(blank.read()), mimetype='image/png')
@app.route('/', methods=['GET'])
def root():
# ... writing on image magic!
return send_file(buffer, mimetype='image/png')
if __name__ == "__main__":
app.run(host='0.0.0.0')
{
"prod": {
"app_function": "app.app",
"aws_region": "eu-central-1",
"profile_name": "mislavcimpersak",
"s3_bucket": "excuse-generator"
},
"dev": {
"extends": "prod",
"debug": true
}
}