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

Simplifying Serverless CI/CD

Simplifying Serverless CI/CD

Serverless South Wales Meetup, Cardiff, November 6th, 2019

Danilo Poccia

November 06, 2019
Tweet

More Decks by Danilo Poccia

Other Decks in Programming

Transcript

  1. © 2019, Amazon Web Services, Inc. or its Affiliates.
    Danilo Poccia
    Principal Evangelist, Serverless
    @danilop
    Simplifying Serverless CI/CD

    View full-size slide

  2. How does
    Serverless
    work?
    Photo by Mervyn Chan on Unsplash

    View full-size slide

  3. © 2019, Amazon Web Services, Inc. or its Affiliates.
    How does Serverless work?
    Storage
    Databases
    Analytics
    Machine Learning
    . . .
    Your
    unique
    business
    logic
    User uploads a picture
    Customer data updated
    Anomaly detected
    API call
    . . .
    Fully-managed
    services
    Events
    Functions

    View full-size slide

  4. © 2019, Amazon Web Services, Inc. or its Affiliates.
    Photo by Oskars Sylwan on Unsplash
    Focus on what you want to build,
    not the nuts & bolts required
    by the implementation of the solution

    View full-size slide

  5. © 2019, Amazon Web Services, Inc. or its Affiliates.
    Photo by Scott Blake on Unsplash
    What can we build?

    View full-size slide

  6. SCALING CHALLENGES
    350
    DONATIONS PER SECOND
    Case
    Study

    View full-size slide

  7. OLD VS NEW
    March 2019 cost*
    $5,393
    March 2015 cost*
    $83,908
    *All hosting costs are paid for through corporate partnerships.
    100% of public donations go to the projects we fund.
    Case
    Study

    View full-size slide

  8. WE COULD DO
    IT ALL AGAIN TOMORROW
    Serverless services cost
    $92
    Case
    Study

    View full-size slide

  9. © 2019, Amazon Web Services, Inc. or its Affiliates.
    Photo by Samuele Errico Piccarini on Unsplash

    View full-size slide

  10. © 2019, Amazon Web Services, Inc. or its Affiliates.
    AWS Serverless Application Model (SAM)
    AWSTemplateFormatVersion: '2010-09-09’
    Transform: AWS::Serverless-2016-10-31
    Resources:
    GetFunction:
    Type: AWS::Serverless::Function
    Properties:
    Handler: index.get
    Runtime: nodejs8.10
    CodeUri: src/
    Policies:
    - DynamoDBReadPolicy:
    TableName: !Ref MyTable
    Events:
    GetResource:
    Type: Api
    Properties:
    Path: /resource/{resourceId}
    Method: get
    MyTable:
    Type: AWS::Serverless::SimpleTable
    Just 20 lines to create:
    • Lambda function
    • IAM role
    • API Gateway
    • DynamoDB table
    O
    pen
    Source

    View full-size slide

  11. © 2019, Amazon Web Services, Inc. or its Affiliates.
    SAM CLI
    pip install --user aws-sam-cli # use native Linux/Windows/macOS installers
    sam init # interactive or with args e.g. --name my-app --runtime python
    cd my-app/
    sam local ... # generate-event/invoke/start-api/start-lambda
    sam validate # The SAM template
    sam build # Depending on the runtime
    sam package --s3-bucket my-packages-bucket \
    --output-template-file packaged.yaml
    sam deploy --template-file packaged.yaml \
    --stack-name my-stack-prod
    sam logs -n MyFunction --stack-name my-stack-prod -t # Tail
    sam publish # To the Serverless Application Repository
    O
    pen
    Source
    CodePipeline
    Use
    CloudFormation
    deployment
    actions with any
    SAM application
    Jenkins
    Use SAM CLI
    plugin

    View full-size slide

  12. © 2019, Amazon Web Services, Inc. or its Affiliates.
    Safe deployments in SAM
    Resources:
    GetFunction:
    Type: AWS::Serverless::Function
    Properties:
    AutoPublishAlias: live
    DeploymentPreference:
    Type: Canary10Percent5Minutes
    Alarms:
    - !Ref ApiErrorsAlarm
    - !Ref ApiLatencyAlarm
    Hooks:
    PreTraffic: !Ref PreTrafficLambdaFunction
    PostTraffic: !Ref PreTrafficLambdaFunction
    Canary10Percent30Minutes
    Canary10Percent5Minutes
    Canary10Percent10Minutes
    Canary10Percent15Minutes
    Linear10PercentEvery10Minutes
    Linear10PercentEvery1Minute
    Linear10PercentEvery2Minutes
    Linear10PercentEvery3Minutes
    AllAtOnce
    +
    Custom Deployment Configurations

    View full-size slide

  13. © 2019, Amazon Web Services, Inc. or its Affiliates.
    Safe deployments in SAM
    Resources:
    GetFunction:
    Type: AWS::Serverless::Function
    Properties:
    AutoPublishAlias: live
    DeploymentPreference:
    Type: Canary10Percent5Minutes
    Alarms:
    - !Ref ApiErrorsAlarm
    - !Ref ApiLatencyAlarm
    Hooks:
    PreTraffic: !Ref PreTrafficLambdaFunction
    PostTraffic: !Ref PreTrafficLambdaFunction
    These can be
    CloudWatch
    anomaly detection
    alarms

    View full-size slide

  14. © 2019, Amazon Web Services, Inc. or its Affiliates.
    Using CloudWatch Anomaly Detection Alarms

    View full-size slide

  15. © 2019, Amazon Web Services, Inc. or its Affiliates.
    Editing the Anomaly Detection Model

    View full-size slide

  16. Photo by J W on Unsplash
    Can we help more?

    View full-size slide

  17. © 2019, Amazon Web Services, Inc. or its Affiliates.
    © 2019, Amazon Web Services, Inc. or its Affiliates.

    View full-size slide

  18. © 2019, Amazon Web Services, Inc. or its Affiliates.
    Photo by Kea Mowat on Unsplash
    Speed & Control

    View full-size slide

  19. © 2019, Amazon Web Services, Inc. or its Affiliates.
    © 2019, Amazon Web Services, Inc. or its Affiliates.
    Thank you!
    @danilop Please give me your feedback

    View full-size slide