Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB...

36
Don’t Let FaaS Do a BaaS Job ...a workshop on serverless functions using BaaS, by Tessa Mero May 30th, 2019 - DeveloperWeek Seattle The content of this presentation is proprietary information of Cloudinary. It is not intended to be distributed to any third party without the written consent of Cloudinary. © 2019 Cloudinary inc. @tessamero

Transcript of Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB...

Page 1: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

Don’t Let FaaS Do a BaaS Job ...a workshop on serverless functions using BaaS, by Tessa Mero May 30th, 2019 - DeveloperWeek Seattle

The content of this presentation is proprietary information of Cloudinary. It is not intended to be distributed to any third party without the written consent of Cloudinary. © 2019 Cloudinary inc.

@tessamero

Page 2: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

Oh hai

● Community Leader

○ Past: Joomla, PHP

○ Current: API, Vue.js, JAMStack

● Developer, Teacher,

Advocate

● Gamer + Mom

● Korean Food Enthusiast

● Steak Hobbyist

@tessamero

Page 3: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

Topics

● What is Serverless?

● Different Services

● Serverless Frameworks

● Using Serverless

Functions and BaaS

● Resources Let’s make your flower of knowledge bloom!

@tessamero

Page 4: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

What is Serverless?

Page 5: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

History

Physical Servers Virtual Machines Containers Serverless

Page 6: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

What is Serverless?

● No Servers!

No More Managing Servers!

Serverless doesn’t mean there are no servers being used, it is

the concept of not having to manage/provision or worry about

servers for your applications

Page 7: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

What is Serverless?

● No Servers!

● Cost

Cost Efficiency

Pay for your resources used rather than the time (provisioned

capacity)

Page 8: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

What is Serverless?

● No Servers!

● Cost

● Scale

Erm. So uhh, Does it Scale?

Auto scaling is built in Serverless!

Page 9: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

What is Serverless?

● No Servers!

● Cost

● Scale

● Time

What will you do with your extra TIME?

Page 10: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

Taking a Look at Different Services

Page 11: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

Taking a Look at Different Services

● IaaS

IaaS - Infrastructure as a Service

Examples:

● Amazon Elastic Cloud Computing (AWS

EC2)

Page 12: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

Taking a Look at Different Services

● IaaS

● SaaS

SaaS - Software as a Service

Examples:

● Stripe

● PayPal

● Slack

*Responsible for integrating services

Page 13: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

Taking a Look at Different Services

● IaaS

● SaaS

● PaaS

PaaS - Platform as a Service

Example:

● Heroku

Provides an entire platform

Page 14: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

Taking a Look at Different Services

● IaaS

● SaaS

● PaaS

● BaaS

BaaS - Backend as a Service

Examples:

● Amazon’s DynamoDB

● Google’s Firebase

Service with complex backend usually with

dedicated SDKs and APIs

Page 15: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

Taking a Look at Different Services

● IaaS

● SaaS

● PaaS

● BaaS

● FaaS

FaaS - Functions as a Service

Examples:

● Azure Functions

● Amazon’s Lambda

Allows a service to be executed when

triggered

Page 16: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

Serverless Frameworks

Page 17: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

Serverless Frameworks

● Amplify Framework

Amplify Framework - JS library for front-end devs, works

with all Frameworks

https://aws-amplify.github.io/

Page 18: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

Serverless Frameworks

● Amplify Framework

● Architect

● Serverless

Architect - An open-source framework. Create, deploy,

and maintain next-generation AWS cloud function-based

serverless infrastructure with full local, offline workflows,

and more

https://arc.codes

Page 19: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

Serverless Frameworks

● Amplify Framework

● Architect

● Serverless

Serverless Framework -First original serverless

framework. The most popular on Github with 30k stars

https://serverless.com

Page 20: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

Using Serverless Functions (FaaS) and BaaS Using Lambda, UnSplash API, and Cloudinary API

Page 21: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

End Result: Deploy a function and a random image will be selected from Unsplash and then uploaded to your Cloudinary media library!

Page 22: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

Let’s Get Started!

Page 23: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

What You Will Need: ● Serverless login serverless.com ● AWS IAM Access Token aws.amazon.com ● Unsplash API Key unsplash.com ● Cloudinary API Key cloudinary.com

Page 24: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

Install Serverless Framework and Login

npm i -g serverless

serverless login

@tessamero

Page 25: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

Start with node.js template

serverless create -t aws-nodejs

handler.js

serverless.yml

@tessamero

Page 26: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

Create an AWS Access Key

Search for IAM in Amazon’s AWS and Set up a User

https://serverless.com/framework/docs/providers/aws/guide/credentials/

Quick Instructions:

IAM -> Users -> Add User -> Enable Programmatic Access -> Next ->

Create User

@tessamero

Page 27: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

open serverless.yml

service: aws-nodejs

app: XXX

tenant: XXX

serverless deploy

@tessamero

Page 28: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

Test by Invoking Function

serverless invoke -f hello -l

@tessamero

Page 30: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

Create a package.json file

https://gist.github.com/tessamero/ and click on

“package.json” and copy the js code

@tessamero

Page 31: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

deploy!

https://gist.github.com/tessamero/ and click on

“serverless.yml” and copy the code

@tessamero

Page 32: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

Update the serverless.yml file

serverless deploy

@tessamero

Page 33: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

Endpoint reached! @tessamero

Page 34: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

Resources: The Serverless Revolution: Why and How The Movement Will Allow Teams to Deploy with More Velocity and Confidence, by Ravi Lachhman What is Serverless? by ServerlessOps Know your history - It’s a serverless world by JAX Editorial Team Origin of Serverless by Joshua Harding Introduction to Serverless FaaS by Tamas Piros 15 Frameworks for Creating Serverless Apps by Alex Ivanovs

Page 35: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

Challenge: Transform a Unicorn Before it’s Gone! ● Step 1: Find the Cloudinary Unicorn (hint:.....) ● Step 2: Take a Picture of the Unicorn ● Step 3: Upload and Transform the photo. Sign up for a free account at

https://cloudinary.com. ○ Go to Media Manager ○ Upload Image. Click “Edit” ○ Click “Transform” and change some presets ○ Copy the “https” URL!

● Step 4: DM me to claim your unicorn (send the URL) https://twitter.com/tessamero ○ (hurry, the unicorns won’t last long!)

Page 36: Don’t Let FaaS Do a BaaS Job · BaaS BaaS - Backend as a Service Examples: Amazon’s DynamoDB Google’s Firebase Service with complex backend usually with dedicated SDKs and APIs

<< end

● Twitter: https://twitter.com/tessamero

● Email.: [email protected]

● Slides: https://slideshare.net/tessa99

THANK YOU!

@tessamero