SlideShare a Scribd company logo
Build a RESTfull API with the
Serverless framework
Plone Conference WebDay 2018 Nov 7th 1
Introduction
1. Introduce myself
2. perpose of this presentation
Plone Conference WebDay 2018 Nov 7th 2
Introduce myself
• Masato Nakamura
• twitter: masahito
• github: masahitojp
• work at Nulab inc. Typetalk team
• use Scala and JavaScript and Python
• Python ❤ and
☕
❤
Plone Conference WebDay 2018 Nov 7th 3
Perpose of this presentation
• You can understand buid a REST API with the
Serverless Framework
• I will talk especially for the AWS services
Plone Conference WebDay 2018 Nov 7th 4
Not covering today
• Technical Details
• AWS knowledge(IAM etc)
Plone Conference WebDay 2018 Nov 7th 5
Today I will talk about following
things
• How to create an RESTful API with the Amazon API
Gateway
• How to use the Serverless Framework
• How to make deployment easier
Plone Conference WebDay 2018 Nov 7th 6
How to create RESTful API
Plone Conference WebDay 2018 Nov 7th 7
How to create RESTful API
1. Where to use RESTful API?
2. What is the Amazon API Gateway
3. What is AWS Lambda
Plone Conference WebDay 2018 Nov 7th 8
Where to use RESTful API?
• Upload File to the Amazon S3
• Send Message to a service
Plone Conference WebDay 2018 Nov 7th 9
Target
• You use CMS
• You want to make API more easily
• I want you to introduce the Amazon API Gateway
Plone Conference WebDay 2018 Nov 7th 10
What is the Amazon API Gateway
API creation, application communication gateway.
Create an endpoint.
It is created from the management console of AWS.
We do not write actual code.
It also has an authentication function, it separates
the environment, deploys and scales.
Plone Conference WebDay 2018 Nov 7th 11
What is the AWS Lambda
A service that executes code.
Create a function called Lambda function and write
code.
You can write it directly in the AWS management
console, but basically upload the code.
You can write even code, AWS Lamvs provide
manage servers, scaling, logging.
Plone Conference WebDay 2018 Nov 7th 12
What you can do with combining
We can create RESTful API ❤
Plone Conference WebDay 2018 Nov 7th 13
Flow of API creation
1. create the Amazon API Gateway
2. create AWS Lambda funtion
3. connect AWS GateWay & AWS Lambda funtion
Plone Conference WebDay 2018 Nov 7th 14
1). create the Amazon API Gateway
Plone Conference WebDay 2018 Nov 7th 15
2). create AWS Lambda funtion
Plone Conference WebDay 2018 Nov 7th 16
3). connect the Amazon API Gateway & AWS Lambda
funtion
Plone Conference WebDay 2018 Nov 7th 17
Next
I want to talk about the AWS Lambda
Plone Conference WebDay 2018 Nov 7th 18
How to use the Serverless
framework
Plone Conference WebDay 2018 Nov 7th 19
How to use the Serverless
framework
1. How to deploy AWS Lambda function.
2. Introduce the Serverless Framework
Plone Conference WebDay 2018 Nov 7th 20
Target
• Python newbie
• use or used the AWS Lambda
Plone Conference WebDay 2018 Nov 7th 21
Goal
•
!
Easy to use AWS Lambda for Python
• When you write Code, You can update easily
Plone Conference WebDay 2018 Nov 7th 22
can register at AWS console
• Write Code
• Run Test
Plone Conference WebDay 2018 Nov 7th 23
When used only once This is enough
Plone Conference WebDay 2018 Nov 7th 24
• example: POST JSON -> send message to Chat
Plone Conference WebDay 2018 Nov 7th 25
• example: POST JSON -> send message to Chat
•
!
We want to use a 3rd Party lib
• requests
• add requirements.txt
requests
• run
$ pip install -r requirements.txt -t vendor/
$ edit python-file
$ zip /path/to/service-dir
$ aws lambda ~~
Plone Conference WebDay 2018 Nov 7th 26
  It's troublesome to do with the
