Upgrade to Pro — share decks privately, control downloads, hide ads and more …

AWS Lambda & Ruby/Rails with SAM

AWS Lambda & Ruby/Rails with SAM

Ken Collins

March 06, 2019
Tweet

More Decks by Ken Collins

Other Decks in Programming

Transcript

  1. AWS Lambda
    & Ruby/Rails with SAM

    View full-size slide

  2. Congratulations!
    The simple fact that
    you are sitting here
    listening to me,
    means you've made a
    glorious contribution
    to Science!
    Tragic, but
    informative.
    Cave Johnson

    View full-size slide

  3. Ken Collins Staff Engineer @CustomInk
    @MetaSkills

    View full-size slide

  4. ⠀ ⠀ ⠀

     


     

     

    View full-size slide

  5. KNOWLEDGE
    Rails &
    Lambda
    Ruby &
    Lambda
    Tech Intro
    AWS SAM
    Objectives & Results

    View full-size slide

  6. Change The World
    One Lambda at a Time!

    View full-size slide

  7. Using Ruby with AWS Lambda & SAM
    https://github.com/757rb/hello-757rb-lambda

    View full-size slide

  8. Custom Ink | Tech Blog
    https://technology.customink.com

    View full-size slide

  9. https://dctechslack.herokuapp.com
    https://slackin757dev.herokuapp.com
    DCTech || 757Dev

    View full-size slide

  10. Strap
    Bootstrap your macOS development system.
    GitHub Project
    https://github.com/MikeMcQuaid/strap

    View full-size slide

  11. • ./bin/
    • bootstrap, setup, build, server, 

    deploy, test, …
    • Usually Bash
    Strap

    View full-size slide

  12. AWS SAM
    GitHub Project
    https://github.com/awslabs/serverless-application-model/

    View full-size slide

  13. https://github.com/awslabs/serverless-
    application-model/blob/master/versions/
    2016-10-31.md

    View full-size slide

  14. https://docs.aws.amazon.com/
    AWSCloudFormation/latest/UserGuide/aws-
    template-resource-type-ref.html
    CLOUDFORMATION

    View full-size slide

  15. $ sam local start-api

    View full-size slide

  16. $ sam build --use-container

    View full-size slide

  17. $ sam package …
    $ sam deploy …

    View full-size slide

  18. Ruby &
    Lambda

    View full-size slide

  19. Project Pillars
    • Local Development Feedback
    • Using Gems with Native Extensions
    • Using DynamoDB

    View full-size slide

  20. Contrived Architecture
    DynamoDB
    HTTP /plos?query={query}

    View full-size slide

  21. Docker Image
    lambci/lambda:ruby2.5

    View full-size slide

  22. Local Dev Deps

    View full-size slide

  23. Easy Development &
    Browser Refreshes

    View full-size slide

  24. Patterns
    • Directories (app, test, etc)
    • Lean Handler & PORO Usage
    • Debug HTML. Event, Context, & ENV
    • Minitest, TravisCI, & Capybara*


    *not really

    View full-size slide

  25. Aws::Record
    GitHub Project
    https://github.com/aws/aws-sdk-ruby-record

    View full-size slide

  26. Used in IAM
    Execution Role
    DynamoDB

    View full-size slide

  27. Patterns
    • Easy/Lazy Development & Test
    • Table Migrations
    • SimpleTable On Demand Defaults

    View full-size slide

  28. Using Ruby with AWS Lambda & SAM
    https://github.com/757rb/hello-757rb-lambda

    View full-size slide

  29. Rails &
    Lambda

    View full-size slide

  30. Product Site
    http://rubyonjets.com

    View full-size slide

  31. Ruby on Jets

    View full-size slide

  32. Ruby on Jets

    View full-size slide

  33. Little Gotcha List
    • Docker Shared Volume Perf
    • Logging & RAILS_LOG_TO_STDOUT
    • Keeping Package Size Down.
    • Invoke URL & Custom Domains

    View full-size slide

  34. Coming Soon
    • Quality Rack Integration. Session,
    Cookies, & More.
    • Deploy asset:precompile to S3.
    • Encrypted Session Secret via AWS
    System Manager Param Store.
    • Better Gemfile dev/test groups.

    View full-size slide

  35. Lambda Layers

    View full-size slide

  36. RailsConf
    2019

    View full-size slide

  37. https://dctechslack.herokuapp.com
    https://slackin757dev.herokuapp.com
    DCTech || 757Dev

    View full-size slide