# AppSyncAuthProvider

Auth provider settings for AppSync Event APIs.

- Source: [`aws-appsync/lib/auth-config.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-appsync/lib/auth-config.ts#L13)
- Type last changed: v2.178.0 · 6 Feb 2025

## Example

```ts
import * as logs from 'aws-cdk-lib/aws-logs';

const apiKeyProvider: appsync.AppSyncAuthProvider = {
  authorizationType: appsync.AppSyncAuthorizationType.API_KEY,
};

const api = new appsync.EventApi(this, 'api', {
  apiName: 'Api',
  ownerContact: 'OwnerContact',
  authorizationConfig: {
    authProviders: [
      apiKeyProvider,
    ],
    connectionAuthModeTypes: [
      appsync.AppSyncAuthorizationType.API_KEY,
    ],
    defaultPublishAuthModeTypes: [
      appsync.AppSyncAuthorizationType.API_KEY,
    ],
    defaultSubscribeAuthModeTypes: [
      appsync.AppSyncAuthorizationType.API_KEY,
    ],
  },
  logConfig: {
    fieldLogLevel: appsync.AppSyncFieldLogLevel.INFO,
    retention: logs.RetentionDays.ONE_WEEK,
  },
});

api.addChannelNamespace('default');
```

## Properties

- `apiKeyConfig`: [AppSyncApiKeyConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.AppSyncApiKeyConfig.html) — If authorizationType is `AuthorizationType.API_KEY`, this option can be configured.

  **Default:** name: 'DefaultAPIKey'

- `authorizationType`: [AppSyncAuthorizationType](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.AppSyncAuthorizationType.html) (required) = `AuthorizationType.API_KEY` — One of possible authorization types AppSync supports.

- `cognitoConfig`: [AppSyncCognitoConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.AppSyncCognitoConfig.html) = none — If authorizationType is `AuthorizationType.USER_POOL`, this option is required.

- `lambdaAuthorizerConfig`: [AppSyncLambdaAuthorizerConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.AppSyncLambdaAuthorizerConfig.html) = none — If authorizationType is `AuthorizationType.LAMBDA`, this option is required.

- `openIdConnectConfig`: [AppSyncOpenIdConnectConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.AppSyncOpenIdConnectConfig.html) = none — If authorizationType is `AuthorizationType.OIDC`, this option is required.