AWS console
!
use 3rd party libraries
!
Especially when using C-API
!
Code version control (git etc)
Plone Conference WebDay 2018 Nov 7th 27
Deploy to the AWSLambda
• Deployment using ZipFile is possible
!
Code version control (git etc)
Plone Conference WebDay 2018 Nov 7th 28
• Deployment using ZipFile is possible
$ aws lambda create-function 
--function-name AccessMemCache 
--region us-east-1 
--zip-file fileb://path-to/app.zip 
--role execution-role-arn 
--handler app.handler 
--runtime python3.6 
--timeout 30 
--vpc-config SubnetIds=comma-separated-vpc-subnet-ids,SecurityGroupIds=default-security-group-id 
--memory-size 1024
https://docs.aws.amazon.com/ja_jp/lambda/latest/
dg/vpc-ec-upload-deployment-pkg.html
Plone Conference WebDay 2018 Nov 7th 29
I want to make it easier
!
Create a zipfile each time you change -> deploy
!
Run test locally
• What we need now
$ edit python-file
$ (pip install ~~)
$ zip /path/to/service-dir
$ aws lambda ~~
Plone Conference WebDay 2018 Nov 7th 30
Introduce the Serverless Framework
Plone Conference WebDay 2018 Nov 7th 31
What is the Serverless Framework?
• http://www.serverless.com
Serverless Framework – Build web, mobile and IoT
applications with serverless architectures using AWS
Lambda, Azure Functions, Google CloudFunctions &
more!
• AWS Lambda, Azure Functions, Google
CloudFunctions を使ってサーバレスアーキテク
チャで web, Mobile IoT アプリケーションを作ろう
Plone Conference WebDay 2018 Nov 7th 32
Description of the Serverless Framework
• pros
!!
Code version control(git / svn / Hg)
!
zip -> deploy is possible by executing Only 1
command
!
manage CloudWatch/ AWS IAM
Plone Conference WebDay 2018 Nov 7th 33
Use the Serverless Framework
How to create environments
$ npm instal -g serverless
$ sls -v
1.32.0
Plone Conference WebDay 2018 Nov 7th 34
create AWS Lambda with the Serverless Framework
$ sls create -t aws-python3 -p py3-hello
Serverless: Generating boilerplate...
Serverless: Generating boilerplate in "/Users/masahito-nulab/src/jobs/typetalk-serverless-internal/py3-hello"
_______ __
| _ .-----.----.--.--.-----.----| .-----.-----.-----.
| |___| -__| _| | | -__| _| | -__|__ --|__ --|
|____ |_____|__| ___/|_____|__| |__|_____|_____|_____|
| | | The Serverless Application Framework
| | serverless.com, v1.27.3
-------'
Serverless: Successfully generated boilerplate for template: "aws-python3"
$ tree py3-hello/
py3-hello/
!"" handler.py
#"" serverless.yml
Plone Conference WebDay 2018 Nov 7th 35
• handler.py
import json
def hello(event, context):
body = {
"message": "Go Serverless v1.0! Your function executed successfully!",
"input": event
}
response = {
"statusCode": 200,
"body": json.dumps(body)
}
return response
• serverless.yml
service: py3-hello
provider:
name: aws
runtime: python3.6
functions:
hello:
handler: handler.hello
Plone Conference WebDay 2018 Nov 7th 36
Run Test locally
$ cd py3-hello
$ sls invoke local -f hello
{
"statusCode": 200,
"body": "{"message": "Go Serverless v1.0! Your function executed successfully!", "input": {}}"
}
Plone Conference WebDay 2018 Nov 7th 37
Deploy to AWS Lambda
!
Deployment will be simplified after setting the
IAM/Role
$ sls deploy
Plone Conference WebDay 2018 Nov 7th 38
How to make deployment
easier
Plone Conference WebDay 2018 Nov 7th 39
How to make deployment easier
1. reduce troublesome for library installation
2. Non-Pure Python module
Plone Conference WebDay 2018 Nov 7th 40
Goal
• Easy to use AWS Lambda for Python
•
!
When you write Code, You can update easily
Plone Conference WebDay 2018 Nov 7th 41
Plone Conference WebDay 2018 Nov 7th 42
reduce troublesome for library installation
!
required 3rd-party library installation
#
!
I often forget this
$ pip install -r requirement.txt -t vendor/
$ sls deploy
Plone Conference WebDay 2018 Nov 7th 43
reduce troublesome for library installation
Use serverless-framework plugin
• UnitedIncome/serverless-python-requirements
• serverless >= v1.12
Plone Conference WebDay 2018 Nov 7th 44
How to install this plugin
$ sls plugin install -n serverless-python-requirements
service: py3-hello
provider:
name: aws
runtime: python3.6
cfLogs: true
plugins:
- serverless-python-requirements
functions:
hello:
handler: handler.hello
Plone Conference WebDay 2018 Nov 7th 45
Deploy
($ sls requirements install)
$ sls deploy
Plone Conference WebDay 2018 Nov 7th 46
It is now possible to execute with a only 1 command !
Plone Conference WebDay 2018 Nov 7th 47
Non-Pure Python module
• Developers often use Windows / OSX for
development environment
• Python has lots of libraries written with C-API
• numpy , TensorFlow , Image Libraries: pillow etc
• Creating a zipfile locally does not work at AWS
Lambda
!
• The environment of AWS Lambda is Linux
Plone Conference WebDay 2018 Nov 7th 48
dockerize pip
Cross-compile in docker environment
• It uses docker image ”lambci / docker-lambda"
service: py3-hello
provider:
name: aws
runtime: python3.6
cfLogs: true
plugins:
- serverless-python-requirements
custom:
pythonRequirements:
dockerizePip: true
functions:
hello:
handler: handler.hello
Plone Conference WebDay 2018 Nov 7th 49
Today I talked about following things
• How to create an RESTful API with the Amazon API
Gateway
• How to use the Serverless Framework
• How to make deployment easier
Plone Conference WebDay 2018 Nov 7th 50
I hope you can write and
deploy RESTfull API ❤
Plone Conference WebDay 2018 Nov 7th 51
Thank you
@masahito
Plone Conference WebDay 2018 Nov 7th 52
Question?
Plone Conference WebDay 2018 Nov 7th 53

More Related Content

What's hot

What you see is what you get for AWS infrastructure
What you see is what you get for AWS infrastructureWhat you see is what you get for AWS infrastructure
What you see is what you get for AWS infrastructure
Anton Babenko
 
PyConIT 2018 Writing and deploying serverless python applications
PyConIT 2018 Writing and deploying serverless python applicationsPyConIT 2018 Writing and deploying serverless python applications
PyConIT 2018 Writing and deploying serverless python applications
Cesar Cardenas Desales
 
Meetup Melbourne August 2017 - Agile Integration with Apache Camel microservi...
Meetup Melbourne August 2017 - Agile Integration with Apache Camel microservi...Meetup Melbourne August 2017 - Agile Integration with Apache Camel microservi...
Meetup Melbourne August 2017 - Agile Integration with Apache Camel microservi...
Claus Ibsen
 
