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

    by Scott Blake on Unsplash What can we build?
  5. 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
  6. © 2019, Amazon Web Services, Inc. or its Affiliates. Photo

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

    2019, Amazon Web Services, Inc. or its Affiliates.
  12. © 2019, Amazon Web Services, Inc. or its Affiliates. Photo

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

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