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
- 1Set DisableExecuteApiEndpoint to true on the REST API
- 2Route all traffic through the custom domain and its WAF / edge controls
import * as apigateway from 'aws-cdk-lib/aws-apigateway';
// The custom domain is mapped to this API, but the default execute-api
// endpoint stays enabled — clients can bypass the domain (and its WAF).
const domain = new apigateway.CfnDomainName(this, 'Domain', {
domainName: 'api.example.com',
regionalCertificateArn:
'arn:aws:acm:us-east-1:111122223333:certificate/abcd',
endpointConfiguration: { types: ['REGIONAL'] },
});
const api = new apigateway.CfnRestApi(this, 'Api', { name: 'my-api' });
new apigateway.CfnBasePathMapping(this, 'Mapping', {
domainName: domain.ref,
restApiId: api.ref,
});import * as apigateway from 'aws-cdk-lib/aws-apigateway';
const domain = new apigateway.CfnDomainName(this, 'Domain', {
domainName: 'api.example.com',
regionalCertificateArn:
'arn:aws:acm:us-east-1:111122223333:certificate/abcd',
endpointConfiguration: { types: ['REGIONAL'] },
});
const api = new apigateway.CfnRestApi(this, 'Api', {
name: 'my-api',
disableExecuteApiEndpoint: true,
});
new apigateway.CfnBasePathMapping(this, 'Mapping', {
domainName: domain.ref,
restApiId: api.ref,
});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::RestApiIntentional? 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 scanCDK Insights runs this and 136+ other rules locally against your synthesised CDK app — free, no account, your code never leaves your machine.