nailing serverless application development€¦ · test locally test on dev cluster commit to repo...

34
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Sanath Kumar Ramesh Software Engineer, AWS Serverless Nailing Serverless Application Development @sanathkr_ @sanathkr

Upload: others

Post on 24-Jun-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Sanath Kumar Ramesh Software Engineer, AWS Serverless

Nailing Serverless Application Development

☁ 🔨

@sanathkr_ @sanathkr

Page 2: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

About Me

•  Obsessed about serverless developer tools since 2016 •  Built SAM, open sourced SAM implementation, and built SAM CLI •  Open source enthusiast •  Previously:

•  Full stack developer at startups •  Windows Kernel Engineer at Microsoft •  Designed multicore processors at grad school

•  To-be dad 👨‍👦

Sanath Kumar Ramesh, Software Engineer, AWS Serverless

@sanathkr_

@sanathkr

Page 3: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

No servers to provision or manage

Scales with usage

Never pay for idle Availability and fault tolerance built in

Serverless means…

Page 4: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Common Serverless use cases

Web Applications •  Static

websites

•  Complex web apps

•  Packages for Flask and Express

Data Processing

•  Real time

•  MapReduce

•  Batch

Chatbots •  Powering

chatbot logic

Backends •  Apps &

services

•  Mobile

•  IoT

</> </>

Amazon Alexa

•  Powering voice-enabled apps

•  Alexa Skills Kit

IT Automation

•  Policy engines

•  Extending AWS services

•  Infrastructure management

Page 5: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

SERVICES (ANYTHING)

Changes in data state

Requests to endpoints

Changes in resource state

EVENT SOURCE FUNCTION

Node.js Python Java C# Go

Serverless applications

Page 6: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

The broader community has also evolved

Page 7: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Nailing Application Development

Source: https://gph.is/2xMjVvf

Page 8: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Building Web Applications

Develop Build Test Locally

Test on dev cluster

Commit to Repo

Deploy to Prod

Building Serverless Applications

Page 9: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Development workflow

is no different #ServerlessIsEasy

Page 10: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Develop Build Test Locally

Test on dev cluster

Commit to Repo

Building a web app..

Non-Serverless Serverless

Deploy to Prod

Application Code

Infrastructure

Page 11: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

MEAN Stack (Mongo Express Node Angular)

Develop Build Test Locally

Test on dev cluster

Commit to Repo

Node: aws-serverless-express

Java: aws-serverless-java-container Python/Flask: Chalice Python/Django: Zappa

Building a web app..

Non-Serverless Serverless

Deploy to Prod

Application Code

MEAN stack + Compatibility Converter

Page 12: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Non-Serverless Serverless

MEAN Stack (Mongo Express Node Angular)

MEAN stack + New programming

model

Develop Build Test Locally

Test on dev cluster

Commit to Repo

Building a web app..

Deploy to Prod

Application Code

Page 13: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

MEAN Stack (Mongo Express Node Angular)

Develop Build Test Locally

Test on dev cluster

Commit to Repo

exports.handler = function(event, context) { // Function Handler response = app.run(event) callback(null, response) }

Building a web app..

Non-Serverless Serverless

Deploy to Prod

Application Code

MEAN stack + New programming

model

Immutable code Stateless

Event-driven

Page 14: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Focus on the business logic, use tools to help with serverless

#ServerlessIsEasy

Page 15: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Terraform

AWS CloudFormation

Terraform

AWS CloudFormation

AWS SAM Serverless Framework

Apex Sparta

Develop Build Test Locally

Test on dev cluster

Commit to Repo

Building a web app..

Non-Serverless Serverless

Deploy to Prod

Infrastructure

Page 16: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Meet SAM!

Page 17: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

From: https://github.com/awslabs/aws-serverless-samfarm/blob/master/api/saml.yaml

<-THIS BECOMES THIS->

AWS SAM Template

Page 18: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Open Source SAM Toolset

SAM Implementation github.com/awslabs/serverless-application-model

SAM CLI github.com/awslabs/aws-sam-cli

Page 19: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Serverless specific tool will help, but not a necessity

#ServerlessIsEasy

Page 20: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Code +

Manifest +

Build Tool =

Deployment Bundle

Develop Build Test Locally

Test on dev cluster

Commit to Repo

Building a web app..

Non-Serverless Serverless

Code +

Manifest +

Build Tool with Serverless Build Plugins

= Deployment Bundle (.zip file)

Deploy to Prod

Page 21: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Code +

Manifest +

Build Tool =

Deployment Bundle

Develop Build Test Locally

Test on dev cluster

Commit to Repo

Building a web app..

Non-Serverless Serverless

pom.xml

Deploy to Prod

Page 22: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Your build tool might already support serverless

#ServerlessIsEasy

Page 23: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Manually Run Application Locally

Unit Tests

Integration Tests

Develop Build Test Locally

Test on dev cluster

Commit to Repo

Building a web app..

Non-Serverless Serverless

Manually Run Application Locally

Unit Tests

Integration Tests

Deploy to Prod

Page 24: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Manually Run Application Locally

Tools: Node Webserver, Nginx,

Apache Webserver etc

Develop Build Test Locally

Test on dev cluster

Commit to Repo

Building a web app..

Non-Serverless Serverless

Manually Run Application Locally

with simulated cloud resources

Tools: SAM CLI, serverless-offline,

LocalStack

Deploy to Prod

Page 25: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Local testing is possible, a serverless tool just makes it

easier #ServerlessIsEasy

Page 26: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Create a dev cluster (usually one per team on

separate account)

Run Integration Tests

Develop Build Test Locally

Test on dev cluster

Commit to Repo

Building a web app..

Non-Serverless Serverless

Create a dev stack (one per developer on

separate account)

Run Integration Tests

Deploy to Prod

Page 27: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Develop Build Test Locally

Test on dev cluster

Commit to Repo

Building a web app..

Deploy to Prod

Page 28: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Develop Build Test Locally

Test on dev cluster

Commit to Repo

Building a web app..

Non-Serverless Serverless

Build ↓

Package ↓

Run Tests ↓

Beta, Gamma, Prod

Jenkins, AWS CodePipeline, AWS CodeBuild, CircleCI, etc

Deploy to Prod

$ sam deploy

Build ↓

Package ↓

Run Tests ↓

Beta, Gamma, Prod

Page 29: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Develop Build Test Locally

Test on dev cluster

Commit to Repo

Building a web app..

Non-Serverless Serverless

Canary or Blue/Green Deployments

Canary or Blue/Green Deployments

Deploy to Prod

sam.yaml

Page 30: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Develop Build Test Locally

Test on dev cluster

Commit to Repo

Building a web app..

Deploy to Prod

Page 31: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Your existing tools work just fine

Page 32: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

If you can build software,

you can build on serverless

#ServerlessIsEasy

Page 33: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Thank You 👨‍💻 Questions?

@sanathkr_

@sanathkr

[email protected]

Page 34: Nailing Serverless Application Development€¦ · Test Locally Test on dev cluster Commit to Repo Building a web app.. Non-Serverless Serverless Manually Run Application Locally

© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Serverless Application

LogicasConfigura.on(StepFunc.ons,APIGWetc)

Sta.cConfigura.on(S3,SQS,IAM)

Code(Java,Python,JSetc)