【问题标题】:Failed to create API Gateway创建 API 网关失败
【发布时间】:2019-06-06 23:23:49
【问题描述】:

我正在尝试使用 Authorizer 和任何方法创建此 API 网关 (gist)。

我遇到了这个错误:

The following resource(s) failed to create: [BaseLambdaExecutionPolicy, ApiGatewayDeployment]

我检查了从其他堆栈传递到此模板的参数,它们是正确的。我检查了这个模板,它是有效的。

我的模板是从这个template 修改为"Runtime": "nodejs8.10"

这是使用 swagger 2 成功创建的同一堆栈 (gist)。我只想用AWS::ApiGateway::Method 替换swagger 2

2019 年 6 月 6 日更新:

我尝试使用 API 网关堆栈的工作版本创建整个嵌套堆栈,然后使用不适用于我从嵌套堆栈获得的参数的模板创建另一个 API 网关,然后我有这个:

The REST API doesn't contain any methods (Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException; Request ID: ID)

但我确实在AWS docs 之后的模板中指定了方法:

"GatewayMethod": {
            "Type" : "AWS::ApiGateway::Method",
            "DependsOn": ["LambdaRole", "ApiGateway"],
            "Properties" : {
                "ApiKeyRequired" : false,
                "AuthorizationType" : "Cognito",
                "HttpMethod" : "ANY",
                "Integration" : {
                    "IntegrationHttpMethod" : "ANY",
                    "Type" : "AWS",
                    "Uri" : {
                        "Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${LambdaFunction.Arn}/invocations"
                    }
                },
                "MethodResponses" : [{
                    "ResponseModels": {
                      "application/json": "Empty"
                    },
                    "StatusCode": 200
                }],
                "RequestModels" : {"application/json": "Empty"},
                "ResourceId" : {
                    "Fn::GetAtt": ["ApiGateway", "RootResourceId"] 
                },
                "RestApiId" : {
                    "Ref": "ApiGateway"
                }
            }
        },

【问题讨论】:

  • 您可能应该回到有效的版本,然后一次添加一个资源,以确定是哪个资源导致了错误。
  • 大概堆栈事件会给你更多关于它为什么失败的信息?
  • @JohnRotenstein 感谢您的建议,这就是我想要做的:使用有效的版本创建嵌套堆栈,并为无效的版本传递参数。我会相应地更新我的问题。
  • @404:不幸的是,这就是针对特定问题向我展示的全部内容。

标签: amazon-web-services amazon-cloudformation aws-api-gateway


【解决方案1】:

感谢@John 的建议。我尝试使用有效的版本创建嵌套堆栈,并为无效的版本传递参数。

该错误的原因是:

CloudFormation 可能会在创建方法之前尝试创建部署

来自balaji的回答here

这就是我所做的:

"methodANY": {
            "Type": "AWS::ApiGateway::Method",
            "Properties": {
              "AuthorizationType": "COGNITO_USER_POOLS",
...},
"ApiGatewayDeployment": {
            "Type": "AWS::ApiGateway::Deployment",
            "DependsOn": "methodANY",
...

我还发现 this article on cloudonaut.io by Michael Wittig 很有帮助。

【讨论】:

    猜你喜欢
    • 2021-05-09
    • 2019-07-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-30
    相关资源
    最近更新 更多