VPC Link Integration configuration

I’m wondering why the configuration of VPC Link integrations is so different from every other type of integration you can do with serverless. For example, the API gateway screen is:

So in theory you should be able to follow the documentation here:

service: service-name
provider: aws
functions: ...

resources:
  Resources:
    ProxyResource:
      Type: AWS::ApiGateway::Resource
      Properties:
        ParentId:
          Fn::GetAtt:
            - ApiGatewayRestApi # our default Rest API logical ID
            - RootResourceId
        PathPart: '{proxy+}'
        RestApiId:
          Ref: ApiGatewayRestApi
    ProxyMethod:
      Type: AWS::ApiGateway::Method
      Properties:
        ResourceId:
          Ref: ProxyResource
        RestApiId:
          Ref: ApiGatewayRestApi
        HttpMethod: GET # the method of your proxy. Is it GET or POST or ... ?
        MethodResponses:
          - StatusCode: 200
        Integration:
          IntegrationHttpMethod: POST
          Type: HTTP_PROXY
          Uri: http://serverless.com/{proxy} # the URL you want to set a proxy to
          IntegrationResponses:
            - StatusCode: 200
          RequestParameters:
             integration.request.path.proxy: method.request.path.proxy

And substitute HTTP_PROXY for VPC_LINK with the added configuration indicating the VPC Link ID. It looks from the documentation however like the only way to use VPC Link is the following:

- http:
    path: v1/repository
    method: get
    integration: http-proxy
    connectionType: vpc-link
    connectionId: '{your-vpc-link-id}'
    cors: true
    request:
      uri: http://www.github.com/v1/repository
      method: get

I’m wondering why there’s such a difference in the configuration between these for a baseline feature of API gateway. Also, is there a way to accomplish the greedy match proxy with the vpc link code?

For anyone else out there with the same question, I didn’t find an answer to why I couldn’t create it with cloud formation, but I did solve the greedy proxy using VPC link which is all I really wanted anyways.

    functions:
     VPCLinkProxy:
        handler: main.someArbitraryLambdaFunction # Seems like this is only needed to pass validation and never used
        events:
          - http:
              path: /{proxy+}
              method: ANY
              integration: http-proxy
              connectionType: vpc-link
              connectionId: 'vpcLinkConnectionId'
              cors: true
              request:
                uri: http://yourdomain.com/{proxy}
                parameters:
                  paths:
                    proxy: true

Hope this helps!

1 Like