aws serverless apps...aws serverless apps introduction page 02 why use it? what is it? demo app what...

148
aws serverless apps

Upload: others

Post on 30-Dec-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

aws serverless apps

Page 2: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

aws serverless appsintroduction

page02

Why useit?

What isit?

Demoapp

Page 3: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

what is serverless?

Page 4: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

parts ofserverless apps

page04

All of the dynamic behavior is provided by JavaScript running

in the user’s browser. The JavaScript itself is static,

though.

JavaScript

Data is written to and retrieved from an API hosted by a cloud

provider. In our case, that provider is AWS API Gateway.

API Markup

Finally, the HTML markup ties the whole thing together. The

markup is static and cacheable, so the initial page

load for your users is fast.

Page 5: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

how do they work together?

page05

a user comes to your site and loads static HTML, CSS, and JavaScript

static parts of the page are in HTML while dynamic parts of the page areadded by JavaScript

JavaScript retrieve dynamic data from the API

JavaScript writes data to the API

JavaScript handles some aspects of navigation

Page 6: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

maybe apicture?

page06

λ

S3CloudFront

API GatewayLambda

Other CloudServices

DynamoDB

Cognito

Page 7: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

why go serverless?

Page 8: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

why not just run a server?

page08

server management (patches, monitoring, hardware failures, etc.)

servers can be cheap, but scaling gets expensive really fast

you don’t pay for processing time you don’t use

easier to split up development between front-end and back-end

Page 9: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

aren’t s3, lambda, etc. servers?

page09

yes, but…

they’re not yours

you’re not the only one on them

amazon has people with pagers to keep them working

Page 10: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

good and bad use cases

page010

good:dynamic applications with lots of user interactionmost of the content in the UI is specific to the user

bad:large applications with lots of data that would have to be loadedanything where the time to load markup, JS, and data would create a very slow UI

Page 11: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

demoapp

Page 12: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the
Page 13: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

getting started

Page 14: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

getting started

page014

Create siteon S3

Sign upfor AWS

Viewsite

Page 15: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

sign up for AWS

page015

Sign up at: https://portal.aws.amazon.com/billing/signup

Free tier information: https://aws.amazon.com/free/

Services we will use:- S3- API Gateway- Lambda- DynamoDB- Cognito- CloudFront- IAM- CloudWatch

Page 16: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the
Page 17: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

understanding S3

Page 18: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

S3 basics

page018

S3 = Simple Storage Service

Key-Blob store

Eventually consistent

Extremely durable

Page 19: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

S3 is not…

page019

a file system

Page 20: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

one more thing…

page020

AWS policies define access control for:- users- other AWS services- resources

Page 21: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

make life easier

page021

{

"Version": "2012-10-17",

"Id": "Policy1497053408897",

"Statement": [

{

"Sid": "Stmt1497053406813",

"Effect": "Allow",

"Principal": "*",

"Action": "s3:GetObject",

"Resource": "arn:aws:s3:::<your bucket name>/*"

}

]

}

Page 22: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the
Page 23: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

JavaScript syntax

Page 24: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

JavaScript syntax

page024

JavaScript is a C-style language in most respects:- control structures- variable naming rules- accessing member values of an object (e.g. foo.bar)

JavaScript is not always C-like:- variables have no type- functions are objects- ===

Page 25: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

JavaScript syntaxoddities

page025

== - equivalent values=== - equal values of the same type

Example:1 == “1” is true1 === “1” is false

Page 26: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

JavaScript syntaxoddities

page026

null vs. undefined

null – an object of type null

undefined – a value of type undefined

Page 27: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

JavaScript declarations

page027

var foo = ‘bar’;var baz = “bar”;

var object = {p1: 1,p2: 2,‘this needs to be quoted’: ‘Hello, world!’

};

object.p1 is the same as object[‘p1’]

Page 28: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

JQuery

page028

$ is JQuery

$.get()$.post()

