amazon-web-services - 尝试使用 SAM 在云形成中创建堆栈并收到错误消息
问题描述
当我尝试使用 SAM 部署堆栈时,我收到以下错误消息。
“无法为堆栈创建变更集:测试,例如:Waiter ChangeSetCreateComplete 失败:Waiter 遇到终端故障状态:对于表达式“状态”,我们匹配预期路径:“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
推荐阅读
- ionic-framework - 离子菜单的推送和显示类型不起作用
- android - Why my app opens wrong folder in filemanager dialog?
- sql - 如何检索包内的方法类型?
- apache-poi - 如何附加现有表?
- vue.js - VUE js 在不同的组件层次结构中调用子组件方法
- amazon-web-services - 将弹性 IP 地址分配给现有/正在运行的 Amazon EC2 实例
- ios - 如何获得 App Store 上可用的任何应用程序的 IPA?(旧方法行不通)
- javascript - 如何在 react-google-maps 中嵌入 textview?
- pandas - 将 Pandas 交叉表数据框绘制成 3D 条形图
- kubernetes - 更新 Kubernetes 作业:会发生什么?