Skip to main content
LOWAPI GatewaySecurity

API Gateway Default Endpoint Enabled With Custom Domain

apigateway-default-endpoint-enabled

What this rule checks

Detects REST APIs that leave the default execute-api endpoint enabled while a custom domain is configured, letting clients bypass the domain and its edge controls.

How to fix it

  1. 1Set DisableExecuteApiEndpoint to true on the REST API
  2. 2Route all traffic through the custom domain and its WAF / edge controls
FlaggedA custom domain is configured but the REST API still exposes the default execute-api endpoint, which bypasses the domain and its edge controls.
import * as apigateway from 'aws-cdk-lib/aws-apigateway';

new apigateway.CfnDomainName(this, 'Domain', {
  domainName: 'api.example.com',
  regionalCertificateArn:
    'arn:aws:acm:eu-west-2:123456789012:certificate/abc-123',
  endpointConfiguration: { types: ['REGIONAL'] },
});
new apigateway.CfnRestApi(this, 'Api', { name: 'my-api' });
FixeddisableExecuteApiEndpoint: true forces all traffic through the custom domain (and any WAF/edge controls) instead of the default URL.
import * as apigateway from 'aws-cdk-lib/aws-apigateway';

new apigateway.CfnDomainName(this, 'Domain', {
  domainName: 'api.example.com',
  regionalCertificateArn:
    'arn:aws:acm:eu-west-2:123456789012:certificate/abc-123',
  endpointConfiguration: { types: ['REGIONAL'] },
});
new apigateway.CfnRestApi(this, 'Api', {
  name: 'my-api',
  disableExecuteApiEndpoint: true,
});

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

SOC2NIST

AWS documentation

Read the AWS guidance

Intentional? Suppress this finding

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

In .cdk-insights.json:

{
  "ignoreRules": [
    { "id": "apigateway-default-endpoint-enabled", "reason": "Why this is intentional" }
  ]
}

Or inline in your CDK code:

Validations.of(scope).acknowledge({
  id: 'cdk-insights::apigateway-default-endpoint-enabled',
  reason: 'Why this is intentional',
});

Use the rule ID apigateway-default-endpoint-enabled 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 118+ other rules locally against your synthesised CDK app — free, no account, your code never leaves your machine.

More API Gateway rules