How AWS Builds Serverless Services Using Serverless - Introducing Amazon EventBridge

A presentation at Serverless Days London in July 2019 in London, UK by Chris Munns

Slide 1

Slide 1

How AWS builds Serverless services using Serverless Chris Munns Principal Developer Advocate AWS Serverless © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 2

Slide 2

About me: Chris Munns - munns@amazon.com, @chrismunns • Principal Developer Advocate - Serverless • New Yorker • Previously: • AWS Business Development Manager – DevOps, July ’15 - Feb ‘17 • AWS Solutions Architect Nov, 2011- Dec 2014 • Formerly on operations teams @Etsy and @Meetup • Little time at a hedge fund, Xerox and a few other startups • Rochester Institute of Technology: Applied Networking and Systems Administration ’05 • Internet infrastructure geek © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 3

Slide 3

Why are we here today? © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. https://secure.flickr.com/photos/mgifford/4525333972

Slide 4

Slide 4

How AWS builds Serverless services using Serverless © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 5

Slide 5

How AWS builds Serverless services using Serverless © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 6

Slide 6

Instead A focus on events © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 7

Slide 7

Going back to Amazon © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Photo by Chris Munns

Slide 8

Slide 8

Development transformation at Amazon: 1994-2001 monolithic architecture + hierarchical organization © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 2002+ decoupled services + 2 pizza teams

Slide 9

Slide 9

Two-pizza teams Full ownership Full accountability Aligned incen:ves “DevOps” © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 10

Slide 10

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

Slide 11

Slide 11

At first there was Amazon S3 © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 12

Slide 12

At first there was Amazon S3* © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 13

Slide 13

At first there was Amazon S3* *OK so Amazon SQS was the first service announced, S3 was the first to GA. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 14

Slide 14

Amazon S3 at launch: © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 15

Slide 15

Amazon S3 today: © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 16

Slide 16

I have a bucket Amazon Simple Storage Service (S3) © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 2006-2014

Slide 17

Slide 17

Objects can go in Object Object Object Object Object Amazon Simple Storage Service (S3) Object Object Object Object Object Object © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 2006-2014

Slide 18

Slide 18

But then…. Object Object Object Object Object Amazon Simple Storage Service (S3) Object Object Object Object Object Object © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 2006-2014

Slide 19

Slide 19

But then what happens from here? Object Object Object Object Object Amazon Simple Storage Service (S3) Object Object Object Object Object Object © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 2006-2014 ?

Slide 20

Slide 20

Workflow for S3 stored objects 2006-2014 There were two main ways of working with data in S3 in this time: • Performing List calls, acting. Client • Parallel client calls to ”notify” some system that objects were stored, polling that system, acting. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Bucket with objects Amazon Simple Queue Service Amazon EC2 Instances

Slide 21

Slide 21

In 2013 AWS Announced Amazon Kinesis Client Client Client Client Amazon Kinesis Client Client Client https://aws.amazon.com/about-aws/whats-new/2013/11/14/introducing-amazon-kinesis/ © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 22

Slide 22

In 2013 AWS Announced Amazon Kinesis Client Client Client Client Amazon Kinesis Client Client Client ? https://aws.amazon.com/about-aws/whats-new/2013/11/14/introducing-amazon-kinesis/ © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 23

Slide 23

In 2013 AWS Announced Amazon Kinesis Client Amazon DynamoDB for KCL Checkpoints Client Client Client Amazon Kinesis Client Amazon EC2 Instances running the Kinesis Client Library Client Client https://aws.amazon.com/about-aws/whats-new/2013/11/14/introducing-amazon-kinesis/ © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 24

Slide 24

And then came AWS Lambda in Nov 2014 © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 25

Slide 25

Amazon S3 + AWS Lambda Object Object Object Object Object Amazon Simple Storage Service (S3) Object Object Object Object Object Object © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 26

Slide 26

Amazon Kinesis + AWS Lambda Client Client Client Client Client Client Client © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Kinesis

Slide 27

Slide 27

AWS Lambda ❤ Events Events event [i-’vent] noun A signal that a system’s state has changed. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 28

Slide 28

AWS Lambda ❤ Events Events Objects placed in an S3 bucket generates an event. Data being put into Kinesis is an event. Messages placed in Amazon SNS is an event. And so on and so on. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 29

Slide 29

And then Amazon API Gateway launched in July 2015 Amazon API Gateway © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 30

Slide 30

And then Amazon API Gateway launched in July 2015 !HAPPY 4TH BIRTHDAY ! API GATEWAY!!! Amazon API Gateway © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 31

Slide 31

Amazon API Gateway + AWS Lambda Client Client Client Client Client Amazon API Gateway Client Client © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 32

Slide 32

Amazon API Gateway + AWS Lambda Client Client Client Client Again, Events! Client Amazon API Gateway Client Client © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 33

Slide 33

APIs are the front door of microservices © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Photo by chris,an koch on Unsplash

Slide 34

Slide 34

But not every microservice needs to be API based… © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 35

Slide 35

And even fewer microservices need to be synchronous… © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 36

Slide 36

