aws 无服务器开发实用工具集 · 云端ide、ide集工 aws cloud9, ide toolkits for...

59
AWS 中国(宁夏)区域由西云数据运营 AWS 中国(北京)区域由光环新网运营 AWS 中国(宁夏)区域由西云数据运营 AWS 中国(北京)区域由光环新网运营 陈洪正 ,AWS 解决方案架构师 AWS 无服务器开发实用工具集 2019/10/15

Upload: others

Post on 26-May-2020

49 views

Category:

Documents


0 download

TRANSCRIPT

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

陈洪正,AWS 解决方案架构师

AWS 无服务器开发实用工具集

2019/10/15

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

议程

• 无服务器开发工具集一览

• 本地开发与调试框架 AWS SAM(Serverless Application Model)

• 使用层(AWS Lambda Layer)复用无服务器代码和依赖包

• 使用 Custom Runtime API 封装自定义的运行时环境

• 补充材料

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

无服务器开发工具集一览

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

学习概念

发现需求

原型开发

编写代码

软件测试

调试纠错监控告警

问题定位

运维安全

部署具体场景

使用无服务器开发的过程

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

学习、发现、原型开发阶段

学习概念

发现需求

原型开发

可利用的资源:产品文档https://docs.aws.amazon.com

视频http://aws.amazon.bokecc.com/index.html

动手实验https://github.com/aws-samples/aws-serverless-

workshop-greater-china-region

https://github.com/aws-samples/aws-serverless-

workshops

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

动手实验资源

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

编写

测试

调试

代码编写、测试、调试与部署阶段

部署

可以利用的工具和功能:本地开发与调试AWS SAM, AWS SAM Local

代码复用与自定义运行时环境AWS Lambda Layer, Custom Runtime API

云端IDE、IDE集成工具AWS Cloud9, IDE Toolkits for IntelliJ, Eclipse, VS

Code, PyCharm

快速开始的模版AWS CodeStar, AWS Serverless Application

Repository(SAR)

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

AWS SAM & AWS SAM Local

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

AWS Lambda Layers

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

10

Custom Runtimes API

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

AWS Cloud9

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

12

使用你喜欢的 IDE 来编写和调试 AWS Lambda 代码

AWS Cloud9

Python, Node

AWS Toolkit for PyCharm

Python

AWS Toolkit for IntelliJ

Java, Python

AWS Toolkit for Visual Studio

Code

.NET, Node

https://aws.amazon.com/cn/visualstudiocode/

https://aws.amazon.com/cn/intellij/

https://aws.amazon.com/cn/visualstudio/

https://aws.amazon.com/cn/eclipse/

https://aws.amazon.com/cn/pycharm/

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

AWS CodeStar

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

使用 AWS 服务实现无服务器应用的持续交付

AWS CodeBuild

+ Third Party

AWS CodeCommit AWS CodeBuild AWS CodeDeploy AWS X-Ray

代码 构建 测试 部署 监控

AWS CodePipeline

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

故障发现与定位,监控和运维

故障监控与发现

故障定位

运维与安全

可以利用的工具:业务、服务指标AWS CloudWatch

业务、服务日志AWS CloudWatch log

应用性能监控AWS X-Ray

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

总结:工具集一览

学习概念

需求发现

原型开发

代码编写

应用测试

代码调试监控发现

故障定位

运维安全

应用部署具体场景

AWSDocs, AWS Lambda Console,

AWS SAM,

Workshops(AWSLAB)

AWS SAM, AWS Toolkits for

popular IDEs, AWS Cloud9,

AWS CodeDeploy, AWS

CodeStar

AWS X-Ray, Amazon CloudWatch

三方工具Stackery, Serverless

Framework (SLS)

SLS, Pulumi, Stackery,

Codeship, GitLab, CloudBees

Datadog, Splunk, Loggly, IOPipe, New Relic,

Sumo Logic, App Dynamics, Epsagon,

SignalFX, Thundra, Protego, Twistlock,

