我有一个用于 AWS 节点项目的无服务器 yml 文件。我还在另一个文件中有一个 dynamodb 表。我可以毫无问题地部署项目,但是 VSCode 在我的导入行中显示红色警报问题:预期类型不正确...
无服务器.yml
service: auction-service
plugins:
- serverless-bundle
- serverless-pseudo-parameters
provider:
name: aws
runtime: nodejs12.x
memorySize: 256
stage: ${opt:stage, 'dev'}
region: eu-west-1
environment:
AUCTIONS_TABLE_NAME: ${self:custom.AuctionsTable.name}
iam:
role:
statements:
- ${file(iam/AuctionsTableIAM.yml):AuctionsTableIAM}
resources:
Resources:
AuctionsTable: ${file(resources/AuctionsTable.yml):AuctionsTable}
functions:
createAuction:
handler: src/handlers/createAuction.handler
events:
- http:
method: POST
path: /auction
custom:
AuctionsTable:
name: !Ref AuctionsTable
arn: !GetAtt AuctionsTable.Arn
bundle:
linting: false
拍卖表.yml:
[![AuctionsTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: AuctionsTable--${self:provider.stage}
BillingMode: PAY_PER_REQUEST
AttributeDefinitions:
- AttributeName: id
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH][1]][1]
最佳答案
试试这个
resources:
Resources:
- ${file(resources/AuctionsTable.yml):AuctionsTable}
请注意,您需要将名称 AuctionsTable
添加到导入的文件中。
关于aws-lambda - 导入 DynamoDB 表 - YML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71671365/