Amazon S3 today: I P A e r a e s e h t f o m l l e a h t t f o No y n a m , s d u e o n o bas r h c n y s t o n e ar © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 37

Slide 37

Synchronous APIs POST /order Client © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 201 Order service

Slide 38

Slide 38

Synchronous APIs POST /order Order service Client POST /order retry after failure Client © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 201 Order service

Slide 39

Slide 39

Synchronous APIs POST /order Client 201 © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. POST /invoice Order service 201 Invoice service

Slide 40

Slide 40

Synchronous APIs POST /order Client 201 © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. POST /invoice Order service 201 Invoice service

Slide 41

Slide 41

Synchronous APIs POST /order POST /invoice Who own’s the Order retry? For how long? Invoice service service 201 the client ever know? Etc.. Client Does201 This effectively creates a “tight coupling” where failures become harder to recover from © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 42

Slide 42

Over time though our architecture evolves © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 43

Slide 43

Architecture v2 © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 44

Slide 44

Long-term architecture © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 45

Slide 45

Long-term architecture What does failure recovery look like for this? © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 46

Slide 46

Sadness. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Photo by Justin Veenema on Unsplash

Slide 47

Slide 47

Async to the rescue! © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Photo by Andrew Yardley on Unsplash

Slide 48

Slide 48

Events are asynchronous Client Service A Service B Client Service A Service B Synchronous Asynchronous Commands Events © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 49

Slide 49

Asynchronous APIs POST /order Client 201 POST /invoice Order service Get /invoice Client 200 © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Invoice service Invoice service

Slide 50

Slide 50

What do we do with these arrows? Order service © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. An order was created!

Slide 51

Slide 51

Amazon SNS Data 1. Data published to a topic Simple, flexible, fully managed publish/subscribe messaging and mobile push notification service for high throughput, highly reliable message delivery Messages are published to a Topic SNS Topic 2. Lambda function(s) invoked Lambda function Lambda function © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Topics can have multiple subscribers (fanout) Messages can be filtered and only sent to certain subscribers Asynchronous

Slide 52

Slide 52

Event fanout with Amazon SNS Order service An order was created! SNS © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 53

Slide 53

At some point we run into new challenges © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 54

Slide 54

Event fanout with Amazon SNS Order service An order was created! SNS © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 55

Slide 55

At some point the flow of events might need to become more than unidirectional Order service SNS © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 56

Slide 56

At some point the flow of events might need to become more than unidirectional What if we need to ”update” all the other services of a status change on an event that was broadcast to several already? • • ”Credit card failed payment” “Inventory issue” What if that update only needs to go to some select number of other processors of that event? • • Marketing campaign tracker doesn’t care that an order failed, just that new ones come in Inventory manager doesn’t care about failed credit card charges How do we avoid re-coupling the system? • A mass of deciated SNS topics per workflow? How do we make it so that the system can flexibly grow without modifications to every other component? Ugh © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 57

Slide 57

Sadness. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Photo by Justin Veenema on Unsplash

Slide 58

Slide 58

What if events were observable, not directed? © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 59

Slide 59

What if events were observable, not directed? Joe, please create an invoice. Directed Commands © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Ok, here it is

Slide 60

Slide 60

What if events were observable, not directed? I don’t care about this Joe, please create an invoice. Customer X just ordered a widget Ok, here it is I’ll add that to the sales report Directed Observable Commands Events © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. I’ll send an invoice

Slide 61

Slide 61

Sharing events with event routers Abstracts producers and consumers © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Selects and filters events

Slide 62

Slide 62

Event routers in AWS AWS Service Topics Amazon Simple Notification Service © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Characteristics Lambda/SQS/HTTP targets Nearly unlimited subscriptions Filter on event metadata

Slide 63

Slide 63

NEW!!! • Removes friction of writing “point-to-point integrations” Amazon EventBridge Serverless event bus for ingesting and processing data across AWS services and SaaS applications © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. • Fully managed, pay-as-you-go • Works across dozens of AWS and SaaS applications • Provides simple programming model

Slide 64

Slide 64

NEW!!! • 90+ AWS Services as sources Amazon EventBridge • 17 AWS Services as targets • 1$ per 1 Million events put in to a bus • No additional cost for delivery to targets Serverless event bus for ingesting and processing data across AWS services and SaaS applications © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 65

Slide 65

Amazon EventBridge • Built on the same technology as CloudWatch Events • Durably stores messages and retries failed connections to targets (for up to 24 hours) • Secured by AWS Identity and Access Management (IAM) • Event payload is JSON based, no dictated schema Amazon • Events Put in via single API call from AWS-SDKs or EventBridge via 3rd party partner SaaS providers © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 66

Slide 66

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

Slide 67

Slide 67

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

Slide 68

Slide 68

Event routers in AWS AWS Service Topics Event buses Amazon Simple Notification Service Amazon EventBridge © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Characteristics Lambda/SQS/HTTP targets Nearly unlimited subscriptions Filter on event metadata 19 AWS targets Native SaaS event sources Metadata and payload routing

Slide 69

Slide 69

