无服务器部署具有特定依赖关系的 lambda@edge
serverless deploy lambda@edge with specific dependency
我想部署从 CloudFront 将图像转换为 WebP 的功能,如前所述 here
但我想使用 serverless
框架,我创建了以下 serverless.yml
和我的 handler.js
service: viewer-image-request
plugins:
- serverless-plugin-include-dependencies
provider:
name: aws
runtime: nodejs12.x
region: us-east-1
resources:
Resources:
LambdaAtEdgeRole:
Type: AWS::IAM::Role
Properties:
RoleName: lambda-at-edge
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
- edgelambda.amazonaws.com
Action: sts:AssumeRole
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
functions:
viewer-request:
handler: handler.handler
role: LambdaAtEdgeRole
package:
exclude:
- node_modules/**
include:
- node_modules/path
- node_modules/useragent
当我部署它时,它会上传 lru-cache
、os-tempdir
、pseudomap
、tmp
、useragent
、yallist
到 node_modules.代码只需要 useragent
& path
,但 path
不会上传。
函数部署后大小为91kB
当我尝试部署 Lambda@Edge 时,我收到了这条消息
我在这里缺少什么?
看来 the default values for serverless.yml 是:
provider:
memorySize: 1024
timeout: 6
根据错误消息,这些是您需要使用的值:
provider:
memorySize: 128
timeout: 5
我想部署从 CloudFront 将图像转换为 WebP 的功能,如前所述 here
但我想使用 serverless
框架,我创建了以下 serverless.yml
和我的 handler.js
service: viewer-image-request
plugins:
- serverless-plugin-include-dependencies
provider:
name: aws
runtime: nodejs12.x
region: us-east-1
resources:
Resources:
LambdaAtEdgeRole:
Type: AWS::IAM::Role
Properties:
RoleName: lambda-at-edge
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
- edgelambda.amazonaws.com
Action: sts:AssumeRole
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
functions:
viewer-request:
handler: handler.handler
role: LambdaAtEdgeRole
package:
exclude:
- node_modules/**
include:
- node_modules/path
- node_modules/useragent
当我部署它时,它会上传 lru-cache
、os-tempdir
、pseudomap
、tmp
、useragent
、yallist
到 node_modules.代码只需要 useragent
& path
,但 path
不会上传。
函数部署后大小为91kB
当我尝试部署 Lambda@Edge 时,我收到了这条消息
我在这里缺少什么?
看来 the default values for serverless.yml 是:
provider:
memorySize: 1024
timeout: 6
根据错误消息,这些是您需要使用的值:
provider:
memorySize: 128
timeout: 5