Simplifying Serverless CI/CD

Simplifying Serverless CI/CD

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

7c9b8b368924556d8642bdaed3ded1f5?s=128

Danilo Poccia

November 06, 2019
Tweet

Transcript

  1. © 2019, Amazon Web Services, Inc. or its Affiliates. Danilo

    Poccia Principal Evangelist, Serverless @danilop Simplifying Serverless CI/CD
  2. How does Serverless work? Photo by Mervyn Chan on Unsplash

  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
  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
  5. © 2019, Amazon Web Services, Inc. or its Affiliates. Photo

    by Scott Blake on Unsplash What can we build?
  6. SCALING CHALLENGES 350 DONATIONS PER SECOND Case Study

  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
  8. WE COULD DO IT ALL AGAIN TOMORROW Serverless services cost

    $92 Case Study
  9. © 2019, Amazon Web Services, Inc. or its Affiliates. Photo

    by Samuele Errico Piccarini on Unsplash
  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
  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
  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
  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
  14. © 2019, Amazon Web Services, Inc. or its Affiliates. Using

    CloudWatch Anomaly Detection Alarms
  15. © 2019, Amazon Web Services, Inc. or its Affiliates. Editing

    the Anomaly Detection Model
  16. Photo by J W on Unsplash Can we help more?

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

    2019, Amazon Web Services, Inc. or its Affiliates.
  18. None
  19. © 2019, Amazon Web Services, Inc. or its Affiliates. Photo

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

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