该区域不支持端点配置类型EDGE

时间:2019-02-01 20:42:49

标签: yaml amazon-cloudformation aws-api-gateway

我正在尝试通过CloudFormation(YAML + Swagger)启动AWS API网关。

当尝试通过控制台启动堆栈时,我一直在获取;

“此区域不支持端点配置类型EDGE:us-gov-west-1”

我已将Endpoint Configuration(端点配置)指定为“ REGIONAL”,但似乎没有用。

此API网关已通过控制台成功创建,因此我认为它应该可以通过CloudFormation使用。

在这一点上,我猜测默认情况下它将与EDGE一起使用,而在gov区域甚至可能不支持此功能。

AWSTemplateFormatVersion: '2010-09-09'
Resources:
  rTestAPI:
    Type: AWS::ApiGateway::RestApi
    Properties:
      Name: Test API
      Description: A test API
      EndpointConfiguration:
        Types:
          - REGIONAL
      Body:
        swagger: '2.0'
        info:
          version: '2019-01-11T16:05:08Z'
          title: test-api
        # host: 9lazpn2fob.execute-api.us-gov-west-1.amazonaws.com
        basePath: /default
        schemes:
          - https
        paths:
          /test:
            post:
              consumes:
                - application/json
                - application/x-www-form-urlencoded
              produces:
                - application/json
                - text/html
              responses:
                '200':
                  description: 200 response
                  schema:
                    $ref: '#/definitions/Empty'
                  headers:
                    Access-Control-Allow-Origin:
                      type: string
                    Access-Control-Allow-Headers:
                      type: string
                    Content-Type:
                      type: string
                '400':
                  description: 400 response
                  schema:
                    $ref: '#/definitions/Error'
                  headers:
                    Access-Control-Allow-Origin:
                      type: string
                    Access-Control-Allow-Headers:
                      type: string
                    Content-Type:
                      type: string
            options:
              consumes:
                - application/json
              produces:
                - application/json
              responses:
                '200':
                  description: 200 response
                  schema:
                    $ref: '#/definitions/surveydata'
                  headers:
                    Access-Control-Allow-Origin:
                      type: string
                    Access-Control-Allow-Methods:
                      type: string
                    Access-Control-Allow-Headers:
                      type: string
        definitions:
          Empty:
            type: object
            title: Empty Schema
          Error:
            type: object
            properties:
              message:
                type: string
            title: Error Schema
          surveydata:
            type: object
            properties:
              name:
                type: string
            title: Survey Data Schema

我的预期结果是CloudFormation创建具有REGIONAL端点的API网关。

2 个答案:

答案 0 :(得分:2)

我在中国也遇到了同样的问题,我更新了一个堆栈,使其包含了可工作的Swagger主体,而我创建的另一个堆栈却不起作用。

因此,我唯一可以使用的解决方法是在没有Swagger主体的情况下部署堆栈和API网关,然后包括Swagger主体并更新堆栈。我所做的就是创建这个空堆栈:

{
    "AWSTemplateFormatVersion": "2010-09-09",
    "Description": "The AWS CloudFormation template for this Serverless application",
    "Resources": {
        "ApiGatewayRestApi": {
            "Type": "AWS::ApiGateway::RestApi",
            "Properties": {
                "Name": "my-api-name",
                "EndpointConfiguration": {
                    "Types": [ "REGIONAL" ]
                }
            }
        }
    }
}

已成功创建。请注意,必须使用相同的逻辑ID才能对其进行更新(在我的情况下为“ ApiGatewayRestApi”)。之后,我使用Swagger提取了实际模板并对其进行了更新。

希望这会有所帮助!

答案 1 :(得分:0)

使用Body导入Swagger时,CFN会忽略EndpointConfiguration字段。要解决此问题,请尝试按照以下示例将endpointConfigurationTypes添加到Parameters

 ApiGatewayApi:
    Type: AWS::ApiGateway::RestApi
    Properties:
      Parameters:
        endpointConfigurationTypes: REGIONAL
        ignore: documentation
      BodyS3Location:
        Bucket: BATS::SAM::CodeS3Bucket
        Key:xxxxxx
      EndpointConfiguration:
        Types:
        - REGIONAL
相关问题