【问题标题】:VPC endpoint in Cloudformation - Endpoint type (Gateway) does not match available service types ([Interface])Cloudformation 中的 VPC 端点 - 端点类型(网关)与可用服务类型不匹配([接口])
【发布时间】:2021-04-17 19:04:19
【问题描述】:

我正在尝试在 Cloudformation 中为 API 网关创建 VPC 端点,但收到此错误:

Endpoint type (Gateway) does not match available service types ([Interface]).

下面的模板放在资源部分:

  executeApiEndpoint:
    Type: AWS::EC2::VPCEndpoint
    Properties:
      PolicyDocument:
        Version: '2012-10-17'
        Statement:
          - Effect: Allow
            Principal: "*"
            Action:
              - "execute-api:Invoke"
              - "execute-api:ManageConnections"
            Resource:
              - "arn:aws:execute-api:*:*:*"
      RouteTableIds:
        - !Ref privateRouteTable
      ServiceName: !Sub com.amazonaws.${AWS::Region}.execute-api
      VpcId: !Ref pubPrivateVPC

这个也不行:

  executeApiEndpoint:
    Type: AWS::EC2::VPCEndpoint
    Properties:
      PolicyDocument:
        Version: '2012-10-17'
        Statement:
          - Effect: Allow
            Principal: "*"
            Action:
              - "execute-api:*"
            Resource:
              - "*"
      RouteTableIds:
        - !Ref privateRouteTable
      ServiceName: !Sub com.amazonaws.${AWS::Region}.execute-api
      VpcId: !Ref pubPrivateVPC

然而,这个块(来自一个模板)能够被执行而没有任何错误:

  s3Endpoint:
    Type: AWS::EC2::VPCEndpoint
    Properties:
      PolicyDocument:
        Version: 2012-10-17
        Statement:
          - Effect: Allow
            Principal: "*"
            Action:
              - "s3:*"
            Resource:
              - "*"
      RouteTableIds:
        - !Ref privateRouteTable
      ServiceName: !Sub com.amazonaws.${AWS::Region}.s3
      VpcId: !Ref pubPrivateVPC

这里出了什么问题?

【问题讨论】:

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


    【解决方案1】:

    您还必须将AWS::EC2::VPCEndpoint 资源上的VpcEndpointType property 指定为Interface,接口类型的VPC 端点才能工作。默认为“网关”,仅适用于 S3 和 DynamoDB VPC 端点。

    您的解决方案使用 S3 作为端点的原因是因为 VpcEndpointType 属性具有“网关”作为默认值(适用于 S3)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-02
      • 1970-01-01
      • 2020-09-08
      • 1970-01-01
      • 2020-02-17
      相关资源
      最近更新 更多