AppSyncDomainOptions Struct
Domain name configuration for AppSync.
| Source | aws-appsync/lib/appsync-common.ts |
|---|---|
| Type last changed |
Example
ts
import * as acm from 'aws-cdk-lib/aws-certificatemanager';
import * as route53 from 'aws-cdk-lib/aws-route53';
const myDomainName = 'api.example.com';
const certificate = new acm.Certificate(this, 'cert', { domainName: myDomainName });
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,
],
},
// Custom Domain Settings
domainName: {
certificate,
domainName: myDomainName,
},
});
api.addChannelNamespace('default');
// You can get custom HTTP/Realtime endpoint
new CfnOutput(this, 'AWS AppSync Events HTTP endpoint', { value: api.customHttpEndpoint });
new CfnOutput(this, 'AWS AppSync Events Realtime endpoint', { value: api.customRealtimeEndpoint });
python
import aws_cdk.aws_certificatemanager as acm
import aws_cdk.aws_route53 as route53
my_domain_name = "api.example.com"
certificate = acm.Certificate(self, "cert", domain_name=my_domain_name)
api_key_provider = appsync.AppSyncAuthProvider(
authorization_type=appsync.AppSyncAuthorizationType.API_KEY
)
api = appsync.EventApi(self, "api",
api_name="Api",
owner_contact="OwnerContact",
authorization_config=appsync.EventApiAuthConfig(
auth_providers=[api_key_provider
],
connection_auth_mode_types=[appsync.AppSyncAuthorizationType.API_KEY
],
default_publish_auth_mode_types=[appsync.AppSyncAuthorizationType.API_KEY
],
default_subscribe_auth_mode_types=[appsync.AppSyncAuthorizationType.API_KEY
]
),
# Custom Domain Settings
domain_name=appsync.AppSyncDomainOptions(
certificate=certificate,
domain_name=my_domain_name
)
)
api.add_channel_namespace("default")
# You can get custom HTTP/Realtime endpoint
CfnOutput(self, "AWS AppSync Events HTTP endpoint", value=api.custom_http_endpoint)
CfnOutput(self, "AWS AppSync Events Realtime endpoint", value=api.custom_realtime_endpoint)
java
import software.amazon.awscdk.services.certificatemanager.*;
import software.amazon.awscdk.services.route53.*;
String myDomainName = "api.example.com";
Certificate certificate = Certificate.Builder.create(this, "cert").domainName(myDomainName).build();
AppSyncAuthProvider apiKeyProvider = AppSyncAuthProvider.builder()
.authorizationType(AppSyncAuthorizationType.API_KEY)
.build();
EventApi api = EventApi.Builder.create(this, "api")
.apiName("Api")
.ownerContact("OwnerContact")
.authorizationConfig(EventApiAuthConfig.builder()
.authProviders(List.of(apiKeyProvider))
.connectionAuthModeTypes(List.of(AppSyncAuthorizationType.API_KEY))
.defaultPublishAuthModeTypes(List.of(AppSyncAuthorizationType.API_KEY))
.defaultSubscribeAuthModeTypes(List.of(AppSyncAuthorizationType.API_KEY))
.build())
// Custom Domain Settings
.domainName(AppSyncDomainOptions.builder()
.certificate(certificate)
.domainName(myDomainName)
.build())
.build();
api.addChannelNamespace("default");
// You can get custom HTTP/Realtime endpoint
// You can get custom HTTP/Realtime endpoint
CfnOutput.Builder.create(this, "AWS AppSync Events HTTP endpoint").value(api.getCustomHttpEndpoint()).build();
CfnOutput.Builder.create(this, "AWS AppSync Events Realtime endpoint").value(api.getCustomRealtimeEndpoint()).build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.CertificateManager;
using Amazon.CDK.AWS.Route53;
var myDomainName = "api.example.com";
var certificate = new Certificate(this, "cert", new CertificateProps { DomainName = myDomainName });
var apiKeyProvider = new AppSyncAuthProvider {
AuthorizationType = AppSyncAuthorizationType.API_KEY
};
var api = new EventApi(this, "api", new EventApiProps {
ApiName = "Api",
OwnerContact = "OwnerContact",
AuthorizationConfig = new EventApiAuthConfig {
AuthProviders = new [] { apiKeyProvider },
ConnectionAuthModeTypes = new [] { AppSyncAuthorizationType.API_KEY },
DefaultPublishAuthModeTypes = new [] { AppSyncAuthorizationType.API_KEY },
DefaultSubscribeAuthModeTypes = new [] { AppSyncAuthorizationType.API_KEY }
},
// Custom Domain Settings
DomainName = new AppSyncDomainOptions {
Certificate = certificate,
DomainName = myDomainName
}
});
api.AddChannelNamespace("default");
// You can get custom HTTP/Realtime endpoint
// You can get custom HTTP/Realtime endpoint
new CfnOutput(this, "AWS AppSync Events HTTP endpoint", new CfnOutputProps { Value = api.CustomHttpEndpoint });
new CfnOutput(this, "AWS AppSync Events Realtime endpoint", new CfnOutputProps { Value = api.CustomRealtimeEndpoint });
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import acm "github.com/aws/aws-cdk-go/awscdk"
import route53 "github.com/aws/aws-cdk-go/awscdk"
myDomainName := "api.example.com"
certificate := acm.NewCertificate(this, jsii.String("cert"), &CertificateProps{
DomainName: myDomainName,
})
apiKeyProvider := &AppSyncAuthProvider{
AuthorizationType: appsync.AppSyncAuthorizationType_API_KEY,
}
api := appsync.NewEventApi(this, jsii.String("api"), &EventApiProps{
ApiName: jsii.String("Api"),
OwnerContact: jsii.String("OwnerContact"),
AuthorizationConfig: &EventApiAuthConfig{
AuthProviders: []AppSyncAuthProvider{
apiKeyProvider,
},
ConnectionAuthModeTypes: []AppSyncAuthorizationType{
appsync.AppSyncAuthorizationType_API_KEY,
},
DefaultPublishAuthModeTypes: []AppSyncAuthorizationType{
appsync.AppSyncAuthorizationType_API_KEY,
},
DefaultSubscribeAuthModeTypes: []AppSyncAuthorizationType{
appsync.AppSyncAuthorizationType_API_KEY,
},
},
// Custom Domain Settings
DomainName: &AppSyncDomainOptions{
Certificate: *Certificate,
DomainName: myDomainName,
},
})
api.AddChannelNamespace(jsii.String("default"))
// You can get custom HTTP/Realtime endpoint
// You can get custom HTTP/Realtime endpoint
awscdk.NewCfnOutput(this, jsii.String("AWS AppSync Events HTTP endpoint"), &CfnOutputProps{
Value: api.customHttpEndpoint,
})
awscdk.NewCfnOutput(this, jsii.String("AWS AppSync Events Realtime endpoint"), &CfnOutputProps{
Value: api.customRealtimeEndpoint,
})
Properties
certificateICertificateRefcertificateICertificateRefcertificateICertificateRefCertificateICertificateRefCertificateICertificateRef required #The certificate to use with the domain name.
The actual domain name.
For example, api.example.com.