Amazon EventBridge Event Buses Event Sources Targets AWS Lambda Default event bus Amazon Kinesis Custom event bus AWS Step Functions Event source SaaS event bus Rules Additional targets © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 70

Slide 70

Amazon EventBridge Event sources AWS Lambda Default event bus Amazon Kinesis Custom event bus AWS Step Functions Event source SaaS event bus Rules Additional targets © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 71

Slide 71

Amazon EventBridge Example put event code (node.js) Event sources (cont) var AWS = require(‘aws-sdk’); cwevents.putEvents(params, function(err, data) { AWS.config.update({region: ‘REGION’}); if (err) { console.log(“Error”, err); AWS Lambda // Create CloudWatchEvents service object Default event bus } else { var cwevents = new AWS.CloudWatchEvents({apiVersion: ‘2015-10console.log(“Success”, data.Entries); 07’}); Amazon Kinesis } }); var params = { Custom event bus Entries: [ { AWS Step Functions “detail-type”: “Ticket Created”, Event “source”: “aws.partner/example.com/123”, source SaaS event bus Rules “detail”: { “ticketId”: ”987654321”, “department”: “billing”, “creator”: “user12345” … }}]}; © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Additional targets

Slide 72

Slide 72

Amazon EventBridge AWS Lambda Default event bus Amazon Kinesis Custom event bus AWS Step Functions Event source SaaS event bus Rules Additional targets © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 73

Slide 73

Amazon EventBridge Event buses AWS Lambda Default event bus Amazon Kinesis Custom event bus AWS Step Functions Event source SaaS event bus Rules Additional targets © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 74

Slide 74

Amazon EventBridge AWS Lambda Default event bus Amazon Kinesis Custom event bus AWS Step Functions Event source SaaS event bus Rules Additional targets © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 75

Slide 75

Amazon EventBridge Example event: { “detail-type”: “Ticket Created”, “source”: “aws.partner/example.com/123”, AWS services “detail”: { “ticketId”: ”987654321”, AWS Lambda Default event bus Amazon Kinesis “department”: “billing”, Custom events Custom event bus “creator”: “user12345” … } SaaS apps AWS Step Functions Event source } SaaS event bus Rules Additional targets © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 76

Slide 76

Amazon EventBridge Example event: Example rule: { { “source”: [“aws.partner/example.com/123”] AWS Lambda “detail-type”: “Ticket Created”, “source”: “aws.partner/example.com/123”, AWS services “detail”: { “ticketId”: ”987654321”, Default event bus } Amazon Kinesis “department”: “billing”, Custom events Custom event bus “creator”: “user12345” … } SaaS apps AWS Step Functions Event source } SaaS event bus Rules Additional targets © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 77

Slide 77

Amazon EventBridge Example event: Example rule: { { “detail”: { “detail-type”: “Ticket Created”, “source”: “aws.partner/example.com/123”, AWS services “detail”: { “ticketId”: ”987654321”, “department”: [“billing”, “fulfillment”] Default event bus } Amazon Kinesis } “department”: “billing”, Custom events Custom event bus “creator”: “user12345” … } SaaS apps AWS Lambda AWS Step Functions Event source } SaaS event bus Rules Additional targets © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 78

Slide 78

Amazon EventBridge Example event: Example rule: { { “detail-type”: [“Ticket Resolved”] AWS Lambda “detail-type”: “Ticket Created”, “source”: “aws.partner/example.com/123”, AWS services “detail”: { “ticketId”: ”987654321”, Default event bus } Amazon Kinesis “department”: “billing”, Custom events Custom event bus “creator”: “user12345” … } SaaS apps AWS Step Functions Event source } SaaS event bus Rules Additional targets © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 79

Slide 79

Amazon EventBridge Targets AWS Lambda Default event bus Amazon Kinesis Custom event bus AWS Step Functions Event source SaaS event bus Rules Additional targets © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 80

Slide 80

EventBridge Integration Partners © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 81

Slide 81

Common use cases Take action SaaS application Amazon EventBridge AWS Lambda SaaS application Amazon EventBridge AWS Step Functions Applications and resources Run workflows Apply intelligence Amazon Comprehend SaaS application Amazon EventBridge AWS Lambda Amazon SageMaker © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 82

Slide 82

Common use cases Audit and analyze SaaS application Amazon EventBridge Amazon Kinesis Data Firehose Amazon S3 AWS Lambda Amazon DynanmoDB fetch Synchronize data SaaS application © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon EventBridge Amazon Athena

Slide 83

Slide 83

Order service SNS © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 84

Slide 84

Events with Amazon EventBridge Order service Amazon EventBridge © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 85

Slide 85

Events with Amazon EventBridge • Order service Amazon EventBridge © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. • Your services can both produce messages onto the bus and consume just the messages they need from the bus Services don’t need to know about each other, just about the bus.

Slide 86

Slide 86

aws.amazon.com/eventbridge © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Slide 87

Slide 87

Chris Munns munns@amazon.com @chrismunns © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. https://www.flickr.com/photos/theredproject/3302110152/

Slide 88

Slide 88

? © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. https://secure.flickr.com/photos/dullhunk/202872717/