Building a Serverless Pipeline
Building a Serverless PipelineBuilding a Serverless Pipeline
Building a Serverless Pipeline
Julien SIMON
 
2020.02.15 DelEx - CI/CD in AWS Cloud
2020.02.15 DelEx - CI/CD in AWS Cloud2020.02.15 DelEx - CI/CD in AWS Cloud
2020.02.15 DelEx - CI/CD in AWS Cloud
Peter Salnikov
 
OpenFaaS - zero serverless in 60 seconds anywhere with case-studies
OpenFaaS - zero serverless in 60 seconds anywhere with case-studiesOpenFaaS - zero serverless in 60 seconds anywhere with case-studies
OpenFaaS - zero serverless in 60 seconds anywhere with case-studies
Alex Ellis
 
CI/CD with AWS Code Services
CI/CD with AWS Code ServicesCI/CD with AWS Code Services
CI/CD with AWS Code Services
Pulkit Gupta
 
Building Cloud Virtual Topologies with Ravello and Ansible
Building Cloud Virtual Topologies with Ravello and AnsibleBuilding Cloud Virtual Topologies with Ravello and Ansible
Building Cloud Virtual Topologies with Ravello and Ansible
Damien Garros
 
Best Practices for Middleware and Integration Architecture Modernization with...
Best Practices for Middleware and Integration Architecture Modernization with...Best Practices for Middleware and Integration Architecture Modernization with...
Best Practices for Middleware and Integration Architecture Modernization with...
Claus Ibsen
 
Flink sql for continuous sql etl apps & Apache NiFi devops
Flink sql for continuous sql etl apps & Apache NiFi devopsFlink sql for continuous sql etl apps & Apache NiFi devops
Flink sql for continuous sql etl apps & Apache NiFi devops
Timothy Spann
 
API Design in the Modern Era - Architecture Next 2020
API Design in the Modern Era - Architecture Next 2020API Design in the Modern Era - Architecture Next 2020
API Design in the Modern Era - Architecture Next 2020
Eran Stiller
 
Origins of Serverless
Origins of ServerlessOrigins of Serverless
Origins of Serverless
Andrii Soldatenko
 
Cloud native - CI/CD
Cloud native - CI/CDCloud native - CI/CD
Cloud native - CI/CD
Elad Hirsch
 
DevOps Fest 2019. Gianluca Arbezzano. DevOps never sleeps. What we learned fr...
DevOps Fest 2019. Gianluca Arbezzano. DevOps never sleeps. What we learned fr...DevOps Fest 2019. Gianluca Arbezzano. DevOps never sleeps. What we learned fr...
DevOps Fest 2019. Gianluca Arbezzano. DevOps never sleeps. What we learned fr...
DevOps_Fest
 
Patterns and practices for real-world event-driven microservices
Patterns and practices for real-world event-driven microservicesPatterns and practices for real-world event-driven microservices
Patterns and practices for real-world event-driven microservices
Rachel Reese
 
ApacheCon NA - Apache Camel K: a cloud-native integration platform
ApacheCon NA - Apache Camel K: a cloud-native integration platformApacheCon NA - Apache Camel K: a cloud-native integration platform
ApacheCon NA - Apache Camel K: a cloud-native integration platform
Nicola Ferraro
 
JavaDay Lviv: Serverless Archtiectures
JavaDay Lviv: Serverless ArchtiecturesJavaDay Lviv: Serverless Archtiectures
JavaDay Lviv: Serverless Archtiectures
Antons Kranga
 
Supercharging CI/CD with GitLab and Rancher - June 2017 Online Meetup
Supercharging CI/CD with GitLab and Rancher - June 2017 Online MeetupSupercharging CI/CD with GitLab and Rancher - June 2017 Online Meetup
Supercharging CI/CD with GitLab and Rancher - June 2017 Online Meetup
Shannon Williams
 
It's a Breeze to develop Apache Airflow (London Apache Airflow meetup)
It's a Breeze to develop Apache Airflow (London Apache Airflow meetup)It's a Breeze to develop Apache Airflow (London Apache Airflow meetup)
It's a Breeze to develop Apache Airflow (London Apache Airflow meetup)
Jarek Potiuk
 
Infrastructure as code
Infrastructure as codeInfrastructure as code
Infrastructure as code
daisuke awaji
 

What's hot (20)

What you see is what you get for AWS infrastructure
What you see is what you get for AWS infrastructureWhat you see is what you get for AWS infrastructure
What you see is what you get for AWS infrastructure
 
PyConIT 2018 Writing and deploying serverless python applications
PyConIT 2018 Writing and deploying serverless python applicationsPyConIT 2018 Writing and deploying serverless python applications
PyConIT 2018 Writing and deploying serverless python applications
 
Meetup Melbourne August 2017 - Agile Integration with Apache Camel microservi...
Meetup Melbourne August 2017 - Agile Integration with Apache Camel microservi...Meetup Melbourne August 2017 - Agile Integration with Apache Camel microservi...
Meetup Melbourne August 2017 - Agile Integration with Apache Camel microservi...
 
Building a Serverless Pipeline
Building a Serverless PipelineBuilding a Serverless Pipeline
Building a Serverless Pipeline
 
2020.02.15 DelEx - CI/CD in AWS Cloud
2020.02.15 DelEx - CI/CD in AWS Cloud2020.02.15 DelEx - CI/CD in AWS Cloud
2020.02.15 DelEx - CI/CD in AWS Cloud
 
