Serverless Framework
With Dani Tornow
What is Serverless?
- A framework the supports server free microservice architectures
- Supports multiple cloud vendors
- AWS
- This is the one we will use today for our demos
- Azure
- Google Cloud
- kubernetes
- AWS
- Runs on Javascript, but lets you develop in a language of your choice
Vocab
- Lambda
- Execute code as needed
- API Gateway
- Expose endpoints to the internet
- SNS
- Message hub, use it how you want
- DynamoDB
- NoSQL keypair database
- S3
- Buckets where you put files
Vocab Cont
- SQS
- Make queues and put messages in them
- Cloudwatch
- Log your work
- Cloudformation
- Tell AWS what to build and how
- IAM
- Configure users and keys
Connect to AWS
- Install the AWS CLI
-
https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html
- python (and pip) needed here
-
https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html
- Create an AWS Access Key
- IAM access & secret key
- Set up a profile
- Can run aws configure for your first time
- Try a command
- aws s3 ls
aws s3 ls --aws-profile <profilename>
Serverless Getting Started
- Get npm on your machine
- Install Serverless
- npm install serverless -g
- Create your first template
- sls create --template <type> --path <foldername>
- aws-ruby is today's demo
- sls is the short term for the serverless application
- there are many other options!
- sls create --template <type> --path <foldername>
npm install serverless -g
sls create --template <type> --path <foldername>
$ sls create --template aws-ruby --path <stagename>
$ cd <stagename>
$ vi serverless.yml
{{make some edits}}
$ sls deploy --stage <stagename> --aws-profile <profilename>
$ sls invoke --stage <stagename> --function hello --aws-profile <profilename>
$ sls logs --stage <stagename> --function hello --aws-profile <profilename>
sls create --template aws-ruby --path <stagename>
cd <stagename>
vi serverless.yml
{{make some edits}}
sls deploy --stage <stagename> --aws-profile <profilename>
sls invoke --stage <stagename> --function hello --aws-profile <profilename>
sls logs --stage <stagename> --function hello --aws-profile <profilename>
What Serverless Does For You
- Serverless will take your configuration and create a Cloudformation template
- Upload the template to AWS
- Start deploying the template using Cloudformation
- Confirm deployment
- Allow you to query the logs
Demo
AKA The Rest of This Presentation...
- Let's build some API endpoints
- Let's put some data in a database
- Let's do it without servers!
- Find the full code used at: https://github.com/danitornow/serverless
What we built
Tips and Tricks
- SLS Deploy is both a create and update for functions or resources
- Lambdas have a maximum time they can be run, don't run them longer than 15 minutes
- Lambdas can be run on a schedule, like cron jobs
- You cannot remove a non-empty bucket with SLS remove, you need to empty the bucket first
I'm Dani Tornow
Besides just giving this talk, I also work at Sanford Imagenetics. We do some pretty sweet stuff regarding genetics. If you want to get in touch with me, you can always shoot me an email or even send a carrier pigeon.
The Details:
danitornow@gmail.com
https://www.linkedin.com/in/dani-tornow/
Questions?
How it's been going in production
- Managed to overload other vendor systems because we process our messages so quickly
- Have a way to easily track a message through the whole system
- Utilized SNS and SQS heavily to make a durable and highly available system
- Sometimes the Lambdas run for 15 minutes and a message gets processed twice
- It's pretty awesome!
Resources
- These Slides: https://slides.com/danitornow/serverless-framework
- The Repo: https://github.com/danitornow/serverless
- Serverless AWS Docs:
https://serverless.com/framework/docs/providers/aws/
Serverless Framework
By Danielle Tornow
Serverless Framework
- 138