# EventApiProps

Properties for an AppSync Event API.

Used as props by: [EventApi](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.EventApi.html)

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

## Example

TypeScript:

```ts
import * as lambda from 'aws-cdk-lib/aws-lambda';
declare const handler: lambda.Function;

const iamProvider: appsync.AppSyncAuthProvider = {
  authorizationType: appsync.AppSyncAuthorizationType.IAM,
};

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

/* API with IAM and API Key providers.
 * Connection, default publish and default subscribe
 * can be done with either IAM and API Key.
 */
const api = new appsync.EventApi(this, 'api', {
  apiName: 'api',
  authorizationConfig: {
    // set auth providers
    authProviders: [
      iamProvider,
      apiKeyProvider,
    ],
  }
});

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

Python:

```python
import aws_cdk.aws_lambda as lambda_
# handler: lambda.Function

iam_provider = appsync.AppSyncAuthProvider(
    authorization_type=appsync.AppSyncAuthorizationType.IAM
)

api_key_provider = appsync.AppSyncAuthProvider(
    authorization_type=appsync.AppSyncAuthorizationType.API_KEY
)

# API with IAM and API Key providers.
# Connection, default publish and default subscribe
# can be done with either IAM and API Key.
#
api = appsync.EventApi(self, "api",
    api_name="api",
    authorization_config=appsync.EventApiAuthConfig(
        # set auth providers
        auth_providers=[iam_provider, api_key_provider
        ]
    )
)

api.add_channel_namespace("default")
```

Java:

```java
import software.amazon.awscdk.services.lambda.*;
Function handler;

AppSyncAuthProvider iamProvider = AppSyncAuthProvider.builder()
        .authorizationType(AppSyncAuthorizationType.IAM)
        .build();

AppSyncAuthProvider apiKeyProvider = AppSyncAuthProvider.builder()
        .authorizationType(AppSyncAuthorizationType.API_KEY)
        .build();

/* API with IAM and API Key providers.
 * Connection, default publish and default subscribe
 * can be done with either IAM and API Key.
 */
EventApi api = EventApi.Builder.create(this, "api")
        .apiName("api")
        .authorizationConfig(EventApiAuthConfig.builder()
                // set auth providers
                .authProviders(List.of(iamProvider, apiKeyProvider))
                .build())
        .build();

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

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.Lambda;
Function handler;

var iamProvider = new AppSyncAuthProvider {
    AuthorizationType = AppSyncAuthorizationType.IAM
};

var apiKeyProvider = new AppSyncAuthProvider {
    AuthorizationType = AppSyncAuthorizationType.API_KEY
};

/* API with IAM and API Key providers.
 * Connection, default publish and default subscribe
 * can be done with either IAM and API Key.
 */
var api = new EventApi(this, "api", new EventApiProps {
    ApiName = "api",
    AuthorizationConfig = new EventApiAuthConfig {
        // set auth providers
        AuthProviders = new [] { iamProvider, apiKeyProvider }
    }
});

api.AddChannelNamespace("default");
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import lambda "github.com/aws/aws-cdk-go/awscdk"
var handler Function

iamProvider := &AppSyncAuthProvider{
	AuthorizationType: appsync.AppSyncAuthorizationType_IAM,
}

apiKeyProvider := &AppSyncAuthProvider{
	AuthorizationType: appsync.AppSyncAuthorizationType_API_KEY,
}

/* API with IAM and API Key providers.
 * Connection, default publish and default subscribe
 * can be done with either IAM and API Key.
 */
api := appsync.NewEventApi(this, jsii.String("api"), &EventApiProps{
	ApiName: jsii.String("api"),
	AuthorizationConfig: &EventApiAuthConfig{
		// set auth providers
		AuthProviders: []AppSyncAuthProvider{
			iamProvider,
			apiKeyProvider,
		},
	},
})

api.AddChannelNamespace(jsii.String("default"))
```

## Properties

- `apiName`: string (required) — the name of the Event API.

- `authorizationConfig`: [EventApiAuthConfig](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.EventApiAuthConfig.html) — Optional authorization configuration.

  **Default:** API Key authorization

- `domainName`: [AppSyncDomainOptions](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.AppSyncDomainOptions.html) — The domain name configuration for the Event API.

  **Default:** no domain name

  The Route 53 hosted zone and CName DNS record must be configured in addition to this setting to
  enable custom domain URL

- `logConfig`: [AppSyncLogConfig](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.AppSyncLogConfig.html) = None — Logging configuration for this api.

- `ownerContact`: string — The owner contact information for an API resource.

  **Default:** No owner contact.

  This field accepts any string input with a length of 0 - 256 characters.
