an introduction to microservices with the serverless framework · @fmc_sea an introduction to...

Post on 15-Jul-2020

13 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

An Introduction to Microservices with the Serverless Framework

Fernando Medina CoreySolutions ArchitectServerless Inc.

@fmc_sea

What are we doing?

@fmc_sea An Introduction to Microservices with the Serverless Framework �3

@fmc_sea An Introduction to Microservices with the Serverless Framework �4

Our Goals

Let’s get our environment ready

@fmc_sea An Introduction to Microservices with the Serverless Framework �5

Create an AWS Account

@fmc_sea An Introduction to Microservices with the Serverless Framework �6

https://aws.amazon.com/free

Install the AWS CLI

@fmc_sea An Introduction to Microservices with the Serverless Framework �7

https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html

(This assumes you have Python3 installed)

Configure the AWS CLI@fmc_sea An Introduction to Microservices with the Serverless Framework �8

https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html

Install the Serverless Framework

@fmc_sea An Introduction to Microservices with the Serverless Framework �9

https://serverless.com/framework/docs/getting-started/

Mac/Linux Windows

Install the Serverless Framework

@fmc_sea An Introduction to Microservices with the Serverless Framework �10

https://serverless.com/framework/docs/getting-started/

(With npm)

Clone the Project

@fmc_sea An Introduction to Microservices with the Serverless Framework �11

https://github.com/fernando-mc/serverless-devweek2020

Develop@fmc_sea An Introduction to Microservices with the Serverless Framework �12

What are we developing?

@fmc_sea An Introduction to Microservices with the Serverless Framework �13

@fmc_sea An Introduction to Microservices with the Serverless Framework �14

@fmc_sea An Introduction to Microservices with the Serverless Framework �15

How does it work?

@fmc_sea An Introduction to Microservices with the Serverless Framework �16

@fmc_sea An Introduction to Microservices with the Serverless Framework �17

@fmc_sea An Introduction to Microservices with the Serverless Framework �18

@fmc_sea An Introduction to Microservices with the Serverless Framework �19

@fmc_sea An Introduction to Microservices with the Serverless Framework �20

@fmc_sea An Introduction to Microservices with the Serverless Framework �21

What’s the code look like?

@fmc_sea An Introduction to Microservices with the Serverless Framework �22

What’s the code look like?

@fmc_sea An Introduction to Microservices with the Serverless Framework �23

generate_code.py

1. Phone number as input2. (re)generates verification code3. Sends the code to the number

@fmc_sea An Introduction to Microservices with the Serverless Framework �24

get_votes.py

1. Gets vote counts for all songs2. Returns them to the frontend

@fmc_sea An Introduction to Microservices with the Serverless Framework �25

vote.py

1. Verified phone number/code 2. Sets the code as used3. Increments a vote counter4. Returns the new vote count

@fmc_sea An Introduction to Microservices with the Serverless Framework �26

app.js

1. Handles interacting with the API2. Updates vote counts in the UI3. Provides helper text for the user

@fmc_sea An Introduction to Microservices with the Serverless Framework �27

index.html

1. Snazzy Spotify embeds!2. Pretty Semantic UI buttons!3. Cool vote counters!

@fmc_sea An Introduction to Microservices with the Serverless Framework �28

serverless.yml

1. Creates Lambda Functions2. Creates API Gateway Endpoints3. Creates our DynamoDB table4. Sets the service’s permissions

@fmc_sea An Introduction to Microservices with the Serverless Framework �29

What’s in serverless.yml?

@fmc_sea An Introduction to Microservices with the Serverless Framework �30

Service Configuration

@fmc_sea An Introduction to Microservices with the Serverless Framework �31

Provider details

@fmc_sea An Introduction to Microservices with the Serverless Framework �32

Provider details - IAM Roles

@fmc_sea An Introduction to Microservices with the Serverless Framework �33

Provider details - IAM Roles

@fmc_sea An Introduction to Microservices with the Serverless Framework �34

Function Definitions

@fmc_sea An Introduction to Microservices with the Serverless Framework �35

Function Definitions

@fmc_sea An Introduction to Microservices with the Serverless Framework �36

Function Definitions

@fmc_sea An Introduction to Microservices with the Serverless Framework �37

Resources

@fmc_sea An Introduction to Microservices with the Serverless Framework �38

Optional Packaging

@fmc_sea An Introduction to Microservices with the Serverless Framework �39

How many total lines of code?

(README not included)