$(‘.class’) – CSS class selector$(‘#id’) – ID selector$(‘div’) – tag selector

Page 29: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

Useful references

page029

JavaScript: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference

JQuery: http://api.jquery.com/

Page 30: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the
Page 31: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

JavaScript parallelism

Page 32: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

classic parallelism

page032

Scenario:You need to make two independent HTTP requests as fast as possible

Solution:Create two threads to make the requestsUse some sort of synchronization to determine when they’re doneKeep doing what you need to do

Page 33: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

is that bad?

page033

No, it’s perfectly normal!

Good:Assuming you have enough processors and memory, you can be as efficient as possible.The threads are not lies. They’re real, and you can make them do what you want.It’s very powerful.

Bad:It’s very complicated.Most people do synchronization poorly.There are entire books on the subject of proper multithreading.

Page 34: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

JavaScript threading

page034

JavaScript was made to run in the browser.The DOM can only be manipulated in a single thread.

Since JavaScript was originally intended to manipulate the DOM, there’s no reason to introduce multithreading.

Page 35: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

what about AJAX?

page035

Exactly!

Browsers already do a bunch of HTTP requests in parallel!

Page 36: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

JavaScript is single-threaded!

page036

…-ish?

All your code runs on a single thread.

Browsers and Node.js manage other threadsthat do things for you.

Page 37: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

callbacks

page037

Page 38: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

effects of event loop

page038

Dependent calls require a lot of functions

Bookkeeping is everything for parallel behaviors

No synchronization

Page 39: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

that’s it!

Page 40: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the
Page 41: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

exercise #1

page041

a) Add a message from “Student” to Frank

b) Add a new conversation

Page 42: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the
Page 43: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

exercise solution

Page 44: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

exercise #1 solution

page044

2.json:

{

"id": "2",

"participants": ["Student", "Frank"],

"messages": [

{

"sender": "Frank",

"time": 1512246342159,

"message": "This is Frank. I'm also sending you a message."

},

{

"sender": "Student",

"time": 1512247342159,

"message": "Hello, Frank!"

}

]

}

Page 45: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

exercise #1 solution

page045

conversations.json:

[

{

"participants": ["Student", "Brian"],

"id": "1"

},

{

"participants": ["Student", "Frank"],

"id": "2"

},

{

"participants": ["Student", "Alice"],

"id": "hello-world"

}

]

Page 46: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

exercise #1 solution

page046

hello-world.json

{

"id": "hello-world",

"participants": ["Student", "Alice"],

"messages": [

{

"sender": "Alice",

"time": 1512246299194,

"message": "I'm Alice. I usually talk to Bob."

}

]

}

Page 47: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the
Page 48: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

λ

Page 49: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

what is lambda?

page049

Function running on AWS

Options:- Java- Python- JavaScript (Node.js)

Page 50: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

what makes lambda serverless?

page050

Feature Lambda EC2

Time to spin up milliseconds seconds to minutes

Billing increments 100ms 1s

Configuration function operating system

Scaling unit parallel function executions

instances

Maintenance AWS AWS and you

Page 51: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the
Page 52: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

IAM and policies

Page 53: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

IAM? i am what?

page053

IAM – Identity and Access Management

users/groupsrolespoliciesidentity providersuser account settingsencryption keys

Page 54: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

where do we needroles?

page054

λ

S3CloudFront

API GatewayLambda

Other CloudServices

DynamoDB

Cognito

Page 55: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the
Page 56: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

lambda triggers

Page 57: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

so many options

page057

API GatewayAWS IoTAlexa SkillsAlexa Smart HomeCloudWatch EventsCloudWatch LogsCodeCommitCognito SyncDynamoDBKinesisS3SNS

Page 58: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

but wait…there’s more!

page058

Lambda APICloudFront

Page 59: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

api gateway

page059

λ λ

proxy mapping

Page 60: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the
Page 61: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

cors

Page 62: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

cors?

page062

cross-origin resource sharing

Page 63: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

long ago, on the internet

page063

websitefoo.com

browser

load this image from bar.com in an <img> tag?

sure

load this JS from baz.com in a <script> tag?

sure

make an XMLHttpRequest to baz.com?

NO!!!

Page 64: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

someone got clever

page064

websitefoo.com

browser

load this JS from baz.com in a <script> tag?

sure

here’s a new <script> tag to load from baz.com

sure

Page 65: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

new standard: cors

