0
votes

I have a SAM template file where i defined my Api as a AWS::Serverless::Api resource. The api is supposed to have an EndpointConfiguration: PRIVATE Unlike AWS::ApiGateway::RestApi, AWS::Serverless::Api supports only a String value for an EndpointConfiguration.

For AWS::ApiGateway::RestApi: I can add 2 properties Types : PRIVATE vpcEndpointIds : []

but for AWS::Serverless::Api I only have one String property that is PRIVATE

As I searched for how to configure vpcEndpointIds I found :

https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-endpoint-configuration.html

And this documentation says that vpcEndpointIds should be defined under "x-amazon-apigateway-endpoint-configuration" in an open api specification document.

but I am not able to find any example on how exactly it should be defined neither in AWS docs nor in open api docs.

Open api doc says it should be defined under server object which I tried and neither worked.

Any help would be really appreciated

2

2 Answers

0
votes

This option is available with CloudFormation but SAM currently does not support defining the VPC endpoint under EndpointConfiguration.

This feature of associating the VPC endpoint was recently added so I think SAM hasn't been updated for it yet. There is a feature request for it, so I expect it to be implemented soon.

0
votes

Thanks for the reply Suraj.

I found the right way to do it in SAM. As you mentioned it is not directly available in SAM as an option. But you can achieve this in the api open api definition document as follows under servers object:

        servers:
      - url: "https://apiname.execute-api.region.aws.com/{basePath}"
        variables:
          basePath:
            default: "/stagename"
        x-amazon-apigateway-endpoint-configuration:
          vpcEndpointIds:
            - !Ref vpcEndpointId

For those who are experiencing the same issue Please remember if you are using swagger 2.0 specification then the property needs to be at a different level. Find it here - https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-endpoint-configuration.html