@fmc_sea An Introduction to Microservices with the Serverless Framework �40

Total lines: 436

Deploy@fmc_sea An Introduction to Microservices with the Serverless Framework �41

Deployment Options@fmc_sea An Introduction to Microservices with the Serverless Framework �42

Local AWS Keys(2 options)

Using the Serverless Dashboard

Using Serverless CI/CD

Local AWS Keys@fmc_sea An Introduction to Microservices with the Serverless Framework �43

AWS Keys &

Serverless Safeguards

@fmc_sea An Introduction to Microservices with the Serverless Framework �44

AWS Keys &

Serverless Safeguards

@fmc_sea An Introduction to Microservices with the Serverless Framework �45

AWS Keys &

Serverless Safeguards

@fmc_sea An Introduction to Microservices with the Serverless Framework �46

@fmc_sea An Introduction to Microservices with the Serverless Framework �47

Deploying with Local Keys

Deploying via the Serverless

Dashboard

@fmc_sea An Introduction to Microservices with the Serverless Framework �48

Deploying via the Serverless

Dashboard

@fmc_sea An Introduction to Microservices with the Serverless Framework �49

Deploying via the Serverless

Dashboard

@fmc_sea An Introduction to Microservices with the Serverless Framework �50

@fmc_sea An Introduction to Microservices with the Serverless Framework �51

Deploying via the Serverless Dashboard

Deploying with Serverless CI/CD@fmc_sea An Introduction to Microservices with the Serverless Framework �52

What are we doing?

@fmc_sea An Introduction to Microservices with the Serverless Framework �53

@fmc_sea An Introduction to Microservices with the Serverless Framework �54

DEMO TIME!1. Review app/org values2. Create/add an IAM role3. Create Profiles and

Safeguards4. Deploy a `dev` and

`prod` service5. Add API Endpoints to

our frontend

Just in case…

@fmc_sea An Introduction to Microservices with the Serverless Framework �55

The demo went great Why did I do a live demo?

@fmc_sea An Introduction to Microservices with the Serverless Framework �56

@fmc_sea An Introduction to Microservices with the Serverless Framework �57

@fmc_sea An Introduction to Microservices with the Serverless Framework �58

@fmc_sea An Introduction to Microservices with the Serverless Framework �59

@fmc_sea An Introduction to Microservices with the Serverless Framework �60

@fmc_sea An Introduction to Microservices with the Serverless Framework �61

@fmc_sea An Introduction to Microservices with the Serverless Framework �62

@fmc_sea An Introduction to Microservices with the Serverless Framework �63

@fmc_sea An Introduction to Microservices with the Serverless Framework �64

@fmc_sea An Introduction to Microservices with the Serverless Framework �65

@fmc_sea An Introduction to Microservices with the Serverless Framework �66

@fmc_sea An Introduction to Microservices with the Serverless Framework �67

Debug

@fmc_sea An Introduction to Microservices with the Serverless Framework �68

Running Our Frontend

@fmc_sea An Introduction to Microservices with the Serverless Framework �69

DEMO TIME!

1. Run our frontend2. Try to vote3. Try to vote again!

@fmc_sea An Introduction to Microservices with the Serverless Framework �70

Monitoring

@fmc_sea An Introduction to Microservices with the Serverless Framework �71

DEMO TIME!1. Explore function logs2. Review specific invocations

Develop@fmc_sea An Introduction to Microservices with the Serverless Framework �72

New Requirements:@fmc_sea An Introduction to Microservices with the Serverless Framework �73

Users may vote every five minutes

Let’s “Build” that@fmc_sea An Introduction to Microservices with the Serverless Framework �74

DEMO TIME!

@fmc_sea An Introduction to Microservices with the Serverless Framework �75

DEMO TIME!

Deploy to `dev`

@fmc_sea An Introduction to Microservices with the Serverless Framework �76

How would we get this to prod?

@fmc_sea An Introduction to Microservices with the Serverless Framework �77

Reality is more complicated…

https://serverless.com/learn/guides/cicd/

@fmc_sea An Introduction to Microservices with the Serverless Framework �78

Deploying Our Frontend

BONUS DEMO TIME?

@fmc_sea An Introduction to Microservices with the Serverless Framework �79

We eat our own dog food

@fmc_sea An Introduction to Microservices with the Serverless Framework �80

Thank you!Office Hours: 9am tomorrow - Room 212

Unofficial Office Hours: Right nowBy appointment - (DM me)

@fmc_sea

top related