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

Learn to Program The Cloud with Ruby & AWS Lambda

Learn to Program The Cloud with Ruby & AWS Lambda

A curated set of resources and guides on how to use Ruby & Rails as your entry point to learning native AWS cloud architectures. Presented to DC Ruby User Group. https://www.meetup.com/dcruby/events/wzqbvpybcjbxb/

Ken Collins

June 18, 2020
Tweet

More Decks by Ken Collins

Other Decks in Technology

Transcript

  1. Learn to Program
    The Cloud
    with Ruby & AWS Lambda

    View full-size slide

  2. Ken Collins @MetaSkills Principal Engineer @CustomInkTech

    View full-size slide

  3. Programming
    The Cloud

    View full-size slide

  4. Getting Started
    AWS, SAM, & Lambda
    https://aws.amazon.com/serverless/sam/

    View full-size slide

  5. https://dev.to/aws-heroes/aws-lambda-microservice-
    workshop-using-s3-libvips-ruby-4o96
    Start Small. Ruby S3/Image Microservice.

    View full-size slide

  6. https://lamby.custominktech.com/docs/quick_start
    And Grow. Rails & JavaScript Starter Application.
    Deploy in 5 min.

    View full-size slide

  7. https://lamby.custominktech.com/docs/quick_start
    And Grow. Rails & JavaScript Starter Application.

    View full-size slide

  8. https://lamby.custominktech.com/docs/quick_start
    And Grow. Rails & JavaScript Starter Application.

    View full-size slide

  9. Unconscious Bias? or
    Knowledge Gaps?
    (open discussion)

    View full-size slide

  10. Rails & Lambda
    (from the inside out)

    View full-size slide

  11. How Does
    Lamby Work?

    View full-size slide

  12. How Does
    Lamby Work?
    Hash Convert

    View full-size slide

  13. How Does
    Lamby Work?
    app.rb
    Everything else is
    just basically Rails

    View full-size slide

  14. How Does
    Lamby Work?
    3 Seconds (cold start)
    Milliseconds

    View full-size slide

  15. • Think of app.rb as config.ru
    for API Gateway.
    • Rails is in good company!
    Express, Flask, etc all do the
    same thing.
    • Think of Lambda as a
    cheaper PAYGO on Heroku.
    Rails & Lambda (inside out)

    View full-size slide

  16. Scaling compute
    is not your
    problem anymore.

    View full-size slide

  17. The Serverless
    Application Model
    https://aws.amazon.com/serverless/sam/

    View full-size slide

  18. Core SAM CLI Commands. More on the ./bin directory later.

    View full-size slide

  19. Infrastructure as Code (IaC) . I hope you like YAML!

    View full-size slide

  20. SAM is Syntactic Sugar for CloudFormation. Meta & DRY!

    View full-size slide

  21. AWS::Serverless::Function

    View full-size slide

  22. • AWS Resource Specification Language.
    • CLI Interface to Develop & Deploy Apps.
    • Lamby Uses Cutters Templates.
    • Super fast Squirrel on GitHub. Keep Up!
    • Bookmark These Resources…
    Serverless Application Model

    View full-size slide

  23. AWS Serverless Application Model (AWS SAM) Specification
    https://github.com/awslabs/serverless-application-model
    https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification.html
    Intrinsic Function Reference
    https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html
    AWS Resource and Property Types Reference
    https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html
    AWS SAM CLI GitHub Release Notes
    https://github.com/awslabs/aws-sam-cli/releases

    View full-size slide

  24. Docker Conventions


    View full-size slide

  25. https://github.blog/2015-06-30-scripts-to-rule-them-all/
    Normalized Script Convention

    View full-size slide

  26. Docker & Docker Compose Bin Scripts.

    View full-size slide

  27. Docker Compose. Avoids Repeated ENV & Volume Configs

    View full-size slide

  28. Docker. Rails, SAM, JavaScript, Etc on Lambda Dev.

    View full-size slide

  29. Script Conventions. Underscore for Container
    bin/_server
    bin/server

    View full-size slide

  30. • Node & Webpacker
    • Compiled & Served
    Assets
    • Dotenv Integration
    • Encrypted
    Credentials with SSM
    Parameter Store
    Dig In & Explore
    https://github.com/customink/lamby-cookiecutter
    • CloudWatch Logging
    & Lograge
    • API Gateway HTTP
    API v2 Default
    • Custom Domain
    Names, SSL, &
    CloudFront

    https://lamby.custominktech.com

    View full-size slide

  31. • Native MySQL & PostgreSQL using
    AWS RDS Proxy. Migrations?
    • Best Practices for Background Tasks
    & Event-Driven architecture using
    EventBridge, Asynchronous
    Invocations, and SNS/SQS. ActiveJob?
    Coming Soon…

    View full-size slide