Skip to main content
MEDIUMAppSyncSecurity

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

  1. 1Use AWS_IAM, Cognito User Pools, or OIDC for production workloads
  2. 2Configure AdditionalAuthenticationProviders for client flexibility
FlaggedauthenticationType is API_KEY. The check flags AppSync GraphQL APIs whose primary authentication is an API key, which is only appropriate for development or public read-only access.
import * as appsync from 'aws-cdk-lib/aws-appsync';

new appsync.CfnGraphQLApi(this, 'Api', {
  name: 'my-api',
  authenticationType: 'API_KEY',
});
FixedSwitching authenticationType to AWS_IAM (Cognito User Pools or OIDC also work) removes the API-key authentication finding.
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::GraphQLApi

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 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 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 AppSync rules