如何通过CloudFormation附加VPC链接以获取API网关中的方法

时间:2018-07-01 22:32:07

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

我正在尝试通过cloudformation创建一个api网关,该网关使用到内部beantalk网络负载均衡器的vpc链接:

这是我创建vpc链接的代码:

  VpcLink:
  Type: AWS::ApiGateway::VpcLink
  Properties:
      Description: vpc link
      Name: channel-vpc-link
      TargetArns:
          - !ImportValue channel-dns-arn

这是我的api gtw代码:

GetMethod:
Type: AWS::ApiGateway::Method
DependsOn: VpcLink
Properties:
  AuthorizationType: NONE
  HttpMethod: GET
  #RequestParameters:
  #  method.request.path.proxy: true
  Integration:
    Type: HTTP
    IntegrationHttpMethod: GET
    Uri:
      Fn::Join:
      - ''
      - - "http://"
        - ${stageVariables.channelUrl}
        - "/channels"
        - "/stories"
    IntegrationResponses:
    - StatusCode: 200
      ResponseParameters:
        method.response.header.Access-Control-Allow-Origin: "'*'"
      ResponseTemplates:
        application/json: ''
    RequestTemplates:
      application/json: ''
  ResourceId: !Ref ChannelsStoriesPath
  RestApiId:
    Ref: RestApi
  MethodResponses:
  - StatusCode: 200
    ResponseParameters:
        method.response.header.Access-Control-Allow-Origin: true

可以正常工作,但是问题是我无法找到一种方法来附加我先前在get方法代码中创建的vpc链接。如何通过vpc链接设置get方法?

我找到了此链接,但根本没有帮助

https://forums.aws.amazon.com/thread.jspa?threadID=275511

1 个答案:

答案 0 :(得分:0)

支持在AWS :: ApiGateway :: Method中设置VPCLink的工作正在进行中。到目前为止,支持的选项是使用swagger模板创建具有VPCLink集成的RestAPI