【发布时间】:2021-02-08 01:07:27
【问题描述】:
我正在尝试将 EFS 挂载到我的 Lambda 函数,以便我可以使用大型依赖项。到目前为止,我一直在关注this 教程。
我稍微修改了.yml。
serverless.yml
service: test2EFS
plugins:
- serverless-pseudo-parameters
custom:
efsAccessPoint: fsap-00**********
LocalMountPath: /mnt/efs
subnetsId: subnet-0b**********
securityGroup: sg-0b7**********
provider:
name: aws
runtime: python3.6
region: us-east-2
package:
exclude:
- node_modules/**
- .vscode/**
- .serverless/**
- .pytest_cache/**
- __pychache__/**
functions:
test:
handler: handler.handler
environment: # Service wide environment variables
MNT_DIR: ${self:custom.LocalMountPath}
vpc:
securityGroupIds:
- ${self:custom.securityGroup}
subnetIds:
- ${self:custom.subnetsId}
iamManagedPolicies:
- arn:aws:iam::aws:policy/AmazonElasticFileSystemClientReadWriteAccess
events:
- http:
path: test
method: get
resources:
extensions:
# Name of function
test2EFSLambdaFunction:
Properties:
FileSystemConfigs:
- Arn: 'arn:aws:elasticfilesystem:${self:provider.region}:#{AWS::AccountId}:access-point/${self:custom.efsAccessPoint}'
LocalMountPath: '${self:custom.LocalMountPath}'
每当我运行 severless deploy 时,我都会收到以下错误:
Serverless: Uploading artifacts...
Serverless: Uploading service test2EFS.zip file to S3 (926 B)...
Serverless: Validating template...
Error --------------------------------------------------
Error: The CloudFormation template is invalid: Template format error: [/Resources/test2EFSLambdaFunction] Every Resources object must contain a Type member.
at provider.request.catch (/usr/local/lib/node_modules/serverless/lib/plugins/aws/deploy/lib/validateTemplate.js:20:13)
at tryCatcher (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromise0 (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:725:18)
at _drainQueueStep (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:93:12)
at _drainQueue (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:86:9)
at Async._drainQueues (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:102:5)
at Immediate.Async.drainQueues [as _onImmediate] (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:15:14)
at runCallback (timers.js:705:18)
at tryOnImmediate (timers.js:676:5)
at processImmediate (timers.js:658:5)
at process.topLevelDomainCallback (domain.js:126:23)
我尝试注释掉各个部分,并将错误范围缩小到某个范围内
resources:
extensions:
# Name of function
test2EFSLambdaFunction:
Properties:
FileSystemConfigs:
- Arn: 'arn:aws:elasticfilesystem:${self:provider.region}:#{AWS::AccountId}:access-point/${self:custom.efsAccessPoint}'
LocalMountPath: '${self:custom.LocalMountPath}'
除了重命名(我认为是)无关紧要的函数名称之外,此代码 sn-p 与引用相同。我尝试根据我的帐户 ID 对#{AWS::AccountId} 进行硬编码,但这没有用。我现在有点难过。
【问题讨论】:
标签: aws-lambda serverless-framework amazon-efs