gpt4 book ai didi

amazon-web-services - AWS sam部署失败: Waiter ChangeSetCreateComplete failed: Max attempts exceeded

转载 作者:行者123 更新时间:2023-12-03 07:34:21 24 4
gpt4 key购买 nike

刚刚向我的堆栈的 template.yaml 添加了一个 DynamoDB 表。运行 aws deploy 卡住一段时间并显示消息正在等待创建变更集..几分钟后失败了

File "/usr/local/Cellar/aws-sam-cli/1.26.0/libexec/lib/python3.8/site-packages/samcli/lib/deploy/deployer.py", line 295, in wait_for_changesetreason = resp["StatusReason"]KeyError: 'StatusReason'

我不确定我缺少什么,我相信该用户的 IAM 也拥有所有必需的权限。我对 AWS 非常陌生,因此我们将不胜感激。

我的 template.yaml 是

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
bibbl.io

Sample SAM Template for bibbl.io

# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 3
Environment:
Variables:
TABLE_NAME: my-table


Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: hello_world/
Handler: app.lambda_handler
Runtime: python3.8
Events:
HelloWorld:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: /hello
Method: get
MyTable:
Type: AWS::DynamoDB:Table
Properties:
TableName: my-table
AttributeDefinitions:
- AttributeName: note_id
AttributeType: S
- AttributeName: upload_uri
AttributeType: S
KeySchema:
- AttributeName: note_id
KeyType: HASH
GlobalSecondaryIndexes:
IndexName: "upload_uri"
KeySchema:
- AttributeName: "upload_uri"
KeyType: "HASH"
Projection:
ProjectionType: "ALL"
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
Policies:
- DynamoDBCrudPolicy:
TableName: !Ref MyTable


Outputs:
# ServerlessRestApi is an implicit API created out of Events key under Serverless::Function
# Find out more about other implicit resources you can reference within SAM
# https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api
HelloWorldApi:
Description: "API Gateway endpoint URL for Prod stage for Hello World function"
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello/"
HelloWorldFunction:
Description: "Hello World Lambda Function ARN"
Value: !GetAtt HelloWorldFunction.Arn
HelloWorldFunctionIamRole:
Description: "Implicit IAM Role created for Hello World function"
Value: !GetAtt HelloWorldFunctionRole.Arn
TableName:
Value: !Ref MyTable
Description: Table name of the newly created DynamoDB table

最佳答案

您的 template.yml 中有几个错误。

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
bibbl.io

Sample SAM Template for bibbl.io

# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 3
Environment:
Variables:
TABLE_NAME: my-table


Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: hello_world/
Handler: app.lambda_handler
Runtime: python3.8
Events:
HelloWorld:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: /hello
Method: get
Policies:
- DynamoDBCrudPolicy:
TableName: !Ref MyTable

MyTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: my-table
AttributeDefinitions:
- AttributeName: note_id
AttributeType: S
- AttributeName: upload_uri
AttributeType: S
KeySchema:
- AttributeName: note_id
KeyType: HASH
GlobalSecondaryIndexes:
-
IndexName: "upload_uri"
KeySchema:
- AttributeName: "upload_uri"
KeyType: "HASH"
Projection:
ProjectionType: "ALL"
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5


Outputs:
# ServerlessRestApi is an implicit API created out of Events key under Serverless::Function
# Find out more about other implicit resources you can reference within SAM
# https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api
HelloWorldApi:
Description: "API Gateway endpoint URL for Prod stage for Hello World function"
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello/"
HelloWorldFunction:
Description: "Hello World Lambda Fun ction ARN"
Value: !GetAtt HelloWorldFunction.Arn
HelloWorldFunctionIamRole:
Description: "Implicit IAM Role created for Hello World function"
Value: !GetAtt HelloWorldFunctionRole.Arn
TableName:
Value: !Ref MyTable
Description: Table name of the newly created DynamoDB table
  1. 您的 Dynamo 表类型在 Dynamo 之后缺少第二个冒号。

  2. Policy 属性需要位于您的 Lambda 上,而不是您的表上。您想要让 Lambda 函数访问您的表,而不是您的表本身,这是没有意义的。

  3. GlobalSecondaryIndexes 是对象列表。您缺少指示列表开始的破折号。

关于amazon-web-services - AWS sam部署失败: Waiter ChangeSetCreateComplete failed: Max attempts exceeded,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68552495/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com