gpt4 book ai didi

amazon-web-services - 云形成 : extraneous key [DependsOn] is not permitted

转载 作者:行者123 更新时间:2023-12-03 07:22:47 30 4
gpt4 key购买 nike

使用 SAM(API 网关 + Lambda)构建简单的 Hello World API。有人告诉我 DependsOn 应该适用于所有资源。

API 配置为:

HelloWorldAPI:
Type: AWS::Serverless::Api
# Type: AWS::ApiGateway::RestApi
Properties:
Name: HelloWorldApi
StageName: !Ref StageName

HelloWorldAPIResource:
Type: AWS::ApiGateway::Resource
Properties:
RestApiId: !Ref HelloWorldAPI
ParentId: !GetAtt HelloWorldAPI.RootResourceId
PathPart: hello

HelloWorldAPIMethod:
Type: AWS::ApiGateway::Method
Properties:
AuthorizationType: NONE
HttpMethod: GET
ResourceId: !Ref HelloWorldAPIResource
RestApiId: !Ref HelloWorldAPI
Integration:
Type: AWS_PROXY
IntegrationHttpMethod: GET
Uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${HelloWorldFunction.Arn}/invocations
# - Arn: !GetAtt HelloWorldFunction.Arn

HelloWorldAPIDeployment:
Type: AWS::ApiGateway::Deployment
Properties:
RestApiId: !Ref HelloWorldAPI
StageName: !Ref StageName
DependsOn:
- HelloWorldAPIMethod

但是我在部署过程中遇到以下错误:

CREATE_FAILED                                   AWS::ApiGateway::Deployment                     HelloWorldAPIDeployment                         Properties validation failed for resource     
HelloWorldAPIDeployment with message: #:
extraneous key [DependsOn] is not permitted
CREATE_FAILED AWS::ApiGateway::Resource HelloWorldAPIResource Resource creation cancelled
CREATE_FAILED AWS::ApiGateway::Deployment HelloWorldAPIDeployment5332c373d4 Resource handler returned message: "The REST
API doesn't contain any methods (Service:
ApiGateway, Status Code: 400, Request ID:
634b4de5-ead7-48f5-8075-ab55d7176189,
Extended Request ID: null)" (RequestToken:
ef65a5fd-cdf4-fe14-2010-a513bca36aca,
HandlerErrorCode: InvalidRequest)

显式定义的 AWS::ApiGateway::Deployment 无法使用 DependsOn,而还有另一个 AWS::ApiGateway::Deployment > 隐式创建但不必要,它在方法之前部署,这就是我首先显式定义一个的原因。

感谢任何帮助。

最佳答案

DependsOn 应该少一个最后一个选项卡:


HelloWorldAPIDeployment:
Type: AWS::ApiGateway::Deployment
Properties:
RestApiId: !Ref HelloWorldAPI
StageName: !Ref StageName
DependsOn:
- HelloWorldAPIMethod

关于amazon-web-services - 云形成 : extraneous key [DependsOn] is not permitted,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71114536/

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