2021年2月7日星期日

Serverless Framework Error: Every Resources object must contain a Type member

I'm trying to mount an EFS to my Lambda function so that I can use large dependencies. So far I've been following this tutorial.

I slightly modified the .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}'  

Whenever I run severless deploy I get the following error:

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)  

I tried commenting out various parts, and narrowed down the error to somewhere within

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}'  

besides renaming (what I think is) an insignificant function name, this code snippet is the same as the reference. I tried hard coding #{AWS::AccountId} based on my account ID, but that didn't work. I'm now a bit stumped.

https://stackoverflow.com/questions/66094737/serverless-framework-error-every-resources-object-must-contain-a-type-member February 08, 2021 at 09:07AM

没有评论:

发表评论