Public endpoint for an internal SAM API

Configure a private endpoint and access policy for an internal REST API.

Description

For an internal SAM REST API, set EndpointConfiguration.Type to PRIVATE and invoke it through a VPC endpoint. An API intended for external clients may use a public endpoint.

Potential impact

A public endpoint can receive internet requests. Method authentication and the resource policy determine which requests are allowed.

Remediation

Provision an API Gateway interface VPC endpoint and restrict the API resource policy to approved VPCs or endpoints. VPCEndpointIds creates DNS aliases for invocation. Enforce the allow-list in the policy.

Examples

The two excerpts select EDGE and PRIVATE for the same prod stage. Supply the endpoint and policy, redeploy, and test access from the intended network.

Before

yaml
Resources:
  ApiGatewayApi:
    Type: AWS::Serverless::Api
    Properties:
      StageName: prod
      EndpointConfiguration:
        Type: EDGE

After

yaml
Resources:
  ApiGatewayApi:
    Type: AWS::Serverless::Api
    Properties:
      StageName: prod
      EndpointConfiguration:
        Type: PRIVATE

References