AWS Lambda& Ruby/Rails with SAM
View Slide
Congratulations!The simple fact thatyou are sitting herelistening to me,means you've made aglorious contributionto Science!Tragic, butinformative.Cave Johnson
Ken Collins Staff Engineer @CustomInk@MetaSkills
⠀ ⠀ ⠀
KNOWLEDGERails &LambdaRuby &LambdaTech IntroAWS SAMObjectives & Results
Change The WorldOne Lambda at a Time!
Using Ruby with AWS Lambda & SAMhttps://github.com/757rb/hello-757rb-lambda
Custom Ink | Tech Bloghttps://technology.customink.com
https://dctechslack.herokuapp.comhttps://slackin757dev.herokuapp.comDCTech || 757Dev
Tech Intro
Strap Bootstrap your macOS development system.GitHub Projecthttps://github.com/MikeMcQuaid/strap
• ./bin/• bootstrap, setup, build, server, deploy, test, …• Usually BashStrap
AWS Lambda
AWS SAMGitHub Projecthttps://github.com/awslabs/serverless-application-model/
$ sam
https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.htmlCLOUDFORMATION
$ sam local start-api
$ sam build --use-container
$ sam package …$ sam deploy …
Ruby &Lambda
Project Pillars• Local Development Feedback• Using Gems with Native Extensions• Using DynamoDB
Contrived ArchitectureDynamoDBHTTP /plos?query={query}
Docker Imagelambci/lambda:ruby2.5
Local Dev Deps
Easy Development &Browser Refreshes
Patterns• Directories (app, test, etc)• Lean Handler & PORO Usage• Debug HTML. Event, Context, & ENV• Minitest, TravisCI, & Capybara* *not really
Aws::RecordGitHub Projecthttps://github.com/aws/aws-sdk-ruby-record
DynamoDB
Used in IAMExecution RoleDynamoDB
Patterns…
Patterns• Easy/Lazy Development & Test• Table Migrations• SimpleTable On Demand Defaults
Rails &Lambda
Product Sitehttp://rubyonjets.com
Ruby on Jets
Little Gotcha List• Docker Shared Volume Perf• Logging & RAILS_LOG_TO_STDOUT• Keeping Package Size Down.• Invoke URL & Custom Domains
Coming Soon• Quality Rack Integration. Session,Cookies, & More.• Deploy asset:precompile to S3.• Encrypted Session Secret via AWSSystem Manager Param Store.• Better Gemfile dev/test groups.
Lambda Layers
--help
RailsConf2019