page065

websitefoo.com

browser

load this JS from baz.com in a <script> tag?

sure

make an XMLHttpRequest to baz.com?

maybe?

Page 66: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

maybe?

page066

browser baz.com

OPTIONS /apiOriginAccess-Control-Request-MethodAccess-Control-Request-Headers

Access-Control-Allow-OriginAccess-Control-Allow-MethodsAccess-Control-Allow-Headers

Access-Control-Max-Age[Access-Control-Allow-Credentials]

Page 67: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

then what?

page067

browser baz.com

POST /apiOrigin

Access-Control-Allow-Origin

Page 68: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the
Page 69: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

dynamodb

Page 70: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

nosql

page070

“non SQL” or “Not only SQL”

basically a key-value storage system

typically not ACID

extremely scalable

Page 71: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

dynamodb tables

page071

hash key sort key data

Page 72: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

types of attributes

page072

name type

B and BS binary (and set)

BOOL boolean

L list

M map

N and NS number (and set)

NULL null

S and SS string (and set)

Page 73: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

retrieving items

page073

get item

query

scan

full key item

partial key results

filter results

Page 74: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

a note on pagination

page074

partial key results

Page 75: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

provisioned throughput

page075

1 read unit = 1 consistent read up to 4KB per second 1 read unit = 2 eventually consistent reads up to 4KB per second

1 write unit = 1 write up to 1KB per second

Page 76: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

that’s the basics

page076

table structuresdata typeshow to get itemspaginationprovisioned capacity

Page 77: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the
Page 78: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

dynamodb vs. s3

Page 79: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

blobs vs. values

page079

001010101001010101010101010101010101010101010010101010101010000000011010101

key value

key 1 stuff

key 2 other stuff

Page 80: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

limits

page080

limit S3 DynamoDB

record size 5TB 400KB

request rate basically unlimited 80k capacity units in Virginia, 20k everywhere else

total size unlimited unlimited

Page 81: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

consistency!

Page 82: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the
Page 83: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

a few things to try

page083

1. Make the Lambda function reject unsupported HTTP methodsA. Create some new test configurations for these cases

2. Remove S3 access for your Lambda function

Page 84: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the
Page 85: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

λ proxy pain

Page 86: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

wait…what?

page086

poorly-documented event object

having to worry about the details of HTTP requests

input comes from multiple places

over 200 lines of JavaScript to manage

Page 87: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

is there anything good about it?

page087

it’s easy

Lambda startup cost can be lower

less management

Page 88: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

basically…

page088

monolith

Page 89: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

the power ofapi gateway

each resource-method combination can be its own function with its own lifecycle

each function can have simple, tailored input

ensuring API compatibility can occur without code

Page 90: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

the plan

page090

resources and methods

api models

request and response flows

Page 91: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the
Page 92: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

resources and methods

Page 93: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

http basics

page093

HTTP/1.1 200 OK

Date: Thu, 11 Jan 2018 03:46:43 GMT

Expires: -1

Cache-Control: private, max-age=0

Content-Type: text/html; charset=ISO-8859-1

P3P: CP="This is not a P3P policy! See

g.co/p3phelp for more info.“

Server: gws

X-XSS-Protection: 1; mode=block

X-Frame-Options: SAMEORIGIN

Set-Cookie: …

Accept-Ranges: none

Vary: Accept-Encoding

Transfer-Encoding: chunked

GET / HTTP/1.1

User-Agent: curl/7.38.0

Host: www.google.com

