Reputation: 7028
I want to deploy function for Converting images to WebP from CloudFront as mentioned here
But I want to use serverless
framework and I have created following serverless.yml
& my 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
When I deploy this it uploads lru-cache
, os-tempdir
, pseudomap
, tmp
, useragent
, yallist
to node_modules. Code only required useragent
& path
, but path
doesn't get uploaded.
After deploy size of the function is 91kB
When I try to deploy it Lambda@Edge I gate this message
What I am missing here ?
Upvotes: 2
Views: 494
Reputation: 3044
It appears that the default values for serverless.yml are:
provider:
memorySize: 1024
timeout: 6
According to the error message, these are the values that you need to use:
provider:
memorySize: 128
timeout: 5
Upvotes: 3