OpenFaaS - zero serverless in 60 seconds anywhere with case-studies
OpenFaaS - zero serverless in 60 seconds anywhere with case-studiesOpenFaaS - zero serverless in 60 seconds anywhere with case-studies
OpenFaaS - zero serverless in 60 seconds anywhere with case-studies
 
CI/CD with AWS Code Services
CI/CD with AWS Code ServicesCI/CD with AWS Code Services
CI/CD with AWS Code Services
 
Building Cloud Virtual Topologies with Ravello and Ansible
Building Cloud Virtual Topologies with Ravello and AnsibleBuilding Cloud Virtual Topologies with Ravello and Ansible
Building Cloud Virtual Topologies with Ravello and Ansible
 
Best Practices for Middleware and Integration Architecture Modernization with...
Best Practices for Middleware and Integration Architecture Modernization with...Best Practices for Middleware and Integration Architecture Modernization with...
Best Practices for Middleware and Integration Architecture Modernization with...
 
Flink sql for continuous sql etl apps & Apache NiFi devops
Flink sql for continuous sql etl apps & Apache NiFi devopsFlink sql for continuous sql etl apps & Apache NiFi devops
Flink sql for continuous sql etl apps & Apache NiFi devops
 
API Design in the Modern Era - Architecture Next 2020
API Design in the Modern Era - Architecture Next 2020API Design in the Modern Era - Architecture Next 2020
API Design in the Modern Era - Architecture Next 2020
 
Origins of Serverless
Origins of ServerlessOrigins of Serverless
Origins of Serverless
 
Cloud native - CI/CD
Cloud native - CI/CDCloud native - CI/CD
Cloud native - CI/CD
 
DevOps Fest 2019. Gianluca Arbezzano. DevOps never sleeps. What we learned fr...
DevOps Fest 2019. Gianluca Arbezzano. DevOps never sleeps. What we learned fr...DevOps Fest 2019. Gianluca Arbezzano. DevOps never sleeps. What we learned fr...
DevOps Fest 2019. Gianluca Arbezzano. DevOps never sleeps. What we learned fr...
 
Patterns and practices for real-world event-driven microservices
Patterns and practices for real-world event-driven microservicesPatterns and practices for real-world event-driven microservices
Patterns and practices for real-world event-driven microservices
 
ApacheCon NA - Apache Camel K: a cloud-native integration platform
ApacheCon NA - Apache Camel K: a cloud-native integration platformApacheCon NA - Apache Camel K: a cloud-native integration platform
ApacheCon NA - Apache Camel K: a cloud-native integration platform
 
JavaDay Lviv: Serverless Archtiectures
JavaDay Lviv: Serverless ArchtiecturesJavaDay Lviv: Serverless Archtiectures
JavaDay Lviv: Serverless Archtiectures
 
Supercharging CI/CD with GitLab and Rancher - June 2017 Online Meetup
Supercharging CI/CD with GitLab and Rancher - June 2017 Online MeetupSupercharging CI/CD with GitLab and Rancher - June 2017 Online Meetup
Supercharging CI/CD with GitLab and Rancher - June 2017 Online Meetup
 
It's a Breeze to develop Apache Airflow (London Apache Airflow meetup)
It's a Breeze to develop Apache Airflow (London Apache Airflow meetup)It's a Breeze to develop Apache Airflow (London Apache Airflow meetup)
It's a Breeze to develop Apache Airflow (London Apache Airflow meetup)
 
Infrastructure as code
Infrastructure as codeInfrastructure as code
Infrastructure as code
 

Similar to Build a RESTful API with the Serverless Framework

Serverless in Production, an experience report (AWS UG South Wales)
Serverless in Production, an experience report (AWS UG South Wales)Serverless in Production, an experience report (AWS UG South Wales)
Serverless in Production, an experience report (AWS UG South Wales)
Yan Cui
 
The path to a serverless-native era with Kubernetes
The path to a serverless-native era with KubernetesThe path to a serverless-native era with Kubernetes
The path to a serverless-native era with Kubernetes
sparkfabrik
 
Serverless in production, an experience report (FullStack 2018)
Serverless in production, an experience report (FullStack 2018)Serverless in production, an experience report (FullStack 2018)
Serverless in production, an experience report (FullStack 2018)
Yan Cui
 
Continuous Integration and Deployment Best Practices on AWS (ARC307) | AWS re...
Continuous Integration and Deployment Best Practices on AWS (ARC307) | AWS re...Continuous Integration and Deployment Best Practices on AWS (ARC307) | AWS re...
Continuous Integration and Deployment Best Practices on AWS (ARC307) | AWS re...
Amazon Web Services
 
Continuous Deployment @ AWS Re:Invent
Continuous Deployment @ AWS Re:InventContinuous Deployment @ AWS Re:Invent
Continuous Deployment @ AWS Re:Invent
John Schneider
 
API workshop by AWS and 3scale
API workshop by AWS and 3scaleAPI workshop by AWS and 3scale
API workshop by AWS and 3scale
3scale
 
用Serverless技術快速開發line聊天機器人
用Serverless技術快速開發line聊天機器人用Serverless技術快速開發line聊天機器人
用Serverless技術快速開發line聊天機器人
Kevin Luo
 
Building CI/CD Pipelines for Serverless Applications - SRV302 - re:Invent 2017
Building CI/CD Pipelines for Serverless Applications - SRV302 - re:Invent 2017Building CI/CD Pipelines for Serverless Applications - SRV302 - re:Invent 2017
Building CI/CD Pipelines for Serverless Applications - SRV302 - re:Invent 2017
Amazon Web Services
 
