EventApiProps Struct
Properties for an AppSync Event API.
Example
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
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
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");
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");
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
the name of the Event API.
authorizationConfigoptionalEventApiAuthConfigauthorization_configoptionalEventApiAuthConfigauthorizationConfigoptionalEventApiAuthConfigAuthorizationConfigoptionalEventApiAuthConfigAuthorizationConfigoptionalEventApiAuthConfig#Optional authorization configuration.
Default: API Key authorization
domainNameoptionalAppSyncDomainOptionsdomain_nameoptionalAppSyncDomainOptionsdomainNameoptionalAppSyncDomainOptionsDomainNameoptionalAppSyncDomainOptionsDomainNameoptionalAppSyncDomainOptions#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
logConfigoptionalAppSyncLogConfiglog_configoptionalAppSyncLogConfiglogConfigoptionalAppSyncLogConfigLogConfigoptionalAppSyncLogConfigLogConfigoptionalAppSyncLogConfig= None#Logging configuration for this api.
ownerContactoptionalstringowner_contactoptionalstrownerContactoptionalStringOwnerContactoptionalstringOwnerContactoptional*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.