Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

Serverless-AWS SAM CLI Session: Developer Meet Up

AWS SAM is a fast and easy way of deploying your serverless applications, allowing you to write simple templates to describe your functions and their event sources (Amazon API Gateway, Amazon S3, Kinesis, and so on). Based on AWS SAM, SAM CLI is a tool that provides an environment for you to develop, test, and analyze your serverless applications locally before uploading them to the Lambda runtime. Whether you're developing on Linux, Mac, or Microsoft Windows, you can use SAM CLI to create a local testing environment that simulates the AWS runtime environment. The SAM CLI also allows faster, iterative development of your Lambda function code. For more information, see Building a Simple Application Using SAM CLI. In this session, we look at the latest version of SAM CLI and its new features to deploy a full CI/CD deployment stack for a .Net Lambda function.

  • Identifiez-vous pour voir les commentaires

Serverless-AWS SAM CLI Session: Developer Meet Up

  1. 1. ©2018, AmazonWebServices, Inc. or its Affiliates. All rights reserved. AmazonConfidential andTrademark©2018, AmazonWebServices, Inc. or its Affiliates. All rights reserved. AmazonConfidential andTrademark Adam Larter, Principal Solutions Architect, Developer Specialist AWS Serverless Application Model SAM and SAM CLI Streamlining serverless development, testing and deployment alarter@amazon.com | www.linkedin.com/in/adamlarter
  2. 2. ©2018, AmazonWebServices, Inc. or its Affiliates. All rights reserved. AmazonConfidential andTrademark Serverless is a mindset change toward automation, agility, and innovation
  3. 3. ©2018, AmazonWebServices, Inc. or its Affiliates. All rights reserved. AmazonConfidential andTrademark No servers to provision or manage Scales with usage Never pay for idle Availability and fault tolerance built in Serverless means…
  4. 4. ©2018, AmazonWebServices, Inc. or its Affiliates. All rights reserved. AmazonConfidential andTrademark Serverless application SERVICES (ANYTHING) Changes in data state Requests to endpoints Changes in resource state EVENT SOURCE FUNCTION Node.js Python Java C# (.Net Core) Go
  5. 5. ©2018, AmazonWebServices, Inc. or its Affiliates. All rights reserved. AmazonConfidential andTrademark Common Lambda use cases Web Applications • Static websites • Complex web apps • Packages for Flask and Express Data Processing • Real time • MapReduce • Batch Chatbots • Powering chatbot logic Backends • Apps & services • Mobile • IoT </></> Amazon Alexa • Powering voice-enabled apps • Alexa Skills Kit IT Automation • Policy engines • Extending AWS services • Infrastructure management </></>
  6. 6. ©2018, AmazonWebServices, Inc. or its Affiliates. All rights reserved. AmazonConfidential andTrademark AmazonS3 Amazon DynamoDB Amazon Kinesis AWS CloudFormation AWS CloudTrail Amazon CloudWatch Amazon Cognito AmazonSNSAmazon SES Cronevents DATA STORES ENDPOINTS DEVELOPMENT AND MANAGEMENT TOOLS EVENT/MESSAGE SERVICES Event sources that trigger AWS Lambda and more! AWS CodeCommit Amazon API Gateway Amazon Alexa AWSIoT AWSStep Functions
  7. 7. ©2018, AmazonWebServices, Inc. or its Affiliates. All rights reserved. AmazonConfidential andTrademark How do we apply DevOps to Serverless and automate deployments?
  8. 8. Meet SAM!
  9. 9. AWS Serverless Application Model (SAM) CloudFormation extension optimised for serverless application development New serverless resource types: functions, APIs, and tables Supports anything CloudFormation supports – mix canonical CloudFormation and SAM together in the same template Open specification (Apache 2.0) https://github.com/awslabs/serverless-application-model
  10. 10. AWSTemplateFormatVersion: '2010-09-09’ Transform: AWS::Serverless-2016-10-31 Resources: GetHtmlFunction: Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/todo_list.zip Handler: index.gethtml Runtime: nodejs4.3 Policies: AmazonDynamoDBReadOnlyAccess Events: GetHtml: Type: Api Properties: Path: /{proxy+} Method: ANY ListTable: Type: AWS::Serverless::SimpleTable SAM template
  11. 11. AWSTemplateFormatVersion: '2010-09-09’ Transform: AWS::Serverless-2016-10-31 Resources: GetHtmlFunction: Type: AWS::Serverless::Function Properties: CodeUri: s3://sam-demo-bucket/todo_list.zip Handler: index.gethtml Runtime: nodejs4.3 Policies: AmazonDynamoDBReadOnlyAccess Events: GetHtml: Type: Api Properties: Path: /{proxy+} Method: ANY ListTable: Type: AWS::Serverless::SimpleTable SAM template Tells CloudFormation this is a SAM template it needs to “transform” Creates a Lambda function with the referenced managed IAM policy, runtime, code at the referenced zip location, and handler as defined. Also creates an API Gateway and takes care of all mapping/permissions necessary Creates a DynamoDB table
  12. 12. How do I test my Lambda functions? How do I continuously deploy my Lambda functions?
  13. 13. CLI tool for local testing of serverless apps Bootstrap your development with code blueprints generated by the tool Response object and function logs available on your local machine Uses open source docker-lambda images to mimic Lambda’s execution environment Emulates timeout, memory limits, runtimes https://github.com/awslabs/aws-sam-local SAM CLI
  14. 14. New for version 0.5.0 Run your automated tests in a local, Lambda-like environment using the AWS SDKs Troubleshoot your Lambda functions using the sam logs command to fetch, tail & filter your function logs Install/upgrade today! pip install --upgrade aws-sam-cli SAM CLI
  15. 15. Demo
  16. 16. Init sam init --runtime dotnetcore2.0 --name mylambda Build and test dotnet publish src/HelloWorld Invoke the Function directly sam local invoke HelloWorldFunction Init the CI/CD pipeline template (run inside the mylambda folder) sam init --location gh:awlarau/cookiecutter-awlarau-sam-pipeline Dotnet demo steps
  17. 17. Build the CI/CD pipeline sh build-pipeline.sh Attach code to repo using usual git init, add origin etc – this will kick off the pipeline to build and deploy the function Invoke the Function locally for testing via APIGW emulation sam local start-api Invoke the Function locally for testing via the AWS SDK sam local start-lambda Dotnet demo steps
  18. 18. Gradual Code Deployment - Canaries SAM usually uses CloudFormation to deploy new/updates to Lambda functions If you enable Safe Lambda Deployments, SAM will instead use CodeDeploy for automated gradual deployment Gradually shift traffic to the new version and roll back if a problem is encountered (based on canaries/alarms)
  19. 19. ©2018, AmazonWebServices, Inc. or its Affiliates. All rights reserved. AmazonConfidential andTrademark Resources SAM CLI https://github.com/awslabs/aws-sam-cli Cookie cutter template used in this demo https://github.com/awlarau/cookiecutter-awlarau-sam-pipeline
  20. 20. ©2018, AmazonWebServices, Inc. or its Affiliates. All rights reserved. AmazonConfidential andTrademark©2018, AmazonWebServices, Inc. or its Affiliates. All rights reserved. AmazonConfidential andTrademark Thank you! Adam Larter, Principal Solutions Architect, Developer Specialist alarter@amazon.com | www.linkedin.com/in/adamlarter

×