Building a DevOps Pipeline on AWS (DEV326) - AWS re:Invent 2018
Building a DevOps Pipeline on AWS (DEV326) - AWS re:Invent 2018Building a DevOps Pipeline on AWS (DEV326) - AWS re:Invent 2018
Building a DevOps Pipeline on AWS (DEV326) - AWS re:Invent 2018
Amazon Web Services
 
When to use Serverless? When to use Kubernetes?
When to use Serverless? When to use Kubernetes?When to use Serverless? When to use Kubernetes?
When to use Serverless? When to use Kubernetes?
Niklas Heidloff
 
PyConIE 2017 Writing and deploying serverless python applications
PyConIE 2017 Writing and deploying serverless python applicationsPyConIE 2017 Writing and deploying serverless python applications
PyConIE 2017 Writing and deploying serverless python applications
Cesar Cardenas Desales
 
Infrastructure Is Code with the AWS Cloud Development Kit (DEV372) - AWS re:I...
Infrastructure Is Code with the AWS Cloud Development Kit (DEV372) - AWS re:I...Infrastructure Is Code with the AWS Cloud Development Kit (DEV372) - AWS re:I...
Infrastructure Is Code with the AWS Cloud Development Kit (DEV372) - AWS re:I...
Amazon Web Services
 
AWS re:Invent 2020 Serverless Recap
AWS re:Invent 2020 Serverless RecapAWS re:Invent 2020 Serverless Recap
AWS re:Invent 2020 Serverless Recap
Daniel Zivkovic
 
Serverless in production, an experience report
Serverless in production, an experience reportServerless in production, an experience report
Serverless in production, an experience report
Yan Cui
 
Developer-Friendly CI / CD for Kubernetes
Developer-Friendly CI / CD for KubernetesDeveloper-Friendly CI / CD for Kubernetes
Developer-Friendly CI / CD for Kubernetes
DevOps Indonesia
 
Serverless Development Deep Dive
Serverless Development Deep DiveServerless Development Deep Dive
Serverless Development Deep Dive
Amazon Web Services
 
Building Serverless applications with Python
Building Serverless applications with PythonBuilding Serverless applications with Python
Building Serverless applications with Python
Andrii Soldatenko
 
Writing and deploying serverless python applications
Writing and deploying serverless python applicationsWriting and deploying serverless python applications
Writing and deploying serverless python applications
Cesar Cardenas Desales
 
Building serverless applications (April 2018)
Building serverless applications (April 2018)Building serverless applications (April 2018)
Building serverless applications (April 2018)
Julien SIMON
 
Kubernetes - State of the Union (Q1-2016)
Kubernetes - State of the Union (Q1-2016)Kubernetes - State of the Union (Q1-2016)
Kubernetes - State of the Union (Q1-2016)
DoiT International
 

Similar to Build a RESTful API with the Serverless Framework (20)

Serverless in Production, an experience report (AWS UG South Wales)
Serverless in Production, an experience report (AWS UG South Wales)Serverless in Production, an experience report (AWS UG South Wales)
Serverless in Production, an experience report (AWS UG South Wales)
 
The path to a serverless-native era with Kubernetes
The path to a serverless-native era with KubernetesThe path to a serverless-native era with Kubernetes
The path to a serverless-native era with Kubernetes
 
Serverless in production, an experience report (FullStack 2018)
Serverless in production, an experience report (FullStack 2018)Serverless in production, an experience report (FullStack 2018)
Serverless in production, an experience report (FullStack 2018)
 
Continuous Integration and Deployment Best Practices on AWS (ARC307) | AWS re...
Continuous Integration and Deployment Best Practices on AWS (ARC307) | AWS re...Continuous Integration and Deployment Best Practices on AWS (ARC307) | AWS re...
Continuous Integration and Deployment Best Practices on AWS (ARC307) | AWS re...
 
Continuous Deployment @ AWS Re:Invent
Continuous Deployment @ AWS Re:InventContinuous Deployment @ AWS Re:Invent
Continuous Deployment @ AWS Re:Invent
 
API workshop by AWS and 3scale
API workshop by AWS and 3scaleAPI workshop by AWS and 3scale
API workshop by AWS and 3scale
 
用Serverless技術快速開發line聊天機器人
用Serverless技術快速開發line聊天機器人用Serverless技術快速開發line聊天機器人
用Serverless技術快速開發line聊天機器人
 
Building CI/CD Pipelines for Serverless Applications - SRV302 - re:Invent 2017
Building CI/CD Pipelines for Serverless Applications - SRV302 - re:Invent 2017Building CI/CD Pipelines for Serverless Applications - SRV302 - re:Invent 2017
Building CI/CD Pipelines for Serverless Applications - SRV302 - re:Invent 2017
 
Building a DevOps Pipeline on AWS (DEV326) - AWS re:Invent 2018
Building a DevOps Pipeline on AWS (DEV326) - AWS re:Invent 2018Building a DevOps Pipeline on AWS (DEV326) - AWS re:Invent 2018
Building a DevOps Pipeline on AWS (DEV326) - AWS re:Invent 2018
 
When to use Serverless? When to use Kubernetes?
When to use Serverless? When to use Kubernetes?When to use Serverless? When to use Kubernetes?
When to use Serverless? When to use Kubernetes?
 
PyConIE 2017 Writing and deploying serverless python applications
PyConIE 2017 Writing and deploying serverless python applicationsPyConIE 2017 Writing and deploying serverless python applications
PyConIE 2017 Writing and deploying serverless python applications
 