Accept: */*

Page 94: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

methods

page094

GETHEAD

Read

POSTPUT

PATCH

Write Other

DELETEOPTIONS

Page 95: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

status codes

page095

family meaning

2xx success

3xx redirect

4xx client error

5xx server error

Page 96: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

parts of a URL

page096

http://www.foo.com/something?search=some+keyword#results

scheme

host

resource

query string

fragment

Page 97: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

request data

resourcemethodquery stringheaders (includes cookies)body (POST, PUT, PATCH)

Page 98: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

response data

status codeheaders (includes cookies)body

Page 99: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

what goes where?

page099

what? request response

resource what data or behavior is required

N/A

query string filtering and subset information

N/A

headers processing directives processing directives

body input data output data

Page 100: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

resources

page0100

Some resources are one of a kind even though they may

change based on user, time, etc.

Example: /conversations

Fully-defined Parameterized

Other resources contain data in the URL. There can be some

large number of resources that follow a pattern.

Example: /conversations/{id}

Page 101: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

resources have methods

page0101

Page 102: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the
Page 103: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

models

Page 104: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

request data

resourcemethodquery stringheaders (includes cookies)body (POST, PUT, PATCH)

Page 105: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

response data

status codeheaders (includes cookies)body

Page 106: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

models in apigateway

page0106

Page 107: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

defining models

page0107

JSON schema

each model in its own schema document

Page 108: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

json schema primitive types

page0108

type notes

null

boolean

object properties defined by “properties”

array elements defined by “items”

number

string

Page 109: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

examples

page0109

{

"type": "string"

}

{

"type": "array",

"items": {

"type": "object",

"properties": {

"id": {

"type": "string"

},

"participants": {

"type": "array",

"items": {

"type": "string"

}

},

"last": {

"type": "number",

"format": "utc-millisec"

}

}

}

}

Page 110: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the
Page 111: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

request flow

Page 112: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

overall flow

Page 113: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

request flow

page0113

authorizationvalidationcachinginput:- request path variables- query string parameters- request headers- request body

integration typeremapping of input

Page 114: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

authorization

page0114

AWS IAMAPI keyCognitoCustom

Page 115: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

integration

page0115

Page 116: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

lambda and mock

page0116

Mock

Always returns the same thingSupports proxy and non-proxy modes

Just calls a Lambda function

Lambda

λ

Page 117: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

http, aws, and vpc

page0117

all very similar

default is effectively passthrough

remapping can be done on almost anything

also, proxy mode

Page 118: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

input mapping

page0118

URL

headers

body

APIGate-way

λ

Page 119: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

input mapping

page0119

URL

headers

body

APIGate-way

λ

Page 120: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

response flow

Page 121: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

overall flow

Page 122: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

response flow

page0122

response definitions response mappingstatus code mapping

Page 123: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the
Page 124: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

stages

Page 125: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

what do they do?

snapshots of the API

public URL

operational settings

generated clients

generated swagger

Canary

Page 126: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

operational stuff

page0126

CloudFront-based caching

Caching

Request rate with bursting

Throttling Variables

Define variables for the stage

Page 127: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

sdk generationand swagger

page0127

Page 128: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

canary

page0128

APIGateway

Page 129: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

canary

page0129

APIGateway

50%

50%

Page 130: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

canary

page0130

APIGateway

0%

100%

Page 131: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the
Page 132: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

cognito

Page 133: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

services

page0133

Your own usernames, passwords, attributes, etc.

User Pools

Use SSO (Google, Facebook, Amazon, etc.)

Federated Sync

Synchronize data across devices

Page 134: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

user pools

page0134

Page 135: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

user information

page0135

List and manage users and/or groups and see details

users and groups attributes

Define what a user looks like

Page 136: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

security

page0136

Password length, special characters, etc.

policies

MFAphone and email verification

mfa and verifications advanced

Intelligent security features

Page 137: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

customization

page0137

Customize messages to users

message

Lambda functions for user lifecycle

triggers devices

Remember devices

Page 138: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

other

page0138

Define clients of the user pool

app clients

AWS tagging

tags analytics

What are your users doing?

Page 139: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

oauth 2.0

page0139

Page 140: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

federation?

page0140

Page 141: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

federation!and sync!

page0141

Page 142: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the
Page 143: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

cloudfront

Page 144: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

what is a cdn?

Page 145: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

origin vs. behavior

page0145

Where the content comes from

S3, Web Server, API

origin behavior

How to serve and cache a set of URIs

Page 146: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

caching

page0146

CDN

Page 147: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

invalidation

page0147

CDN

invalidation

Page 148: aws serverless apps...aws serverless apps introduction page 02 Why use it? What is it? Demo app what is serverless? sundog-education.com parts of serverless apps page 04 All of the

sundog-education.com

other stuff

page0148

compression

Node.js at the edge