Slide 1

Slide 1 text

© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Danilo Poccia, Technical Evangelist @danilop Serverless in Production With CI/CD and End-to-End Tracing

Slide 2

Slide 2 text

What is Serverless?

Slide 3

Slide 3 text

Operations and management Scaling Provisioning and utilization Availability and fault tolerance Owning servers means dealing with ...

Slide 4

Slide 4 text

AWS Lambda: Run code in response to events FUNCTION SERVICES (ANYTHING) Changes in data state Requests to endpoints Changes in resource state Node Python Java C# EVENT SOURCE

Slide 5

Slide 5 text

No servers to provision or manage Scales with usage Never pay for idle Availability and fault tolerance built in Benefits of Lambda and serverless compute

Slide 6

Slide 6 text

Example Serverless Application Architecture

Slide 7

Slide 7 text

Web Applications and Backends

Slide 8

Slide 8 text

Data Processing

Slide 9

Slide 9 text

Data Processing

Slide 10

Slide 10 text

Serverless IoT with AWS Lambda at iRobot

Slide 11

Slide 11 text

AWS Lambda Amazon CloudFront Amazon S3 Amazon DynamoDB Amazon Redshift Amazon Route 53 Amazon VPC Amazon CloudWatch AWS CloudFormation AWS CloudTrail AWS Config AWS IAM AWS KMS AWS WAF Amazon Cognito Amazon SNS Amazon API Gateway Amazon SQS Amazon Elasticsearch Service Amazon Kinesis Amazon QuickSight AWS IoT How iRobot leverages AWS

Slide 12

Slide 12 text

API Gateway App requests over HTTPS CRUD operations

Slide 13

Slide 13 text

IoT MQTT CRUD operations

Slide 14

Slide 14 text

IoT MQTT MQTT Presigned URL Staging bucket

Slide 15

Slide 15 text

Infrastructure as Code

Slide 16

Slide 16 text

AWS CloudFormation brings: • Infrastructure as code • Easy to provision and manage a collection of related AWS resources • Input .yaml file and output provisioned AWS resources • Optimized for infrastructure AWS SAM: • CloudFormation extension optimized for serverless • New serverless resources: functions, APIs, and tables • Supports anything CloudFormation supports • Open specification (Apache 2.0) AWS Serverless Application Model (AWS SAM)

Slide 17

Slide 17 text

AWSTemplateFormatVersion: '2010-09-09' Resources: GetHtmlFunctionGetHtmlPermissionProd: Type: AWS::Lambda::Permission Properties: Action: lambda:invokeFunction Principal: apigateway.amazonaws.com FunctionName: Ref: GetHtmlFunction SourceArn: Fn::Sub: arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ServerlessRestApi}/Prod/ANY/* ServerlessRestApiProdStage: Type: AWS::ApiGateway::Stage Properties: DeploymentId: Ref: ServerlessRestApiDeployment RestApiId: Ref: ServerlessRestApi StageName: Prod ListTable: Type: AWS::DynamoDB::Table Properties: ProvisionedThroughput: WriteCapacityUnits: 5 ReadCapacityUnits: 5 AttributeDefinitions: - AttributeName: id AttributeType: S KeySchema: - KeyType: HASH AttributeName: id GetHtmlFunction: Type: AWS::Lambda::Function Properties: Handler: index.gethtml Code: S3Bucket: flourish-demo-bucket S3Key: todo_list.zip Role: Fn::GetAtt: - GetHtmlFunctionRole - Arn Runtime: nodejs4.3 GetHtmlFunctionRole: Type: AWS::IAM::Role Properties: ManagedPolicyArns: - arn:aws:iam::aws:policy/AmazonDynamoDBReadOnlyAccess - arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole AssumeRolePolicyDocument: Version: '2012-10-17' Statement: - Action: - sts:AssumeRole Effect: Allow Principal: Service: - lambda.amazonaws.com ServerlessRestApiDeployment: Type: AWS::ApiGateway::Deployment Properties: RestApiId: Ref: ServerlessRestApi Description: 'RestApi deployment id: 127e3fb91142ab1ddc5f5446adb094442581a90d' StageName: Stage GetHtmlFunctionGetHtmlPermissionTest: Type: AWS::Lambda::Permission Properties: Action: lambda:invokeFunction Principal: apigateway.amazonaws.com FunctionName: Ref: GetHtmlFunction SourceArn: Fn::Sub: arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ServerlessRestApi}/*/ANY/* ServerlessRestApi: Type: AWS::ApiGateway::RestApi Properties: Body: info: version: '1.0' title: Ref: AWS::StackName paths: "/{proxy+}": x-amazon-apigateway-any-method: x-amazon-apigateway-integration: httpMethod: ANY type: aws_proxy uri: Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03- 31/functions/${GetHtmlFunction.Arn}/invocations responses: {} swagger: '2.0' CF template example – API triggering Lambda AWSTemplateFormatVersion: '2010-09-09’ Transform: AWS::Serverless-2016-10-31 Resources: GetHtmlFunction: Type: AWS::Serverless::Function Properties: CodeUri: s3://flourish-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 AWS SAM example – API triggering Lambda AWS SAM: Less complexity, more power

Slide 18

Slide 18 text

What is Continuous Integration?

Slide 19

Slide 19 text

What is Continuous Integration? Automation Component + Cultural Component

Slide 20

Slide 20 text

Continuous Integration Benefits Improve Developer Productivity Find and Address Bugs Quicker Deliver Updates Faster

Slide 21

Slide 21 text

Set Up a Serverless CI/CD Pipeline on AWS AWS CodeCommit AWS CodeBuild AWS CodePipeline AWS CloudFormation Amazon S3 GitHub AWS SAM Commit Build Deploy + Tests (CodeBuild or other services) + Manuals Approval (CodePipeline) + Multiple Environments (CodePipeline + CloudFormation)

Slide 22

Slide 22 text

How to make it easier?

Slide 23

Slide 23 text

AWS CodeStar New!

Slide 24

Slide 24 text

New! AWS X-Ray

Slide 25

Slide 25 text

Time for a demo J

Slide 26

Slide 26 text

Build a Serverless Web Application https://aws.amazon.com/getting-started/serverless-web-app/

Slide 27

Slide 27 text

JavaScript + AWS Mobile Hub Ionic + AWS MobileHub Starter Project https://github.com/ionic-team/ionic2-starter-aws Enhanced JavaScript development with AWS Mobile Hub https://aws.amazon.com/blogs/mobile/enhanced-javascript-development-with-aws-mobile-hub/ Deploy a React App to S3 and CloudFront with AWS Mobile Hub https://aws.amazon.com/blogs/mobile/deploy-a-react-app-to-s3-and-cloudfront-with-aws-mobile-hub/ Integrate the AWS SDK for JavaScript into a React App https://aws.amazon.com/blogs/mobile/integrate-the-aws-sdk-for-javascript-into-a-react-app/

Slide 28

Slide 28 text

Conclusion Lambda is a fundamental component of modern application architectures It has a place in everything from data processing to simple web apps

Slide 29

Slide 29 text

Thank you! @danilop