Ada*_*dam 11 amazon-web-services aws-cloudformation
部署 CloudFormation 堆栈时获取以下信息:
REST API 不包含任何方法(服务:AmazonApiGateway;状态代码:400;错误代码:BadRequestException;请求 ID:d527f56e-a1e1-11e9-a0a4-af7563b2b15a)
该堆栈具有由具有单个资源和方法的 API 触发的单个 Lambda:
FailureReporting:
Type: "AWS::ApiGateway::RestApi"
DependsOn: "MyLambdaFunction"
Properties:
Name: "FailureReporting"
FailOnWarnings: true
FailureReportingDeployment:
Type: AWS::ApiGateway::Deployment
Properties:
RestApiId:
Ref: "FailureReporting"
Description: "Production environment supporting version-1 of the interface."
StageName: "v1"
Failures:
Type: "AWS::ApiGateway::Resource"
Properties:
RestApiId: !Ref "FailureReporting"
ParentId: !GetAtt ["FailureReporting", "RootResourceId"]
PathPart: "failures"
FailuresMethodGet:
Type: "AWS::ApiGateway::Method"
Properties:
RestApiId: !Ref "FailureReporting"
ResourceId: !Ref "Failures"
HttpMethod: "GET"
AuthorizationType: "NONE"
MethodResponses:
- StatusCode: "200"
Integration:
IntegrationHttpMethod: "POST"
Type: "AWS_PROXY"
IntegrationResponses:
- StatusCode: "200"
Credentials: !GetAtt [ 3FailureReportingExecuteAPI, Arn ]
Uri: !Sub
- "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${lambdaArn}/invocations"
- lambdaArn: !GetAtt [ GetFailureKeysByOrderNumber, Arn ]
Run Code Online (Sandbox Code Playgroud)
我错过了我搞砸的地方。
小智 14
放一个DependsOn部署资源:
FailureReportingDeployment:
Type: AWS::ApiGateway::Deployment
DependsOn:
- "FailuresMethodGet"
Properties:
Description: "Production environment supporting version-1 of the interface."
RestApiId: !Ref "FailureReporting"
StageName: "v1"
Run Code Online (Sandbox Code Playgroud)
这不直观。在文档中,您会发现以下内容:
如果您在与部署相同的模板中创建 AWS::ApiGateway::RestApi 资源及其方法(使用 AWS::ApiGateway::Method),则部署必须依赖于 RestApi 的方法。要创建依赖项,请将 DependsOn 属性添加到部署。如果不这样做,AWS CloudFormation 会在创建不包含任何方法的 RestApi 资源后立即创建部署,并且 AWS CloudFormation 遇到以下错误:REST API 不包含任何方法。
| 归档时间: |
|
| 查看次数: |
4193 次 |
| 最近记录: |