如何解决尝试使用 SAM 在云形成中创建堆栈并收到错误消息
当我尝试使用 SAM 部署堆栈时,我收到以下错误消息。
“无法为堆栈创建变更集:测试,例如:Water ChangeSetCreateComplete 失败:Water 遇到终端故障状态:对于表达式“Status”,我们匹配了预期路径:“Failed”状态:Failed。原因:模板资源属性无效'KeySchema'"
我正在尝试创建一个 API 网关,该网关连接到将与 DynamoDB 表交互的 Lambda 函数。根据文档 https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/quickref-dynamodb.html
,我的 YAML 模板文件有效,KeySchema 似乎是有效的资源属性我的 Yaml 文件看起来像这样
AWstemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: "Stack for DynamoDB,Lambda and APIGateway"
Resources:
CounterFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: Backend/
Handler: lambda.lambda_handler
Runtime: python3.8
Events:
VisitorData:
Type: Api
Properties:
Path: /Counter
Method: get
Visitors:
Type: AWS::DyanmoDB::Table
Properties:
AttributeDeFinitions:
-
AttributeName: "ID"
AttributeType: "N"
-
AttributeName: "Counter"
AttributeType: "N"
KeySchema:
- AttributeName: "ID"
KeyType: "HASH"
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
Outputs:
VisitorDataApi:
Description: "API Gateway endpoint URL for Prod stage for Counter Function"
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello/"
CounterFunction:
Description: "Counter Function lambda ARN"
Value: !GetAtt CounterFunction.Arn
HelloWorldFunctionIamRole:
Description: "Implicit IAM Role created for Counter Function"
Value: !GetAtt Lambda-Get-Function-role-40isam1j
Visitors Table:
Description: "Visitor table ARN"
Value: !GetAtt "Visitors.ARN"
解决方法
应该是:
Type: AWS::DynamoDB::Table
不是:
Type: AWS::DyanmoDB::Table
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。