Infrastructure Is Code with the AWS Cloud Development Kit (DEV372) - AWS re:I...
Infrastructure Is Code with the AWS Cloud Development Kit (DEV372) - AWS re:I...Infrastructure Is Code with the AWS Cloud Development Kit (DEV372) - AWS re:I...
Infrastructure Is Code with the AWS Cloud Development Kit (DEV372) - AWS re:I...
 
AWS re:Invent 2020 Serverless Recap
AWS re:Invent 2020 Serverless RecapAWS re:Invent 2020 Serverless Recap
AWS re:Invent 2020 Serverless Recap
 
Serverless in production, an experience report
Serverless in production, an experience reportServerless in production, an experience report
Serverless in production, an experience report
 
Developer-Friendly CI / CD for Kubernetes
Developer-Friendly CI / CD for KubernetesDeveloper-Friendly CI / CD for Kubernetes
Developer-Friendly CI / CD for Kubernetes
 
Serverless Development Deep Dive
Serverless Development Deep DiveServerless Development Deep Dive
Serverless Development Deep Dive
 
Building Serverless applications with Python
Building Serverless applications with PythonBuilding Serverless applications with Python
Building Serverless applications with Python
 
Writing and deploying serverless python applications
Writing and deploying serverless python applicationsWriting and deploying serverless python applications
Writing and deploying serverless python applications
 
Building serverless applications (April 2018)
Building serverless applications (April 2018)Building serverless applications (April 2018)
Building serverless applications (April 2018)
 
Kubernetes - State of the Union (Q1-2016)
Kubernetes - State of the Union (Q1-2016)Kubernetes - State of the Union (Q1-2016)
Kubernetes - State of the Union (Q1-2016)
 

More from masahitojp

Python と型ヒントとその使い方
Python と型ヒントとその使い方Python と型ヒントとその使い方
Python と型ヒントとその使い方
masahitojp
 
Enjoy Type Hints and its benefits
Enjoy Type Hints and its benefitsEnjoy Type Hints and its benefits
Enjoy Type Hints and its benefits
masahitojp
 
Presentation kyushu-2018
Presentation kyushu-2018Presentation kyushu-2018
Presentation kyushu-2018
masahitojp
 
serverless framework + AWS Lambda with Python
serverless framework + AWS Lambda with Pythonserverless framework + AWS Lambda with Python
serverless framework + AWS Lambda with Python
masahitojp
 
The Benefits of Type Hints
The Benefits of Type HintsThe Benefits of Type Hints
The Benefits of Type Hints
masahitojp
 
20170131 python3 6 PEP526
20170131 python3 6 PEP526 20170131 python3 6 PEP526
20170131 python3 6 PEP526
masahitojp
 
chat bot framework for Java8
chat bot framework for Java8chat bot framework for Java8
chat bot framework for Java8
masahitojp
 
Akka meetup 2014_sep
Akka meetup 2014_sepAkka meetup 2014_sep
Akka meetup 2014_sep
masahitojp
 
Pyconjp2014_implementations
Pyconjp2014_implementationsPyconjp2014_implementations
Pyconjp2014_implementations
masahitojp
 
Pyconsg2014 pyston
Pyconsg2014 pystonPyconsg2014 pyston
Pyconsg2014 pyston
masahitojp
 
Riak map reduce for beginners
Riak map reduce for beginnersRiak map reduce for beginners
Riak map reduce for beginners
masahitojp
 
Play2 translate 20120714
Play2 translate 20120714Play2 translate 20120714
Play2 translate 20120714masahitojp
 
Play2の裏側
Play2の裏側Play2の裏側
Play2の裏側masahitojp
 
Play!framework2.0 introduction
Play!framework2.0 introductionPlay!framework2.0 introduction
Play!framework2.0 introduction
masahitojp
 
5分で説明する Play! scala
5分で説明する Play! scala5分で説明する Play! scala
5分で説明する Play! scalamasahitojp
 

More from masahitojp (16)

Python と型ヒントとその使い方
Python と型ヒントとその使い方Python と型ヒントとその使い方
Python と型ヒントとその使い方
 
Enjoy Type Hints and its benefits
Enjoy Type Hints and its benefitsEnjoy Type Hints and its benefits
Enjoy Type Hints and its benefits
 
Presentation kyushu-2018
Presentation kyushu-2018Presentation kyushu-2018
Presentation kyushu-2018
 
serverless framework + AWS Lambda with Python
serverless framework + AWS Lambda with Pythonserverless framework + AWS Lambda with Python
serverless framework + AWS Lambda with Python
 
The Benefits of Type Hints
The Benefits of Type HintsThe Benefits of Type Hints
The Benefits of Type Hints
 
20170131 python3 6 PEP526
20170131 python3 6 PEP526 20170131 python3 6 PEP526
20170131 python3 6 PEP526
 
chat bot framework for Java8
chat bot framework for Java8chat bot framework for Java8
chat bot framework for Java8
 
Akka meetup 2014_sep
Akka meetup 2014_sepAkka meetup 2014_sep
Akka meetup 2014_sep
 
Pyconjp2014_implementations
Pyconjp2014_implementationsPyconjp2014_implementations
Pyconjp2014_implementations
 
Pyconsg2014 pyston
Pyconsg2014 pystonPyconsg2014 pyston
Pyconsg2014 pyston
 
Pykonjp2014
Pykonjp2014Pykonjp2014
Pykonjp2014
 
Riak map reduce for beginners
Riak map reduce for beginnersRiak map reduce for beginners
Riak map reduce for beginners
 
Play2 translate 20120714
Play2 translate 20120714Play2 translate 20120714
Play2 translate 20120714
 
