AppSync API Key Authentication
appsync-api-key-auth
What this rule checks
Detects AppSync APIs using API key authentication or lacking additional authentication providers.
How to fix it
- 1Use AWS_IAM, Cognito User Pools, or OIDC for production workloads
- 2Configure AdditionalAuthenticationProviders for client flexibility
import * as appsync from 'aws-cdk-lib/aws-appsync';
new appsync.CfnGraphQLApi(this, 'Api', {
name: 'my-api',
authenticationType: 'API_KEY',
});import * as appsync from 'aws-cdk-lib/aws-appsync';
new appsync.CfnGraphQLApi(this, 'Api', {
name: 'my-api',
authenticationType: 'AWS_IAM',
});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::AppSync::GraphQLApiIntentional? Suppress this finding
Sometimes a flag is deliberate β a genuinely public endpoint, say. You can dismiss appsync-api-key-auth and the reason is kept in the report, not silently hidden.
In .cdk-insights.json:
{
"ignoreRules": [
{ "id": "appsync-api-key-auth", "reason": "Why this is intentional" }
]
}Or inline in your CDK code:
Validations.of(scope).acknowledge({
id: 'cdk-insights::appsync-api-key-auth',
reason: 'Why this is intentional',
});Use the rule ID appsync-api-key-auth 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 118+ other rules locally against your synthesised CDK app β free, no account, your code never leaves your machine.