Skip to main content
MEDIUMAPI GatewaySecurity

API Gateway Publicly Accessible

api-gateway-public-endpoint

What this rule checks

Detects API Gateway REST APIs configured with a non-PRIVATE endpoint, i.e. reachable from the public internet.

How to fix it

  1. 1Use a PRIVATE endpoint type with a VPC endpoint for internal APIs
  2. 2For intentionally public APIs, attach an authorizer and a WAF web ACL
  3. 3If public access is intended, suppress this rule for the resource
FlaggedA default RestApi uses an EDGE (non-PRIVATE) endpoint type, so it is reachable from the public internet. The check flags any REST API whose endpoint type is not PRIVATE.
import * as apigateway from 'aws-cdk-lib/aws-apigateway';

const api = new apigateway.RestApi(this, 'Api');
api.root.addMethod('GET', new apigateway.MockIntegration());
FixedSetting the endpoint type to EndpointType.PRIVATE restricts the API to a VPC endpoint, so the check passes.
import * as apigateway from 'aws-cdk-lib/aws-apigateway';

const api = new apigateway.RestApi(this, 'Api', {
  endpointConfiguration: { types: [apigateway.EndpointType.PRIVATE] },
});
api.root.addMethod('GET', new apigateway.MockIntegration());

CDK Insights pinpoints the exact file and line in your CDK source for every finding, so you can jump straight to the fix.

Affected resource types

AWS::ApiGateway::RestApi

Compliance frameworks

SOC2HIPAAPCI-DSSNIST

AWS documentation

Read the AWS guidance

Intentional? Suppress this finding

Sometimes a flag is deliberate — a genuinely public endpoint, say. You can dismiss api-gateway-public-endpoint and the reason is kept in the report, not silently hidden.

In .cdk-insights.json:

{
  "ignoreRules": [
    { "id": "api-gateway-public-endpoint", "reason": "Why this is intentional" }
  ]
}

Or inline in your CDK code:

Validations.of(scope).acknowledge({
  id: 'cdk-insights::api-gateway-public-endpoint',
  reason: 'Why this is intentional',
});

Use the rule ID api-gateway-public-endpoint shown above — not the CDK-* ID from SARIF / GitHub code scanning. To dismiss every finding on one construct instead, use ignorePaths. Suppression docs →

Catch this in your stack

$ npx cdk-insights scan

CDK Insights runs this and 126+ other rules locally against your synthesised CDK app — free, no account, your code never leaves your machine.

More API Gateway rules