SlideShare a Scribd company logo
1 of 33
Download to read offline
About
Manish Pandit
Director of Platform Engineering @Marqeta
Twitter : @lobster1234
Blog: lobster1234.github.io
LinkedIn: in/mpandit
Serverless
Serverless is the finest grain abstraction in distributed computing
100% managed with zero infrastructure concerns
Lowest cost compared to Servers and Containers (if designed correctly!)
Why Serverless
Ideal fit for microservices architectures - functions have limited, well
defined scopes
Pricing - you pay for what you use
No need to worry about infrastructure
AWS Lambda
Function as a Service
Simple Pricing Model - Memory * time
Event Sources - DynamoDB, S3, API Gateway, Cloudwatch, SNS...
Security via VPC and IAM Roles
Serverless Framework
Node.js based CLI
Makes working with FaaS much, much easier
Simple, YAML based configuration abstracts Cloudformation
Supports many cloud providers - AWS, OpenWhisk, GCP, Azure
Supports stages
Popular, feature rich, well documented
Install
bash-3.2$ npm install serverless -g
+ serverless@1.23.0
bash-3.2$ serverless --version
1.23.0
Configure AWS - Option 1
bash-3.2$ aws configure
AWS Access Key ID [****************4MTA]:
AWS Secret Access Key [****************g2uU]:
Default region name [us-east-1]:
Default output format [json]:
bash-3.2$
Configure AWS - Option 2
bash-3.2$ serverless config credentials --provider aws --key XXXX --secret YYY
If you already have a default profile….
Serverless: Setting up AWS...
Serverless: Failed! ~/.aws/credentials already has a "default" profile. Use the
overwrite flag ("-o" or "--overwrite") to force the update
Create a Project
bash-3.2$ serverless create --template aws-java-maven
Serverless: Generating boilerplate...
Serverless: Successfully generated boilerplate for template: "aws-java-maven"
Serverless: NOTE: Please update the "service" property in serverless.yml with your
service name
bash-3.2$
The Project Structure
bash-3.2$ tree .
.
├── pom.xml
├── serverless.yml
└── src
└── main
├── java
│ └── com
│ └── serverless
│ ├── ApiGatewayResponse.java
│ ├── Handler.java
│ └── Response.java
└── resources
└── log4j.properties
6 directories, 6 files
serverless.yml
service: aws-java-maven # NOTE: update this with your service name
provider:
name: aws
runtime: java8
package:
artifact: target/hello-dev.jar
functions:
hello:
handler: com.serverless.Handler
# The following are a few example events you can configure
# NOTE: Please make sure to change your handler code to work with those events
# Check the event documentation for details
# events:
# - http:
# path: users/create
# method: get
Handler Class
package com.serverless;
import …
public class Handler implements RequestHandler<Map<String, Object>, ApiGatewayResponse>
handleRequest Method
@Override
public ApiGatewayResponse handleRequest(Map<String, Object> input, Context context) {
BasicConfigurator.configure();
LOG.info("received: " + input);
Response responseBody = new Response("Go Serverless v1.x! Your function executed successfully!",
input);
return ApiGatewayResponse.builder()
.setStatusCode(200)
.setObjectBody(responseBody)
.setHeaders(Collections.singletonMap("X-Powered-By", "AWS Lambda & serverless"))
.build();
}
Build
bash-3.2$ mvn clean install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building hello dev
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ hello ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.666 s
[INFO] Finished at: 2017-10-07T01:34:10-07:00
[INFO] Final Memory: 16M/214M
[INFO] ------------------------------------------------------------------------
Deploy
bash-3.2$ serverless deploy
Serverless: Packaging service...
Serverless: Creating Stack...
Serverless: Checking Stack create progress...
Serverless: Stack create finished...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Validating template...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
...............
Serverless: Stack update finished...
Service Information
service: aws-java-maven
stage: dev
region: us-east-1
stack: aws-java-maven-dev
api keys:
None
endpoints:
None
functions:
hello: aws-java-maven-dev-hello
Invoke
bash-3.2$ serverless invoke -f hello
{
"statusCode": 200,
"body": "{"message":"Go Serverless v1.x! Your function executed successfully!","input":{}}",
"headers": {
"X-Powered-By": "AWS Lambda & serverless"
},
"isBase64Encoded": false
}
bash-3.2$
Execution
1.An event source generates an event, or a trigger
2.A new container is spun off or an existing one is reused to launch
the runtime
3.The function (script if interpreted language, binary if compiled) is
executed
4.The runtime exits
Invoke Local
bash-3.2$ serverless invoke local -f hello
Serverless: In order to get human-readable output, please implement "toString()" method of your
"ApiGatewayResponse" object.
0 [main] INFO com.serverless.Handler - received: {}
com.serverless.ApiGatewayResponse@77cd7a0
bash-3.2$
Using an HTTP Event Source
service: aws-java-maven # NOTE: update this with your service name
provider:
name: aws
runtime: java8
package:
artifact: target/hello-dev.jar
functions:
hello:
handler: com.serverless.Handler
events:
- http:
path: /hello
method: get
Deploy with a new stage!
bash-3.2$ serverless deploy --stage prod
Serverless: Packaging service...
Serverless: Creating Stack...
Serverless: Checking Stack create progress…
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
Serverless: Stack update finished...
Service Information
service: aws-java-maven
stage: prod
region: us-east-1
stack: aws-java-maven-prod
api keys:
None
endpoints:
GET - https://f582xxq581.execute-api.us-east-1.amazonaws.com/prod/hello
functions:
hello: aws-java-maven-prod-hello
Test
bash-3.2$ curl https://f582xxq581.execute-api.us-east-1.amazonaws.com/prod/hello
{"message":"Go Serverless v1.x! Your function executed
successfully!","input":{"resource":"/hello","path":"/hello","httpMethod":"GET","headers":{"Accept":"*/*","Cl
oudFront-Forwarded-Proto":"https","CloudFront-Is-Desktop-Viewer":"true","CloudFront-Is-Mobile-
Viewer":"false","CloudFront-Is-SmartTV-Viewer":"false","CloudFront-Is-Tablet-Viewer":"false","CloudFront-
Viewer-Country":"US","Host":"f582xxq581.execute-api.us-east-1.amazonaws.com","User-
Agent":"curl/7.51.0","Via":"1.1 3cc911e7eb2df956e3f7c8f27c198a0b.cloudfront.net (CloudFront)","X-Amz-Cf-
Id":"rngpB7WCzOt_XnMXzDc0Pv5i9Eq7_ZA1olb08W84xi5Of8Od4VvVVw==","X-Amzn-Trace-Id":"Root=1-59d895b4-
375b518e32e7a6866c80fa0a","X-Forwarded-For":"69.181.73.181, 205.251.214.68","X-Forwarded-Port":"443","X-
Forwarded-
Proto":"https"},"queryStringParameters":null,"pathParameters":null,"stageVariables":null,"requestContext":{"
path":"/prod/hello","accountId":"xxxxxxxxxxxx","resourceId":"07sycy","stage":"prod","requestId":"cab13cdc-
ab3c-11e7-b85c-
0fc68f7d77c1","identity":{"cognitoIdentityPoolId":null,"accountId":null,"cognitoIdentityId":null,"caller":nu
ll,"apiKey":"","sourceIp":"69.181.73.181","accessKey":null,"cognitoAuthenticationType":null,"cognitoAuthenti
cationProvider":null,"userArn":null,"userAgent":"curl/7.51.0","user":null},"resourcePath":"/hello","httpMeth
od":"GET","apiId":"f582xxq581"},"body":null,"isBase64Encoded":false}}
bash-3.2$
Serverless Logs
bash-3.2$ serverless logs -f hello
START RequestId: 32c366cc-ab41-11e7-bcba-6f7680b04a52 Version: $LATEST
2017-10-07 09:23:38 <32c366cc-ab41-11e7-bcba-6f7680b04a52> INFO com.serverless.Handler:20 -
received: {}
0 [main] INFO com.serverless.Handler - received: {}
END RequestId: 32c366cc-ab41-11e7-bcba-6f7680b04a52
REPORT RequestId: 32c366cc-ab41-11e7-bcba-6f7680b04a52 Duration: 411.34 ms Billed Duration: 500 ms
Memory Size: 1024 MB Max Memory Used: 63 MB
START RequestId: e41254f3-ab41-11e7-ab1b-750906e00517 Version: $LATEST
2017-10-07 09:28:34 <e41254f3-ab41-11e7-ab1b-750906e00517> INFO com.serverless.Handler:20 -
received: {}
END RequestId: e41254f3-ab41-11e7-ab1b-750906e00517
REPORT RequestId: e41254f3-ab41-11e7-ab1b-750906e00517 Duration: 9.92 ms Billed Duration: 100 ms
Memory Size: 1024 MB Max Memory Used: 63 MB
Serverless Metrics
bash-3.2$ serverless metrics -f hello
Service wide metrics
October 6, 2017 2:21 AM - October 7, 2017 2:21 AM
Invocations: 4
Throttles: 0
Errors: 0
Duration (avg.): 206.84ms
bash-3.2$
Serverless Metrics w/ Stages
bash-3.2$ serverless metrics --stage dev -f hello
hello
October 6, 2017 2:29 AM - October 7, 2017 2:29 AM
Invocations: 8
Throttles: 0
Errors: 0
Duration (avg.): 120.89ms
bash-3.2$ serverless metrics --stage prod -f hello
hello
October 6, 2017 2:29 AM - October 7, 2017 2:29 AM
Invocations: 6
Throttles: 0
Errors: 0
Duration (avg.): 187.97ms
Serverless Info
bash-3.2$ serverless info
Service Information
service: aws-java-maven
stage: dev
region: us-east-1
stack: aws-java-maven-dev
api keys:
None
endpoints:
None
functions:
hello: aws-java-maven-dev-hello
Serverless Info w/Stages
bash-3.2$ serverless info --stage prod
Service Information
service: aws-java-maven
stage: prod
region: us-east-1
stack: aws-java-maven-prod
api keys:
None
endpoints:
GET - https://f582xxq581.execute-api.us-east-1.amazonaws.com/prod/hello
functions:
hello: aws-java-maven-prod-hello
bash-3.2$
Remove Stack
bash-3.2$ serverless remove
Serverless: Getting all objects in S3 bucket...
Serverless: Removing objects in S3 bucket...
Serverless: Removing Stack...
Serverless: Checking Stack removal progress...
....
Serverless: Stack removal finished…
bash-3.2$
Remove Stack w/Stages
bash-3.2$ serverless remove --stage prod
Serverless: Getting all objects in S3 bucket...
Serverless: Removing objects in S3 bucket...
Serverless: Removing Stack...
Serverless: Checking Stack removal progress...
................
Serverless: Stack removal finished…
bash-3.2$ curl https://f582xxq581.execute-api.us-east-1.amazonaws.com/prod/hello
curl: (35) SSL peer handshake failed, the server most likely requires a client
certificate to connect
bash-3.2$
Lambda Tips
1. Write your code in a way that it can be tested without an event source
2. Lambda cannot execute for longer than 5 minutes
3. Coordinating many Lambdas can be difficult, use AWS Step Functions
4. Do not persist anything on the disk - it may not be available
5. Be aware of cold start - JVM will take a while to start
6. Do not write lambdas for everything - if a service is high throughput, you’re better off
with ECS or EC2 given the costs
7. Lambdas can be tied to VPCs and have IAM execution roles
8. Serverless supports API Gateway Proxy Integration by default - everything gets passed to
the function
Resources
Serverless Framework - https://serverless.com
AWS Lambda - https://aws.amazon.com/lambda
My Tutorial - https://lobster1234.github.io/categories/serverless
Questions
Manish Pandit
@lobster1234
lobster1234.github.io

More Related Content

What's hot

AWS Infrastructure as Code - September 2016 Webinar Series
AWS Infrastructure as Code - September 2016 Webinar SeriesAWS Infrastructure as Code - September 2016 Webinar Series
AWS Infrastructure as Code - September 2016 Webinar SeriesAmazon Web Services
 
[AWS Dev Day] 앱 현대화 | AWS Fargate를 사용한 서버리스 컨테이너 활용 하기 - 삼성전자 개발자 포털 사례 - 정영준...
[AWS Dev Day] 앱 현대화 | AWS Fargate를 사용한 서버리스 컨테이너 활용 하기 - 삼성전자 개발자 포털 사례 - 정영준...[AWS Dev Day] 앱 현대화 | AWS Fargate를 사용한 서버리스 컨테이너 활용 하기 - 삼성전자 개발자 포털 사례 - 정영준...
[AWS Dev Day] 앱 현대화 | AWS Fargate를 사용한 서버리스 컨테이너 활용 하기 - 삼성전자 개발자 포털 사례 - 정영준...Amazon Web Services Korea
 
(APP306) Using AWS CloudFormation for Deployment and Management at Scale | AW...
(APP306) Using AWS CloudFormation for Deployment and Management at Scale | AW...(APP306) Using AWS CloudFormation for Deployment and Management at Scale | AW...
(APP306) Using AWS CloudFormation for Deployment and Management at Scale | AW...Amazon Web Services
 
OpenSource ToolChain for the Hybrid Cloud
OpenSource ToolChain for the Hybrid CloudOpenSource ToolChain for the Hybrid Cloud
OpenSource ToolChain for the Hybrid CloudIsaac Christoffersen
 
Automation with Packer and TerraForm
Automation with Packer and TerraFormAutomation with Packer and TerraForm
Automation with Packer and TerraFormWesley Charles Blake
 
Amazon EC2 Container Service Live Demo - Microservices Web Day
Amazon EC2 Container Service Live Demo - Microservices Web DayAmazon EC2 Container Service Live Demo - Microservices Web Day
Amazon EC2 Container Service Live Demo - Microservices Web DayAWS Germany
 
Spinnaker 파트 1
Spinnaker 파트 1Spinnaker 파트 1
Spinnaker 파트 1Steven Shim
 
The AWS DevOps combo (January 2017)
The AWS DevOps combo (January 2017)The AWS DevOps combo (January 2017)
The AWS DevOps combo (January 2017)Julien SIMON
 
AWS CloudFormation and Puppet at PuppetConf - Jinesh Varia
AWS CloudFormation and Puppet at PuppetConf - Jinesh VariaAWS CloudFormation and Puppet at PuppetConf - Jinesh Varia
AWS CloudFormation and Puppet at PuppetConf - Jinesh VariaAmazon Web Services
 
Fargate 를 이용한 ECS with VPC 1부
Fargate 를 이용한 ECS with VPC 1부Fargate 를 이용한 ECS with VPC 1부
Fargate 를 이용한 ECS with VPC 1부Hyun-Mook Choi
 
ECS & ECR Deep Dive - 김기완 솔루션즈 아키텍트 :: AWS Container Day
ECS & ECR Deep Dive - 김기완 솔루션즈 아키텍트 :: AWS Container DayECS & ECR Deep Dive - 김기완 솔루션즈 아키텍트 :: AWS Container Day
ECS & ECR Deep Dive - 김기완 솔루션즈 아키텍트 :: AWS Container DayAmazon Web Services Korea
 
Infrastructure as code with Amazon Web Services
Infrastructure as code with Amazon Web ServicesInfrastructure as code with Amazon Web Services
Infrastructure as code with Amazon Web ServicesJulien SIMON
 
AWS Webcast - Getting Started with AWS OpsWorks
AWS Webcast - Getting Started with AWS OpsWorksAWS Webcast - Getting Started with AWS OpsWorks
AWS Webcast - Getting Started with AWS OpsWorksAmazon Web Services
 
Introduction to Amazon EC2 Container Service and setting up build pipeline wi...
Introduction to Amazon EC2 Container Service and setting up build pipeline wi...Introduction to Amazon EC2 Container Service and setting up build pipeline wi...
Introduction to Amazon EC2 Container Service and setting up build pipeline wi...Swapnil Dahiphale
 
EC2 AMI Factory with Chef, Berkshelf, and Packer
EC2 AMI Factory with Chef, Berkshelf, and PackerEC2 AMI Factory with Chef, Berkshelf, and Packer
EC2 AMI Factory with Chef, Berkshelf, and PackerGeorge Miranda
 

What's hot (20)

AWS CloudFormation Masterclass
AWS CloudFormation MasterclassAWS CloudFormation Masterclass
AWS CloudFormation Masterclass
 
AWS Infrastructure as Code - September 2016 Webinar Series
AWS Infrastructure as Code - September 2016 Webinar SeriesAWS Infrastructure as Code - September 2016 Webinar Series
AWS Infrastructure as Code - September 2016 Webinar Series
 
[AWS Dev Day] 앱 현대화 | AWS Fargate를 사용한 서버리스 컨테이너 활용 하기 - 삼성전자 개발자 포털 사례 - 정영준...
[AWS Dev Day] 앱 현대화 | AWS Fargate를 사용한 서버리스 컨테이너 활용 하기 - 삼성전자 개발자 포털 사례 - 정영준...[AWS Dev Day] 앱 현대화 | AWS Fargate를 사용한 서버리스 컨테이너 활용 하기 - 삼성전자 개발자 포털 사례 - 정영준...
[AWS Dev Day] 앱 현대화 | AWS Fargate를 사용한 서버리스 컨테이너 활용 하기 - 삼성전자 개발자 포털 사례 - 정영준...
 
(APP306) Using AWS CloudFormation for Deployment and Management at Scale | AW...
(APP306) Using AWS CloudFormation for Deployment and Management at Scale | AW...(APP306) Using AWS CloudFormation for Deployment and Management at Scale | AW...
(APP306) Using AWS CloudFormation for Deployment and Management at Scale | AW...
 
OpenSource ToolChain for the Hybrid Cloud
OpenSource ToolChain for the Hybrid CloudOpenSource ToolChain for the Hybrid Cloud
OpenSource ToolChain for the Hybrid Cloud
 
Automation with Packer and TerraForm
Automation with Packer and TerraFormAutomation with Packer and TerraForm
Automation with Packer and TerraForm
 
Getting Started with Amazon ECS
Getting Started with Amazon ECSGetting Started with Amazon ECS
Getting Started with Amazon ECS
 
Amazon EC2 Container Service Live Demo - Microservices Web Day
Amazon EC2 Container Service Live Demo - Microservices Web DayAmazon EC2 Container Service Live Demo - Microservices Web Day
Amazon EC2 Container Service Live Demo - Microservices Web Day
 
Spinnaker 파트 1
Spinnaker 파트 1Spinnaker 파트 1
Spinnaker 파트 1
 
Packer
Packer Packer
Packer
 
The AWS DevOps combo (January 2017)
The AWS DevOps combo (January 2017)The AWS DevOps combo (January 2017)
The AWS DevOps combo (January 2017)
 
AWS CloudFormation and Puppet at PuppetConf - Jinesh Varia
AWS CloudFormation and Puppet at PuppetConf - Jinesh VariaAWS CloudFormation and Puppet at PuppetConf - Jinesh Varia
AWS CloudFormation and Puppet at PuppetConf - Jinesh Varia
 
Amazon EC2 Container Service
Amazon EC2 Container ServiceAmazon EC2 Container Service
Amazon EC2 Container Service
 
Packer by HashiCorp
Packer by HashiCorpPacker by HashiCorp
Packer by HashiCorp
 
Fargate 를 이용한 ECS with VPC 1부
Fargate 를 이용한 ECS with VPC 1부Fargate 를 이용한 ECS with VPC 1부
Fargate 를 이용한 ECS with VPC 1부
 
ECS & ECR Deep Dive - 김기완 솔루션즈 아키텍트 :: AWS Container Day
ECS & ECR Deep Dive - 김기완 솔루션즈 아키텍트 :: AWS Container DayECS & ECR Deep Dive - 김기완 솔루션즈 아키텍트 :: AWS Container Day
ECS & ECR Deep Dive - 김기완 솔루션즈 아키텍트 :: AWS Container Day
 
Infrastructure as code with Amazon Web Services
Infrastructure as code with Amazon Web ServicesInfrastructure as code with Amazon Web Services
Infrastructure as code with Amazon Web Services
 
AWS Webcast - Getting Started with AWS OpsWorks
AWS Webcast - Getting Started with AWS OpsWorksAWS Webcast - Getting Started with AWS OpsWorks
AWS Webcast - Getting Started with AWS OpsWorks
 
Introduction to Amazon EC2 Container Service and setting up build pipeline wi...
Introduction to Amazon EC2 Container Service and setting up build pipeline wi...Introduction to Amazon EC2 Container Service and setting up build pipeline wi...
Introduction to Amazon EC2 Container Service and setting up build pipeline wi...
 
EC2 AMI Factory with Chef, Berkshelf, and Packer
EC2 AMI Factory with Chef, Berkshelf, and PackerEC2 AMI Factory with Chef, Berkshelf, and Packer
EC2 AMI Factory with Chef, Berkshelf, and Packer
 

Similar to AWS Lambda with Serverless Framework and Java

DB proxy server test: run tests on tens of virtual machines with Jenkins, Vag...
DB proxy server test: run tests on tens of virtual machines with Jenkins, Vag...DB proxy server test: run tests on tens of virtual machines with Jenkins, Vag...
DB proxy server test: run tests on tens of virtual machines with Jenkins, Vag...Timofey Turenko
 
Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
 Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbsAWS Chicago
 
DevOps for the Enterprise: Virtual Office Hours
DevOps for the Enterprise: Virtual Office HoursDevOps for the Enterprise: Virtual Office Hours
DevOps for the Enterprise: Virtual Office HoursAmazon Web Services
 
Application Lifecycle Management in a Serverless World
Application Lifecycle Management in a Serverless WorldApplication Lifecycle Management in a Serverless World
Application Lifecycle Management in a Serverless WorldAmazon Web Services
 
2013 05-openstack-israel-heat
2013 05-openstack-israel-heat2013 05-openstack-israel-heat
2013 05-openstack-israel-heatAlex Heneveld
 
Self Service Agile Infrastructure for Product Teams - Pop-up Loft Tel Aviv
Self Service Agile Infrastructure for Product Teams - Pop-up Loft Tel AvivSelf Service Agile Infrastructure for Product Teams - Pop-up Loft Tel Aviv
Self Service Agile Infrastructure for Product Teams - Pop-up Loft Tel AvivAmazon Web Services
 
Aws Lambda in Swift - NSLondon - 3rd December 2020
Aws Lambda in Swift - NSLondon - 3rd December 2020Aws Lambda in Swift - NSLondon - 3rd December 2020
Aws Lambda in Swift - NSLondon - 3rd December 2020Andrea Scuderi
 
AWS meets Continuous Delivery
AWS meets Continuous DeliveryAWS meets Continuous Delivery
AWS meets Continuous DeliveryAndreas Mohrhard
 
Node Interactive: Node.js Performance and Highly Scalable Micro-Services
Node Interactive: Node.js Performance and Highly Scalable Micro-ServicesNode Interactive: Node.js Performance and Highly Scalable Micro-Services
Node Interactive: Node.js Performance and Highly Scalable Micro-ServicesChris Bailey
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesLindsay Holmwood
 
AWS re:Invent 2016: Deploying and Managing .NET Pipelines and Microsoft Workl...
AWS re:Invent 2016: Deploying and Managing .NET Pipelines and Microsoft Workl...AWS re:Invent 2016: Deploying and Managing .NET Pipelines and Microsoft Workl...
AWS re:Invent 2016: Deploying and Managing .NET Pipelines and Microsoft Workl...Amazon Web Services
 
Migrate your Existing Express Apps to AWS Lambda and Amazon API Gateway
Migrate your Existing Express Apps to AWS Lambda and Amazon API GatewayMigrate your Existing Express Apps to AWS Lambda and Amazon API Gateway
Migrate your Existing Express Apps to AWS Lambda and Amazon API GatewayAmazon Web Services
 
Fluentd Plugins for CouchDB, Amazon SQS/SNS
Fluentd Plugins for CouchDB, Amazon SQS/SNSFluentd Plugins for CouchDB, Amazon SQS/SNS
Fluentd Plugins for CouchDB, Amazon SQS/SNSYuri Odagiri
 
A 60-minute tour of AWS Compute (November 2016)
A 60-minute tour of AWS Compute (November 2016)A 60-minute tour of AWS Compute (November 2016)
A 60-minute tour of AWS Compute (November 2016)Julien SIMON
 
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...Emerson Eduardo Rodrigues Von Staffen
 
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...Amazon Web Services
 
Serverless archtiectures
Serverless archtiecturesServerless archtiectures
Serverless archtiecturesIegor Fadieiev
 

Similar to AWS Lambda with Serverless Framework and Java (20)

DB proxy server test: run tests on tens of virtual machines with Jenkins, Vag...
DB proxy server test: run tests on tens of virtual machines with Jenkins, Vag...DB proxy server test: run tests on tens of virtual machines with Jenkins, Vag...
DB proxy server test: run tests on tens of virtual machines with Jenkins, Vag...
 
Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
 Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
 
DevOps for the Enterprise: Virtual Office Hours
DevOps for the Enterprise: Virtual Office HoursDevOps for the Enterprise: Virtual Office Hours
DevOps for the Enterprise: Virtual Office Hours
 
Application Lifecycle Management in a Serverless World
Application Lifecycle Management in a Serverless WorldApplication Lifecycle Management in a Serverless World
Application Lifecycle Management in a Serverless World
 
AWS Serverless Workshop
AWS Serverless WorkshopAWS Serverless Workshop
AWS Serverless Workshop
 
2013 05-openstack-israel-heat
2013 05-openstack-israel-heat2013 05-openstack-israel-heat
2013 05-openstack-israel-heat
 
Self Service Agile Infrastructure for Product Teams - Pop-up Loft Tel Aviv
Self Service Agile Infrastructure for Product Teams - Pop-up Loft Tel AvivSelf Service Agile Infrastructure for Product Teams - Pop-up Loft Tel Aviv
Self Service Agile Infrastructure for Product Teams - Pop-up Loft Tel Aviv
 
Aws Lambda in Swift - NSLondon - 3rd December 2020
Aws Lambda in Swift - NSLondon - 3rd December 2020Aws Lambda in Swift - NSLondon - 3rd December 2020
Aws Lambda in Swift - NSLondon - 3rd December 2020
 
MesosCon - Be a microservices hero
MesosCon - Be a microservices heroMesosCon - Be a microservices hero
MesosCon - Be a microservices hero
 
AWS meets Continuous Delivery
AWS meets Continuous DeliveryAWS meets Continuous Delivery
AWS meets Continuous Delivery
 
Node Interactive: Node.js Performance and Highly Scalable Micro-Services
Node Interactive: Node.js Performance and Highly Scalable Micro-ServicesNode Interactive: Node.js Performance and Highly Scalable Micro-Services
Node Interactive: Node.js Performance and Highly Scalable Micro-Services
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websites
 
AWS re:Invent 2016: Deploying and Managing .NET Pipelines and Microsoft Workl...
AWS re:Invent 2016: Deploying and Managing .NET Pipelines and Microsoft Workl...AWS re:Invent 2016: Deploying and Managing .NET Pipelines and Microsoft Workl...
AWS re:Invent 2016: Deploying and Managing .NET Pipelines and Microsoft Workl...
 
Migrate your Existing Express Apps to AWS Lambda and Amazon API Gateway
Migrate your Existing Express Apps to AWS Lambda and Amazon API GatewayMigrate your Existing Express Apps to AWS Lambda and Amazon API Gateway
Migrate your Existing Express Apps to AWS Lambda and Amazon API Gateway
 
Fluentd Plugins for CouchDB, Amazon SQS/SNS
Fluentd Plugins for CouchDB, Amazon SQS/SNSFluentd Plugins for CouchDB, Amazon SQS/SNS
Fluentd Plugins for CouchDB, Amazon SQS/SNS
 
A 60-minute tour of AWS Compute (November 2016)
A 60-minute tour of AWS Compute (November 2016)A 60-minute tour of AWS Compute (November 2016)
A 60-minute tour of AWS Compute (November 2016)
 
Deploying SharePoint @ Cloud
Deploying SharePoint @ CloudDeploying SharePoint @ Cloud
Deploying SharePoint @ Cloud
 
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
 
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
 
Serverless archtiectures
Serverless archtiecturesServerless archtiectures
Serverless archtiectures
 

More from Manish Pandit

Disaster recovery - What, Why, and How
Disaster recovery - What, Why, and HowDisaster recovery - What, Why, and How
Disaster recovery - What, Why, and HowManish Pandit
 
Serverless Architectures on AWS in practice - OSCON 2018
Serverless Architectures on AWS in practice - OSCON 2018Serverless Architectures on AWS in practice - OSCON 2018
Serverless Architectures on AWS in practice - OSCON 2018Manish Pandit
 
Disaster Recovery and Reliability
Disaster Recovery and ReliabilityDisaster Recovery and Reliability
Disaster Recovery and ReliabilityManish Pandit
 
AWS Primer and Quickstart
AWS Primer and QuickstartAWS Primer and Quickstart
AWS Primer and QuickstartManish Pandit
 
Securing your APIs with OAuth, OpenID, and OpenID Connect
Securing your APIs with OAuth, OpenID, and OpenID ConnectSecuring your APIs with OAuth, OpenID, and OpenID Connect
Securing your APIs with OAuth, OpenID, and OpenID ConnectManish Pandit
 
Silicon Valley 2014 - API Antipatterns
Silicon Valley 2014 - API AntipatternsSilicon Valley 2014 - API Antipatterns
Silicon Valley 2014 - API AntipatternsManish Pandit
 
Scalabay - API Design Antipatterns
Scalabay - API Design AntipatternsScalabay - API Design Antipatterns
Scalabay - API Design AntipatternsManish Pandit
 
OSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at Netflix
OSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at NetflixOSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at Netflix
OSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at NetflixManish Pandit
 
API Design Antipatterns - APICon SF
API Design Antipatterns - APICon SFAPI Design Antipatterns - APICon SF
API Design Antipatterns - APICon SFManish Pandit
 
Motivation : it Matters
Motivation : it MattersMotivation : it Matters
Motivation : it MattersManish Pandit
 
Building Apis in Scala with Playframework2
Building Apis in Scala with Playframework2Building Apis in Scala with Playframework2
Building Apis in Scala with Playframework2Manish Pandit
 
Introducing Scala to your Ruby/Java Shop : My experiences at IGN
Introducing Scala to your Ruby/Java Shop : My experiences at IGNIntroducing Scala to your Ruby/Java Shop : My experiences at IGN
Introducing Scala to your Ruby/Java Shop : My experiences at IGNManish Pandit
 
Evolving IGN’s New APIs with Scala
 Evolving IGN’s New APIs with Scala Evolving IGN’s New APIs with Scala
Evolving IGN’s New APIs with ScalaManish Pandit
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented ProgrammingManish Pandit
 
Silicon Valley Code Camp 2011: Play! as you REST
Silicon Valley Code Camp 2011: Play! as you RESTSilicon Valley Code Camp 2011: Play! as you REST
Silicon Valley Code Camp 2011: Play! as you RESTManish Pandit
 
Silicon Valley Code Camp: 2011 Introduction to MongoDB
Silicon Valley Code Camp: 2011 Introduction to MongoDBSilicon Valley Code Camp: 2011 Introduction to MongoDB
Silicon Valley Code Camp: 2011 Introduction to MongoDBManish Pandit
 

More from Manish Pandit (20)

Disaster recovery - What, Why, and How
Disaster recovery - What, Why, and HowDisaster recovery - What, Why, and How
Disaster recovery - What, Why, and How
 
Serverless Architectures on AWS in practice - OSCON 2018
Serverless Architectures on AWS in practice - OSCON 2018Serverless Architectures on AWS in practice - OSCON 2018
Serverless Architectures on AWS in practice - OSCON 2018
 
Disaster Recovery and Reliability
Disaster Recovery and ReliabilityDisaster Recovery and Reliability
Disaster Recovery and Reliability
 
OAuth2 primer
OAuth2 primerOAuth2 primer
OAuth2 primer
 
AWS Primer and Quickstart
AWS Primer and QuickstartAWS Primer and Quickstart
AWS Primer and Quickstart
 
Securing your APIs with OAuth, OpenID, and OpenID Connect
Securing your APIs with OAuth, OpenID, and OpenID ConnectSecuring your APIs with OAuth, OpenID, and OpenID Connect
Securing your APIs with OAuth, OpenID, and OpenID Connect
 
Silicon Valley 2014 - API Antipatterns
Silicon Valley 2014 - API AntipatternsSilicon Valley 2014 - API Antipatterns
Silicon Valley 2014 - API Antipatterns
 
Scalabay - API Design Antipatterns
Scalabay - API Design AntipatternsScalabay - API Design Antipatterns
Scalabay - API Design Antipatterns
 
OSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at Netflix
OSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at NetflixOSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at Netflix
OSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at Netflix
 
API Design Antipatterns - APICon SF
API Design Antipatterns - APICon SFAPI Design Antipatterns - APICon SF
API Design Antipatterns - APICon SF
 
Motivation : it Matters
Motivation : it MattersMotivation : it Matters
Motivation : it Matters
 
Building Apis in Scala with Playframework2
Building Apis in Scala with Playframework2Building Apis in Scala with Playframework2
Building Apis in Scala with Playframework2
 
Scala at Netflix
Scala at NetflixScala at Netflix
Scala at Netflix
 
Introducing Scala to your Ruby/Java Shop : My experiences at IGN
Introducing Scala to your Ruby/Java Shop : My experiences at IGNIntroducing Scala to your Ruby/Java Shop : My experiences at IGN
Introducing Scala to your Ruby/Java Shop : My experiences at IGN
 
Evolving IGN’s New APIs with Scala
 Evolving IGN’s New APIs with Scala Evolving IGN’s New APIs with Scala
Evolving IGN’s New APIs with Scala
 
IGN's V3 API
IGN's V3 APIIGN's V3 API
IGN's V3 API
 
Java and the JVM
Java and the JVMJava and the JVM
Java and the JVM
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
Silicon Valley Code Camp 2011: Play! as you REST
Silicon Valley Code Camp 2011: Play! as you RESTSilicon Valley Code Camp 2011: Play! as you REST
Silicon Valley Code Camp 2011: Play! as you REST
 
Silicon Valley Code Camp: 2011 Introduction to MongoDB
Silicon Valley Code Camp: 2011 Introduction to MongoDBSilicon Valley Code Camp: 2011 Introduction to MongoDB
Silicon Valley Code Camp: 2011 Introduction to MongoDB
 

Recently uploaded

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 

Recently uploaded (20)

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 

AWS Lambda with Serverless Framework and Java

  • 1.
  • 2. About Manish Pandit Director of Platform Engineering @Marqeta Twitter : @lobster1234 Blog: lobster1234.github.io LinkedIn: in/mpandit
  • 3. Serverless Serverless is the finest grain abstraction in distributed computing 100% managed with zero infrastructure concerns Lowest cost compared to Servers and Containers (if designed correctly!)
  • 4. Why Serverless Ideal fit for microservices architectures - functions have limited, well defined scopes Pricing - you pay for what you use No need to worry about infrastructure
  • 5. AWS Lambda Function as a Service Simple Pricing Model - Memory * time Event Sources - DynamoDB, S3, API Gateway, Cloudwatch, SNS... Security via VPC and IAM Roles
  • 6. Serverless Framework Node.js based CLI Makes working with FaaS much, much easier Simple, YAML based configuration abstracts Cloudformation Supports many cloud providers - AWS, OpenWhisk, GCP, Azure Supports stages Popular, feature rich, well documented
  • 7.
  • 8. Install bash-3.2$ npm install serverless -g + serverless@1.23.0 bash-3.2$ serverless --version 1.23.0
  • 9. Configure AWS - Option 1 bash-3.2$ aws configure AWS Access Key ID [****************4MTA]: AWS Secret Access Key [****************g2uU]: Default region name [us-east-1]: Default output format [json]: bash-3.2$
  • 10. Configure AWS - Option 2 bash-3.2$ serverless config credentials --provider aws --key XXXX --secret YYY If you already have a default profile…. Serverless: Setting up AWS... Serverless: Failed! ~/.aws/credentials already has a "default" profile. Use the overwrite flag ("-o" or "--overwrite") to force the update
  • 11. Create a Project bash-3.2$ serverless create --template aws-java-maven Serverless: Generating boilerplate... Serverless: Successfully generated boilerplate for template: "aws-java-maven" Serverless: NOTE: Please update the "service" property in serverless.yml with your service name bash-3.2$
  • 12. The Project Structure bash-3.2$ tree . . ├── pom.xml ├── serverless.yml └── src └── main ├── java │ └── com │ └── serverless │ ├── ApiGatewayResponse.java │ ├── Handler.java │ └── Response.java └── resources └── log4j.properties 6 directories, 6 files
  • 13. serverless.yml service: aws-java-maven # NOTE: update this with your service name provider: name: aws runtime: java8 package: artifact: target/hello-dev.jar functions: hello: handler: com.serverless.Handler # The following are a few example events you can configure # NOTE: Please make sure to change your handler code to work with those events # Check the event documentation for details # events: # - http: # path: users/create # method: get
  • 14. Handler Class package com.serverless; import … public class Handler implements RequestHandler<Map<String, Object>, ApiGatewayResponse>
  • 15. handleRequest Method @Override public ApiGatewayResponse handleRequest(Map<String, Object> input, Context context) { BasicConfigurator.configure(); LOG.info("received: " + input); Response responseBody = new Response("Go Serverless v1.x! Your function executed successfully!", input); return ApiGatewayResponse.builder() .setStatusCode(200) .setObjectBody(responseBody) .setHeaders(Collections.singletonMap("X-Powered-By", "AWS Lambda & serverless")) .build(); }
  • 16. Build bash-3.2$ mvn clean install [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building hello dev [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ hello --- [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.666 s [INFO] Finished at: 2017-10-07T01:34:10-07:00 [INFO] Final Memory: 16M/214M [INFO] ------------------------------------------------------------------------
  • 17. Deploy bash-3.2$ serverless deploy Serverless: Packaging service... Serverless: Creating Stack... Serverless: Checking Stack create progress... Serverless: Stack create finished... Serverless: Uploading CloudFormation file to S3... Serverless: Uploading artifacts... Serverless: Validating template... Serverless: Updating Stack... Serverless: Checking Stack update progress... ............... Serverless: Stack update finished... Service Information service: aws-java-maven stage: dev region: us-east-1 stack: aws-java-maven-dev api keys: None endpoints: None functions: hello: aws-java-maven-dev-hello
  • 18. Invoke bash-3.2$ serverless invoke -f hello { "statusCode": 200, "body": "{"message":"Go Serverless v1.x! Your function executed successfully!","input":{}}", "headers": { "X-Powered-By": "AWS Lambda & serverless" }, "isBase64Encoded": false } bash-3.2$
  • 19. Execution 1.An event source generates an event, or a trigger 2.A new container is spun off or an existing one is reused to launch the runtime 3.The function (script if interpreted language, binary if compiled) is executed 4.The runtime exits
  • 20. Invoke Local bash-3.2$ serverless invoke local -f hello Serverless: In order to get human-readable output, please implement "toString()" method of your "ApiGatewayResponse" object. 0 [main] INFO com.serverless.Handler - received: {} com.serverless.ApiGatewayResponse@77cd7a0 bash-3.2$
  • 21. Using an HTTP Event Source service: aws-java-maven # NOTE: update this with your service name provider: name: aws runtime: java8 package: artifact: target/hello-dev.jar functions: hello: handler: com.serverless.Handler events: - http: path: /hello method: get
  • 22. Deploy with a new stage! bash-3.2$ serverless deploy --stage prod Serverless: Packaging service... Serverless: Creating Stack... Serverless: Checking Stack create progress… Serverless: Updating Stack... Serverless: Checking Stack update progress... Serverless: Stack update finished... Service Information service: aws-java-maven stage: prod region: us-east-1 stack: aws-java-maven-prod api keys: None endpoints: GET - https://f582xxq581.execute-api.us-east-1.amazonaws.com/prod/hello functions: hello: aws-java-maven-prod-hello
  • 23. Test bash-3.2$ curl https://f582xxq581.execute-api.us-east-1.amazonaws.com/prod/hello {"message":"Go Serverless v1.x! Your function executed successfully!","input":{"resource":"/hello","path":"/hello","httpMethod":"GET","headers":{"Accept":"*/*","Cl oudFront-Forwarded-Proto":"https","CloudFront-Is-Desktop-Viewer":"true","CloudFront-Is-Mobile- Viewer":"false","CloudFront-Is-SmartTV-Viewer":"false","CloudFront-Is-Tablet-Viewer":"false","CloudFront- Viewer-Country":"US","Host":"f582xxq581.execute-api.us-east-1.amazonaws.com","User- Agent":"curl/7.51.0","Via":"1.1 3cc911e7eb2df956e3f7c8f27c198a0b.cloudfront.net (CloudFront)","X-Amz-Cf- Id":"rngpB7WCzOt_XnMXzDc0Pv5i9Eq7_ZA1olb08W84xi5Of8Od4VvVVw==","X-Amzn-Trace-Id":"Root=1-59d895b4- 375b518e32e7a6866c80fa0a","X-Forwarded-For":"69.181.73.181, 205.251.214.68","X-Forwarded-Port":"443","X- Forwarded- Proto":"https"},"queryStringParameters":null,"pathParameters":null,"stageVariables":null,"requestContext":{" path":"/prod/hello","accountId":"xxxxxxxxxxxx","resourceId":"07sycy","stage":"prod","requestId":"cab13cdc- ab3c-11e7-b85c- 0fc68f7d77c1","identity":{"cognitoIdentityPoolId":null,"accountId":null,"cognitoIdentityId":null,"caller":nu ll,"apiKey":"","sourceIp":"69.181.73.181","accessKey":null,"cognitoAuthenticationType":null,"cognitoAuthenti cationProvider":null,"userArn":null,"userAgent":"curl/7.51.0","user":null},"resourcePath":"/hello","httpMeth od":"GET","apiId":"f582xxq581"},"body":null,"isBase64Encoded":false}} bash-3.2$
  • 24. Serverless Logs bash-3.2$ serverless logs -f hello START RequestId: 32c366cc-ab41-11e7-bcba-6f7680b04a52 Version: $LATEST 2017-10-07 09:23:38 <32c366cc-ab41-11e7-bcba-6f7680b04a52> INFO com.serverless.Handler:20 - received: {} 0 [main] INFO com.serverless.Handler - received: {} END RequestId: 32c366cc-ab41-11e7-bcba-6f7680b04a52 REPORT RequestId: 32c366cc-ab41-11e7-bcba-6f7680b04a52 Duration: 411.34 ms Billed Duration: 500 ms Memory Size: 1024 MB Max Memory Used: 63 MB START RequestId: e41254f3-ab41-11e7-ab1b-750906e00517 Version: $LATEST 2017-10-07 09:28:34 <e41254f3-ab41-11e7-ab1b-750906e00517> INFO com.serverless.Handler:20 - received: {} END RequestId: e41254f3-ab41-11e7-ab1b-750906e00517 REPORT RequestId: e41254f3-ab41-11e7-ab1b-750906e00517 Duration: 9.92 ms Billed Duration: 100 ms Memory Size: 1024 MB Max Memory Used: 63 MB
  • 25. Serverless Metrics bash-3.2$ serverless metrics -f hello Service wide metrics October 6, 2017 2:21 AM - October 7, 2017 2:21 AM Invocations: 4 Throttles: 0 Errors: 0 Duration (avg.): 206.84ms bash-3.2$
  • 26. Serverless Metrics w/ Stages bash-3.2$ serverless metrics --stage dev -f hello hello October 6, 2017 2:29 AM - October 7, 2017 2:29 AM Invocations: 8 Throttles: 0 Errors: 0 Duration (avg.): 120.89ms bash-3.2$ serverless metrics --stage prod -f hello hello October 6, 2017 2:29 AM - October 7, 2017 2:29 AM Invocations: 6 Throttles: 0 Errors: 0 Duration (avg.): 187.97ms
  • 27. Serverless Info bash-3.2$ serverless info Service Information service: aws-java-maven stage: dev region: us-east-1 stack: aws-java-maven-dev api keys: None endpoints: None functions: hello: aws-java-maven-dev-hello
  • 28. Serverless Info w/Stages bash-3.2$ serverless info --stage prod Service Information service: aws-java-maven stage: prod region: us-east-1 stack: aws-java-maven-prod api keys: None endpoints: GET - https://f582xxq581.execute-api.us-east-1.amazonaws.com/prod/hello functions: hello: aws-java-maven-prod-hello bash-3.2$
  • 29. Remove Stack bash-3.2$ serverless remove Serverless: Getting all objects in S3 bucket... Serverless: Removing objects in S3 bucket... Serverless: Removing Stack... Serverless: Checking Stack removal progress... .... Serverless: Stack removal finished… bash-3.2$
  • 30. Remove Stack w/Stages bash-3.2$ serverless remove --stage prod Serverless: Getting all objects in S3 bucket... Serverless: Removing objects in S3 bucket... Serverless: Removing Stack... Serverless: Checking Stack removal progress... ................ Serverless: Stack removal finished… bash-3.2$ curl https://f582xxq581.execute-api.us-east-1.amazonaws.com/prod/hello curl: (35) SSL peer handshake failed, the server most likely requires a client certificate to connect bash-3.2$
  • 31. Lambda Tips 1. Write your code in a way that it can be tested without an event source 2. Lambda cannot execute for longer than 5 minutes 3. Coordinating many Lambdas can be difficult, use AWS Step Functions 4. Do not persist anything on the disk - it may not be available 5. Be aware of cold start - JVM will take a while to start 6. Do not write lambdas for everything - if a service is high throughput, you’re better off with ECS or EC2 given the costs 7. Lambdas can be tied to VPCs and have IAM execution roles 8. Serverless supports API Gateway Proxy Integration by default - everything gets passed to the function
  • 32. Resources Serverless Framework - https://serverless.com AWS Lambda - https://aws.amazon.com/lambda My Tutorial - https://lobster1234.github.io/categories/serverless