Puresec

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

AWS SAM

(Serverless Application Model)本地开发与调试框架

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

无服务器应用开发

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

构建一个无服务器的部署包

Node.js & Python Java

• 将所有源码和依赖打包为一个zip包,或者一个单独的jar

• 使用Maven/Eclipse

IDE插件

• 将编译好的类核资源文件部署在根目录下,需要的jar包部署在/lib目录下

C# (.NET Core)

• 将所有源码和依赖打包为一个zip包,或者一个单独的dll

文件

• 使用NuGet/VisualStudi

o的插件

• 所有程序集dll都需要在根目录下

Go

• Zip包需要包含Go的

二进制文件和所有依赖

• 使用go get来安装依赖

• 打包正包含代码和所有依赖的zip包

• 使用npm/pip来安装依赖库

• 所有依赖包需要在zip

包的根目录内

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

AWS SAM (Serverless Application Framework)AWS CloudFormation 模版

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'

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

第三方 Serverless 部署框架

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

AWS SAM (Serverless Application Framework)AWS 维护并开源的无服务器开发框架

基于AWS CloudFormation实现的,针对无服务器开发而优化的框架

支持无服务器应用的本地开发和调试

支持常用的无服务器资源类型并简化其配置,如AWS

Lambda、Amazon API Gateway以及Amazon

DynamoDB Table

支持所有AWS CloudFormation所支持的资源

开源许可 (Apache 2.0)

https://github.com/awslabs/serverless-application-model

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

AWS SAM 模版文件

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

告诉AWS CloudFormation这是一个AWS SAM模版,需要“transform”为原生模版

创建 AWS Lambda Function并作相关配置

同时创建了Amazon API Gateway

并且自动配置好所有设定

创建 Amazon DynamoDB Table

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

AWS SAM 模版支持的字段和属性

AWS::Serverless::Function

AWS::Serverless::Api

AWS::Serverless::SimpleTable

AWS::Serverless::Application

AWS::Serverless::LayerVersion

StageName: prod

DefinitionUri: swagger.yml

CacheClusterEnabled: true

CacheClusterSize: 28.4

EndpointConfiguration: REGIONAL

Variables:

VarName: VarValue

https://github.com/awslabs/serverless-application-

model/blob/master/versions/2016-10-31.md#awsserverlessapplication

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

使用 AWS CloudFormation 原生模版APIG4XXErrorAlarm:

Type: "AWS::CloudWatch::Alarm"

Properties:

ActionsEnabled: true

AlarmDescription: "APIG too many 4xx errors"

AlarmName:

'Fn::Sub': 'sam-apidemo-${Env} too many 4xx errors'

ComparisonOperator: GreaterThanThreshold

Dimensions:

-

Name: 'ApiName'

Value:

'Fn::Sub': '${AWS::StackName}'

-

Name: 'Stage'

Value: 'Prod'

EvaluationPeriods: "1"

MetricName: 4XXError

Namespace: AWS/ApiGateway

Statistic: "Sum"

Threshold: "1"

TreatMissingData: "notBreaching"

Unit: "Count"

https://docs.aws.amazon.com/zh_cn/AWS

CloudFormation/latest/UserGuide/templa

te-reference.html

对AWS SAM没有特殊支持的资源,可直接应用 AWS

CloudFormation 的模版。

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

AWS SAM (Serverless Application Framework)AWS SAM CLI

• 使用开源docker-lambda 镜像本地模拟 AWS

Lambda的执行环境

o 模拟超时, 内存限制, 运行时环境

• 本地触发 AWS Lambda 函数

• 本地运行 Amazon API Gateway

• 模拟各类常见的事件源 Amazon S3,Amazon

DynamoDB,Amazon Kinesis 等

• 支持实时 Debug Java、Node.js、Python

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

AWS SAM 两个重要的命令 - Package & Deploy

Package

• 创建部署包(.zip file)