Play2の裏側
Play2の裏側Play2の裏側
Play2の裏側
 
Play!framework2.0 introduction
Play!framework2.0 introductionPlay!framework2.0 introduction
Play!framework2.0 introduction
 
5分で説明する Play! scala
5分で説明する Play! scala5分で説明する Play! scala
5分で説明する Play! scala
 

Recently uploaded

road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
BrazilAccount1
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERSCW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
veerababupersonal22
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
ongomchris
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
BrazilAccount1
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
Vijay Dialani, PhD
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
SyedAbiiAzazi1
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
ChristineTorrepenida1
 

Recently uploaded (20)

road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERSCW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
CW RADAR, FMCW RADAR, FMCW ALTIMETER, AND THEIR PARAMETERS
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
 

Build a RESTful API with the Serverless Framework

  • 1. Build a RESTfull API with the Serverless framework Plone Conference WebDay 2018 Nov 7th 1
  • 2. Introduction 1. Introduce myself 2. perpose of this presentation Plone Conference WebDay 2018 Nov 7th 2
  • 3. Introduce myself • Masato Nakamura • twitter: masahito • github: masahitojp • work at Nulab inc. Typetalk team • use Scala and JavaScript and Python • Python ❤ and ☕ ❤ Plone Conference WebDay 2018 Nov 7th 3
  • 4. Perpose of this presentation • You can understand buid a REST API with the Serverless Framework • I will talk especially for the AWS services Plone Conference WebDay 2018 Nov 7th 4
  • 5. Not covering today • Technical Details • AWS knowledge(IAM etc) Plone Conference WebDay 2018 Nov 7th 5
  • 6. Today I will talk about following things • How to create an RESTful API with the Amazon API Gateway • How to use the Serverless Framework • How to make deployment easier Plone Conference WebDay 2018 Nov 7th 6
  • 7. How to create RESTful API Plone Conference WebDay 2018 Nov 7th 7
  • 8. How to create RESTful API 1. Where to use RESTful API? 2. What is the Amazon API Gateway 3. What is AWS Lambda Plone Conference WebDay 2018 Nov 7th 8
  • 9. Where to use RESTful API? • Upload File to the Amazon S3 • Send Message to a service Plone Conference WebDay 2018 Nov 7th 9
  • 10. Target • You use CMS • You want to make API more easily • I want you to introduce the Amazon API Gateway Plone Conference WebDay 2018 Nov 7th 10
  • 11. What is the Amazon API Gateway API creation, application communication gateway. Create an endpoint. It is created from the management console of AWS. We do not write actual code. It also has an authentication function, it separates the environment, deploys and scales. Plone Conference WebDay 2018 Nov 7th 11
  • 12. What is the AWS Lambda A service that executes code. Create a function called Lambda function and write code. You can write it directly in the AWS management console, but basically upload the code. You can write even code, AWS Lamvs provide manage servers, scaling, logging. Plone Conference WebDay 2018 Nov 7th 12
  • 13. What you can do with combining We can create RESTful API ❤ Plone Conference WebDay 2018 Nov 7th 13
  • 14. Flow of API creation 1. create the Amazon API Gateway 2. create AWS Lambda funtion 3. connect AWS GateWay & AWS Lambda funtion Plone Conference WebDay 2018 Nov 7th 14
  • 15. 1). create the Amazon API Gateway Plone Conference WebDay 2018 Nov 7th 15
  • 16. 2). create AWS Lambda funtion Plone Conference WebDay 2018 Nov 7th 16
  • 17. 3). connect the Amazon API Gateway & AWS Lambda funtion Plone Conference WebDay 2018 Nov 7th 17
  • 18. Next I want to talk about the AWS Lambda Plone Conference WebDay 2018 Nov 7th 18
  • 19. How to use the Serverless framework Plone Conference WebDay 2018 Nov 7th 19
  • 20. How to use the Serverless framework 1. How to deploy AWS Lambda function. 2. Introduce the Serverless Framework Plone Conference WebDay 2018 Nov 7th 20
  • 21. Target • Python newbie • use or used the AWS Lambda Plone Conference WebDay 2018 Nov 7th 21
  • 22. Goal • ! Easy to use AWS Lambda for Python • When you write Code, You can update easily Plone Conference WebDay 2018 Nov 7th 22
  • 23. can register at AWS console • Write Code • Run Test Plone Conference WebDay 2018 Nov 7th 23
  • 24. When used only once This is enough Plone Conference WebDay 2018 Nov 7th 24
  • 25. • example: POST JSON -> send message to Chat Plone Conference WebDay 2018 Nov 7th 25
  • 26. • example: POST JSON -> send message to Chat • ! We want to use a 3rd Party lib • requests • add requirements.txt requests • run $ pip install -r requirements.txt -t vendor/ $ edit python-file $ zip /path/to/service-dir $ aws lambda ~~ Plone Conference WebDay 2018 Nov 7th 26
  • 27.   It's troublesome to do with the AWS console ! use 3rd party libraries ! Especially when using C-API ! Code version control (git etc) Plone Conference WebDay 2018 Nov 7th 27
  • 28. Deploy to the AWSLambda • Deployment using ZipFile is possible ! Code version control (git etc) Plone Conference WebDay 2018 Nov 7th 28
  • 29. • Deployment using ZipFile is possible $ aws lambda create-function --function-name AccessMemCache --region us-east-1 --zip-file fileb://path-to/app.zip --role execution-role-arn --handler app.handler --runtime python3.6 --timeout 30 --vpc-config SubnetIds=comma-separated-vpc-subnet-ids,SecurityGroupIds=default-security-group-id --memory-size 1024 https://docs.aws.amazon.com/ja_jp/lambda/latest/ dg/vpc-ec-upload-deployment-pkg.html Plone Conference WebDay 2018 Nov 7th 29
  • 30. I want to make it easier ! Create a zipfile each time you change -> deploy ! Run test locally • What we need now $ edit python-file $ (pip install ~~) $ zip /path/to/service-dir $ aws lambda ~~ Plone Conference WebDay 2018 Nov 7th 30
  • 31. Introduce the Serverless Framework Plone Conference WebDay 2018 Nov 7th 31
  • 32. What is the Serverless Framework? • http://www.serverless.com Serverless Framework – Build web, mobile and IoT applications with serverless architectures using AWS Lambda, Azure Functions, Google CloudFunctions & more! • AWS Lambda, Azure Functions, Google CloudFunctions を使ってサーバレスアーキテク チャで web, Mobile IoT アプリケーションを作ろう Plone Conference WebDay 2018 Nov 7th 32
  • 33. Description of the Serverless Framework • pros !! Code version control(git / svn / Hg) ! zip -> deploy is possible by executing Only 1 command ! manage CloudWatch/ AWS IAM Plone Conference WebDay 2018 Nov 7th 33
  • 34. Use the Serverless Framework How to create environments $ npm instal -g serverless $ sls -v 1.32.0 Plone Conference WebDay 2018 Nov 7th 34
  • 35. create AWS Lambda with the Serverless Framework $ sls create -t aws-python3 -p py3-hello Serverless: Generating boilerplate... Serverless: Generating boilerplate in "/Users/masahito-nulab/src/jobs/typetalk-serverless-internal/py3-hello" _______ __ | _ .-----.----.--.--.-----.----| .-----.-----.-----. | |___| -__| _| | | -__| _| | -__|__ --|__ --| |____ |_____|__| ___/|_____|__| |__|_____|_____|_____| | | | The Serverless Application Framework | | serverless.com, v1.27.3 -------' Serverless: Successfully generated boilerplate for template: "aws-python3" $ tree py3-hello/ py3-hello/ !"" handler.py #"" serverless.yml Plone Conference WebDay 2018 Nov 7th 35
  • 36. • handler.py import json def hello(event, context): body = { "message": "Go Serverless v1.0! Your function executed successfully!", "input": event } response = { "statusCode": 200, "body": json.dumps(body) } return response • serverless.yml service: py3-hello provider: name: aws runtime: python3.6 functions: hello: handler: handler.hello Plone Conference WebDay 2018 Nov 7th 36
  • 37. Run Test locally $ cd py3-hello $ sls invoke local -f hello { "statusCode": 200, "body": "{"message": "Go Serverless v1.0! Your function executed successfully!", "input": {}}" } Plone Conference WebDay 2018 Nov 7th 37
  • 38. Deploy to AWS Lambda ! Deployment will be simplified after setting the IAM/Role $ sls deploy Plone Conference WebDay 2018 Nov 7th 38
  • 39. How to make deployment easier Plone Conference WebDay 2018 Nov 7th 39
  • 40. How to make deployment easier 1. reduce troublesome for library installation 2. Non-Pure Python module Plone Conference WebDay 2018 Nov 7th 40
  • 41. Goal • Easy to use AWS Lambda for Python • ! When you write Code, You can update easily Plone Conference WebDay 2018 Nov 7th 41
  • 42. Plone Conference WebDay 2018 Nov 7th 42
  • 43. reduce troublesome for library installation ! required 3rd-party library installation # ! I often forget this $ pip install -r requirement.txt -t vendor/ $ sls deploy Plone Conference WebDay 2018 Nov 7th 43
  • 44. reduce troublesome for library installation Use serverless-framework plugin • UnitedIncome/serverless-python-requirements • serverless >= v1.12 Plone Conference WebDay 2018 Nov 7th 44
  • 45. How to install this plugin $ sls plugin install -n serverless-python-requirements service: py3-hello provider: name: aws runtime: python3.6 cfLogs: true plugins: - serverless-python-requirements functions: hello: handler: handler.hello Plone Conference WebDay 2018 Nov 7th 45
  • 46. Deploy ($ sls requirements install) $ sls deploy Plone Conference WebDay 2018 Nov 7th 46
  • 47. It is now possible to execute with a only 1 command ! Plone Conference WebDay 2018 Nov 7th 47
  • 48. Non-Pure Python module • Developers often use Windows / OSX for development environment • Python has lots of libraries written with C-API • numpy , TensorFlow , Image Libraries: pillow etc • Creating a zipfile locally does not work at AWS Lambda ! • The environment of AWS Lambda is Linux Plone Conference WebDay 2018 Nov 7th 48
  • 49. dockerize pip Cross-compile in docker environment • It uses docker image ”lambci / docker-lambda" service: py3-hello provider: name: aws runtime: python3.6 cfLogs: true plugins: - serverless-python-requirements custom: pythonRequirements: dockerizePip: true functions: hello: handler: handler.hello Plone Conference WebDay 2018 Nov 7th 49
  • 50. Today I talked about following things • How to create an RESTful API with the Amazon API Gateway • How to use the Serverless Framework • How to make deployment easier Plone Conference WebDay 2018 Nov 7th 50
  • 51. I hope you can write and deploy RESTfull API ❤ Plone Conference WebDay 2018 Nov 7th 51
  • 52. Thank you @masahito Plone Conference WebDay 2018 Nov 7th 52