• 自动上传部署包到指定的 Amazon S3 bucket临时存放

• 返回 AWS CloudFormation的YAML并且改写CodeUri属性指向这个Amazon

S3 URI(以方便接下来通过AWS CloudFormation部署)

Deploy

• 调用 AWS CloudFormation ‘CreateChangeSet’ API创建ChangeSet

• 调用 AWS CloudFormation ‘ExecuteChangeSet’ API创建或更新Serverless环境

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

#!/bin/bash

REPLACE_THIS_WITH_YOUR_S3_BUCKET_NAME="hzchen-private-ore"

REGION="us-west-2"

STACK="sam-apidemo-prod"

pip install -r requirements.txt -t apidemo/build/ && \

cp apidemo/*.py apidemo/build/ && \

sam validate && \

sam package --template-file template.yaml --output-template-file packaged.yaml

--s3-bucket $REPLACE_THIS_WITH_YOUR_S3_BUCKET_NAME --region $REGION && \

sam deploy --template-file packaged.yaml --stack-name $STACK --capabilities CAPABILITY_IAM

--parameter-overrides Env=staging DeploymentPreference=AllAtOnce --region $REGION && \

aws cloudformation describe-stacks --stack-name $STACK --query 'Stacks[].Outputs' --region $REGION

AWS SAM 命令的应用

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

AWS SAM 安全部署(Safe Deployment)

Globals:Function:

Runtime: nodejs4.3

AutoPublishAlias: !Ref ENVIRONMENT

MyLambdaFunction:Type: AWS::Serverless::Function

Properties:Handler: index.handlerDeploymentPreference:

Type: Linear10PercentEvery10MinutesAlarms:

# A list of alarms that you want to monitor- !Ref AliasErrorMetricGreaterThanZeroAlarm- !Ref LatestVersionErrorMetricGreaterThanZeroAlarm

Hooks:# Validation Lambda functions that are run before & after

traffic shiftingPreTraffic: !Ref PreTrafficLambdaFunctionPostTraffic: !Ref PostTrafficLambdaFunction

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

AWS Lambda 基于别名的流量切换与 AWS SAM 的集成

AutoPublishAlias

在使用该字段并赋值一个别名后, AWS

SAM 将自动处理以下操作:

• 根据提供的AWS Lambda函数的Amazon S3 URI,检测代码是否有更新

• 用最新的代码创建或者发布一个更新的函数版本

• 创建一个你提供的AWS Lambda别名

(除非该别名已存在)并将该别名指向最新的AWS Lambda函数版本

Deployment Preference类型

Canary10Percent30Minutes

Canary10Percent5Minutes

Canary10Percent10Minutes

Canary10Percent15Minutes

Linear10PercentEvery10Minutes

Linear10PercentEvery1Minute

Linear10PercentEvery2Minutes

Linear10PercentEvery3Minutes

AllAtOnce

在 AWS SAM 模版内:

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

基于告警的迅速回滚

Alarms: # 以下每行代表一个相关联的告警

- !Ref AliasErrorMetricGreaterThanZeroAlarm

- !Ref LatestVersionErrorMetricGreaterThanZeroAlarm

Hooks: # 用于在切换流量前后用于验证的Lambda函数

PreTraffic: !Ref PreTrafficLambdaFunction

PostTraffic: !Ref PostTrafficLambdaFunction

在 AWS SAM 模版内:

注意:您可以关联最多10个告警项

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

AWS SAM 的总结

更少的代码(不用写 AWS CloudFormation)

更简单的过程(AWS SAM CLI、AWS SAM Local)

简单的实现对 AWS Lambda 的安全发布

支持金丝雀的方式以及蓝/绿发布

AWS CodeDeploy

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

AWS Lambda Layers复用无服务器代码和依赖包

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

35

依赖包

源代码

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

36

AWS Lambda Layers

一种集中管理被多个函数共享的代码和数据的方式

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

AWS Lambda Layers 的使用场景

维护被多个函数或者第三方依赖库引用的代码

分享不常变动的代码

Layers 可以被跨账号共享、设置为公开,或者被一个 AWS

Organization下的所有账号共享

AWS Lambda

Layers

AWS Lambda

Function

AWS

Lambda

Function

AWS

Lambda

Layers

Account A Account B

Same-account Layers

AWS

Lambda

Layers

Icon made by Freepik from www.flaticon.com

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

使用层(AWS Lambda Layers)

将代码打包到一个 zip 文件中,并以AWS Lambda Layer 的形式上传

Layers 无法修改,但是可以带上版本号以管理更新

当一个 Layers 的某版本被删除、引用权限被取消时,引用它的函数依然可以正常工作,但你无法创建新的引用

Lambda

Layers

arn:aws:lambda:region:accountId:layer:shared-lib

Lambda

Layers

arn:aws:lambda:region:accountId:layer:shared-lib:2

Lambda

Layers

arn:aws:lambda:region:accountId:layer:shared-lib:3

Icon made by Freepik from www.flaticon.com

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

使用层(AWS Lambda Layers)

一个函数可以引用最多5个层,其中的层也可以是自定义的运行时环境(Custom Runtime)

当函数被触发时,层会依照你定义的次序自动部署到函数的执行环境中

部署包的总大小依然受限于 AWS

Lambda 自身的服务限制(解压后不超过250MB)

AWS

Lambda

Layers

AWS

Lambda

Function

AWS

Lambda

Layers

AWS

Lambda

Layers

AWS

Lambda

Layers

AWS

Lambda

Layers

Up to 5 Layers

/opt NodeJS v11.X provided runtime

/opt Node runtime + node_modules

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

将代码依赖库封装到 Layer 中

运行时环境 目录结构

Node.jsnodejs/node_modules

nodejs/node8/node_modules (NODE_PATH)

Pythonpython

python/lib/python3.7/site-packages (site directories)

Java java/lib (CLASSPATH)

Rubyruby/gems/2.5.0 (GEM_PATH)

ruby/lib (RUBY_LIB)

Allbin (PATH)

lib (LD_LIBRARY_PATH)

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

AWS SAM 对层的支持

BashRuntime:Type: AWS::Serverless::LayerVersionProperties:

LayerName: bash-samDescription: Bash Runtime FWIWContentUri: bash_runtimeLicenseInfo: 'MIT-0 license’RetentionPolicy: RetainCompatibleRuntimes: [List]

HelloBashFunction:Type: AWS::Serverless::FunctionProperties:

CodeUri: bash_helloHandler: hello.handlerRuntime: providedLayers:

- !Ref BashRuntime- <LayerTwoArn>

AWS::Serverless::LayerVersion 资源类型支持从本地文件系统或者 Amazon S3

URI 中创建 AWS Lambda 层

层可以被限制为仅限特定的运行时环境使用(通过 CompatibleRuntimes 属性)

从 SAM CLI 0.8.1+开始支持本地或者远程的方式来引用层(通过 ARN)

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

Custom Runtime API封装自定义的运行时环境

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

Custom Runtimes 是什么?

它是一个简易的 API 接口,

帮助客户实现用任何编程语言,任何语言版本来编写自

己的 AWS Lambda函数

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

Custom Runtimes 是什么?

AWS Lambda Runtime API

帮助你实现用任意编程语言的任意版本写 AWS

Lambda 函数的一组简单的接口

Bootstrap

用于将 Runtime API 与你运行时环境集成的一个文件名叫 bootstrap 的可执行文件

Runtime

你的运行时环境所需的执行文件

/runtime API/invocation/next

/init/error /ID/error

/invocation/ID/response

/invocation/ID/error

bootstrap

Process events/headers

Clean up

Initialize and Invoke function

Response/Error handling

AWS

Lambda

Function

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

Lambda Runtime API 的使用

在 AWS Lambda 界面选择运行时环境时,选择自定义的运行时环境

自定义运行时环境的层或者代码包里必须包含一个叫bootstrap 的可执行文件

Bash FWIW

https://docs.aws.amazon.com/lambda/latest/dg/runtimes-walkthrough.html

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

Runtime Bootstrap 的使用

叫 bootstrap 的可执行文件作为 Runtime

HTTP API 和执行函数之间的桥梁

Bootstrap 负责轮询到来的事件,并处理程序响应,错误处理,上下文创建以及函数执行等工作

Runtime API 接口的访问节点与函数入口等信息均通过环境变量来传递

/runtime API/invocation/next

/init/error /ID/error

/invocation/ID/response

/invocation/ID/error

bootstrap

Process events/headers

Clean up

Initialize and Invoke function

Response/Error handling

AWS

Lambda

Function

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

AWS Lambda Runtime API 支持的环境变量

• AWS_LAMBDA_RUNTIME_API

• HOSTNAME:PORT

• _HANDLER

• SCRIPT_NAME.FUNCTION_NAME

• LAMBDA_TASK_ROOT

• The directory that contains the function code

Runtime API的接口定义与更多信息参考: https://docs.aws.amazon.com/lambda/latest/dg/runtimes-api.html

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

48

Custom Runtimes 如何使用?

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

49

Custom Runtimes 如何使用?

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

开源可直接使用的运行时环境

C++ (AWS)

Rust (AWS)

Nim (LambCI)

Erlang (Alert Logic)

Elixir (Alert Logic)

Cobol (Blu Age)

Node.js (NodeSource N|Solid)

PHP (Stackery)

github.com/mthenw/awesome-layers

AWS 和社区已经提供了大量开源且可以直接使用的运行时环境

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

51

AWS Lambda Layers 与 Custom Runtime 总结

AWS Lambda Layers

复用代码和依赖包

安全的共享方式

Custom Runtime API

封装自定义的运行时环境

有助于社区和合作伙伴的发展

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

DEMO!

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

补充材料

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

AWS SAM 文档

AWS Serverless Application Model (SAM) –

https://docs.aws.amazon.com/serverless-application-

model/latest/developerguide/what-is-sam.html

AWS SAM template specification –

https://github.com/awslabs/serverless-application-

model/blob/master/versions/2016-10-31.md#specification

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

动手实验

AWS Lambda Layers –

https://github.com/hawkey999/lambda-layer-demo

https://aws.amazon.com/cn/blogs/china/use-aws-lambda-layer-function/

Custom Runtime –

https://github.com/lazydragon/lambda_custom_runtime

https://aws.amazon.com/cn/blogs/apn/aws-lambda-custom-runtime-for-

php-a-practical-example/

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

其它服务资源

AWS SAR:

https://docs.aws.amazon.com/zh_cn/serverlessrepo/latest/devguide/wh

at-is-serverlessrepo.html

AWS X-Ray:

https://docs.aws.amazon.com/zh_cn/xray/latest/devguide/aws-xray.html

AWS Cloud9:

https://docs.aws.amazon.com/zh_cn/cloud9/latest/user-

guide/welcome.html

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

Q&AName of presenter

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

我们希望您喜欢今天的内容!也请帮助我们完成反馈问卷。

欲获取关于 AWS 的更多信息和技术内容,可以通过以下方式找到我们:

感谢参加 AWS 在线研讨会

微信订阅号:AWS 云计算(awschina)

新浪微博:https://www.weibo.com/amazonaws/

领英:https://www.linkedin.com/company/aws-china/

知乎:https://www.zhihu.com/org/aws-54/activities/

视频中心:http://aws.amazon.bokecc.com/

更多线上活动:https://aws.amazon.com/cn/about-aws/events/webinar/

微信服务号:AWS Builder 俱乐部(amazonaws)

抖音:亚马逊云计算(抖音号:266052872)

AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营AWS 中国(宁夏)区域由西云数据运营AWS 中国(北京)区域由光环新网运营

Thank you!