Package software.amazon.awscdk.services.appsync
AWS AppSync Construct Library
The aws-cdk-lib/aws-appsync package contains constructs for building flexible
APIs that use GraphQL and Events.
import software.amazon.awscdk.services.appsync.*;
GraphQL
Example
DynamoDB
Example of a GraphQL API with AWS_IAM authorization resolving into a DynamoDb
backend data source.
GraphQL schema file schema.graphql:
type demo {
id: String!
version: String!
}
type Query {
getDemos: [ demo! ]
getDemosConsistent: [demo!]
}
input DemoInput {
version: String!
}
type Mutation {
addDemo(input: DemoInput!): demo
}
CDK stack file app-stack.ts:
GraphqlApi api = GraphqlApi.Builder.create(this, "Api")
.name("demo")
.definition(Definition.fromFile(join(__dirname, "schema.graphql")))
.authorizationConfig(AuthorizationConfig.builder()
.defaultAuthorization(AuthorizationMode.builder()
.authorizationType(AuthorizationType.IAM)
.build())
.build())
.xrayEnabled(true)
.build();
Table demoTable = Table.Builder.create(this, "DemoTable")
.partitionKey(Attribute.builder()
.name("id")
.type(AttributeType.STRING)
.build())
.build();
DynamoDbDataSource demoDS = api.addDynamoDbDataSource("demoDataSource", demoTable);
// Resolver for the Query "getDemos" that scans the DynamoDb table and returns the entire list.
// Resolver Mapping Template Reference:
// https://docs.aws.amazon.com/appsync/latest/devguide/resolver-mapping-template-reference-dynamodb.html
demoDS.createResolver("QueryGetDemosResolver", BaseResolverProps.builder()
.typeName("Query")
.fieldName("getDemos")
.requestMappingTemplate(MappingTemplate.dynamoDbScanTable())
.responseMappingTemplate(MappingTemplate.dynamoDbResultList())
.build());
// Resolver for the Mutation "addDemo" that puts the item into the DynamoDb table.
demoDS.createResolver("MutationAddDemoResolver", BaseResolverProps.builder()
.typeName("Mutation")
.fieldName("addDemo")
.requestMappingTemplate(MappingTemplate.dynamoDbPutItem(PrimaryKey.partition("id").auto(), Values.projecting("input")))
.responseMappingTemplate(MappingTemplate.dynamoDbResultItem())
.build());
//To enable DynamoDB read consistency with the `MappingTemplate`:
demoDS.createResolver("QueryGetDemosConsistentResolver", BaseResolverProps.builder()
.typeName("Query")
.fieldName("getDemosConsistent")
.requestMappingTemplate(MappingTemplate.dynamoDbScanTable(true))
.responseMappingTemplate(MappingTemplate.dynamoDbResultList())
.build());
Aurora Serverless
AppSync provides a data source for executing SQL commands against Amazon Aurora Serverless clusters. You can use AppSync resolvers to execute SQL statements against the Data API with GraphQL queries, mutations, and subscriptions.
Aurora Serverless V1 Cluster
// Build a data source for AppSync to access the database.
GraphqlApi api;
// Create username and password secret for DB Cluster
DatabaseSecret secret = DatabaseSecret.Builder.create(this, "AuroraSecret")
.username("clusteradmin")
.build();
// The VPC to place the cluster in
Vpc vpc = new Vpc(this, "AuroraVpc");
// Create the serverless cluster, provide all values needed to customise the database.
ServerlessCluster cluster = ServerlessCluster.Builder.create(this, "AuroraCluster")
.engine(DatabaseClusterEngine.AURORA_MYSQL)
.vpc(vpc)
.credentials(Map.of("username", "clusteradmin"))
.clusterIdentifier("db-endpoint-test")
.defaultDatabaseName("demos")
.build();
RdsDataSource rdsDS = api.addRdsDataSource("rds", cluster, secret, "demos");
// Set up a resolver for an RDS query.
rdsDS.createResolver("QueryGetDemosRdsResolver", BaseResolverProps.builder()
.typeName("Query")
.fieldName("getDemosRds")
.requestMappingTemplate(MappingTemplate.fromString("\n {\n \"version\": \"2018-05-29\",\n \"statements\": [\n \"SELECT * FROM demos\"\n ]\n }\n "))
.responseMappingTemplate(MappingTemplate.fromString("\n $utils.toJson($utils.rds.toJsonObject($ctx.result)[0])\n "))
.build());
// Set up a resolver for an RDS mutation.
rdsDS.createResolver("MutationAddDemoRdsResolver", BaseResolverProps.builder()
.typeName("Mutation")
.fieldName("addDemoRds")
.requestMappingTemplate(MappingTemplate.fromString("\n {\n \"version\": \"2018-05-29\",\n \"statements\": [\n \"INSERT INTO demos VALUES (:id, :version)\",\n \"SELECT * WHERE id = :id\"\n ],\n \"variableMap\": {\n \":id\": $util.toJson($util.autoId()),\n \":version\": $util.toJson($ctx.args.version)\n }\n }\n "))
.responseMappingTemplate(MappingTemplate.fromString("\n $utils.toJson($utils.rds.toJsonObject($ctx.result)[1][0])\n "))
.build());
Aurora Serverless V2 Cluster
// Build a data source for AppSync to access the database.
GraphqlApi api;
// Create username and password secret for DB Cluster
DatabaseSecret secret = DatabaseSecret.Builder.create(this, "AuroraSecret")
.username("clusteradmin")
.build();
// The VPC to place the cluster in
Vpc vpc = new Vpc(this, "AuroraVpc");
// Create the serverless cluster, provide all values needed to customise the database.
DatabaseCluster cluster = DatabaseCluster.Builder.create(this, "AuroraClusterV2")
.engine(DatabaseClusterEngine.auroraPostgres(AuroraPostgresClusterEngineProps.builder().version(AuroraPostgresEngineVersion.VER_15_5).build()))
.credentials(Map.of("username", "clusteradmin"))
.clusterIdentifier("db-endpoint-test")
.writer(ClusterInstance.serverlessV2("writer"))
.serverlessV2MinCapacity(2)
.serverlessV2MaxCapacity(10)
.vpc(vpc)
.defaultDatabaseName("demos")
.enableDataApi(true)
.build();
RdsDataSource rdsDS = api.addRdsDataSourceV2("rds", cluster, secret, "demos");
// Set up a resolver for an RDS query.
rdsDS.createResolver("QueryGetDemosRdsResolver", BaseResolverProps.builder()
.typeName("Query")
.fieldName("getDemosRds")
.requestMappingTemplate(MappingTemplate.fromString("\n {\n \"version\": \"2018-05-29\",\n \"statements\": [\n \"SELECT * FROM demos\"\n ]\n }\n "))
.responseMappingTemplate(MappingTemplate.fromString("\n $utils.toJson($utils.rds.toJsonObject($ctx.result)[0])\n "))
.build());
// Set up a resolver for an RDS mutation.
rdsDS.createResolver("MutationAddDemoRdsResolver", BaseResolverProps.builder()
.typeName("Mutation")
.fieldName("addDemoRds")
.requestMappingTemplate(MappingTemplate.fromString("\n {\n \"version\": \"2018-05-29\",\n \"statements\": [\n \"INSERT INTO demos VALUES (:id, :version)\",\n \"SELECT * WHERE id = :id\"\n ],\n \"variableMap\": {\n \":id\": $util.toJson($util.autoId()),\n \":version\": $util.toJson($ctx.args.version)\n }\n }\n "))
.responseMappingTemplate(MappingTemplate.fromString("\n $utils.toJson($utils.rds.toJsonObject($ctx.result)[1][0])\n "))
.build());
HTTP Endpoints
GraphQL schema file schema.graphql:
type job {
id: String!
version: String!
}
input DemoInput {
version: String!
}
type Mutation {
callStepFunction(input: DemoInput!): job
}
type Query {
_placeholder: String
}
GraphQL request mapping template request.vtl:
{
"version": "2018-05-29",
"method": "POST",
"resourcePath": "/",
"params": {
"headers": {
"content-type": "application/x-amz-json-1.0",
"x-amz-target":"AWSStepFunctions.StartExecution"
},
"body": {
"stateMachineArn": "<your step functions arn>",
"input": "{ \"id\": \"$context.arguments.id\" }"
}
}
}
GraphQL response mapping template response.vtl:
{
"id": "${context.result.id}"
}
CDK stack file app-stack.ts:
GraphqlApi api = GraphqlApi.Builder.create(this, "api")
.name("api")
.definition(Definition.fromFile(join(__dirname, "schema.graphql")))
.build();
HttpDataSource httpDs = api.addHttpDataSource("ds", "https://states.amazonaws.com", HttpDataSourceOptions.builder()
.name("httpDsWithStepF")
.description("from appsync to StepFunctions Workflow")
.authorizationConfig(AwsIamConfig.builder()
.signingRegion("us-east-1")
.signingServiceName("states")
.build())
.build());
httpDs.createResolver("MutationCallStepFunctionResolver", BaseResolverProps.builder()
.typeName("Mutation")
.fieldName("callStepFunction")
.requestMappingTemplate(MappingTemplate.fromFile("request.vtl"))
.responseMappingTemplate(MappingTemplate.fromFile("response.vtl"))
.build());
EventBridge
Integrating AppSync with EventBridge enables developers to use EventBridge rules to route commands for GraphQL mutations that need to perform any one of a variety of asynchronous tasks. More broadly, it enables teams to expose an event bus as a part of a GraphQL schema.
GraphQL schema file schema.graphql:
schema {
query: Query
mutation: Mutation
}
type Query {
event(id:ID!): Event
}
type Mutation {
emitEvent(id: ID!, name: String): PutEventsResult!
}
type Event {
id: ID!
name: String!
}
type Entry {
ErrorCode: String
ErrorMessage: String
EventId: String
}
type PutEventsResult {
Entries: [Entry!]
FailedEntry: Int
}
GraphQL request mapping template request.vtl:
{
"version" : "2018-05-29",
"operation": "PutEvents",
"events" : [
{
"source": "integ.appsync.eventbridge",
"detailType": "Mutation.emitEvent",
"detail": $util.toJson($context.arguments)
}
]
}
GraphQL response mapping template response.vtl:
$util.toJson($ctx.result)'
This response mapping template simply converts the EventBridge PutEvents result to JSON. For details about the response see the documentation. Additional logic can be added to the response template to map the response type, or to error in the event of failed events. More information can be found here.
CDK stack file app-stack.ts:
import software.amazon.awscdk.services.events.*;
GraphqlApi api = GraphqlApi.Builder.create(this, "EventBridgeApi")
.name("EventBridgeApi")
.definition(Definition.fromFile(join(__dirname, "appsync.eventbridge.graphql")))
.build();
EventBus bus = EventBus.Builder.create(this, "DestinationEventBus").build();
EventBridgeDataSource dataSource = api.addEventBridgeDataSource("NoneDS", bus);
dataSource.createResolver("EventResolver", BaseResolverProps.builder()
.typeName("Mutation")
.fieldName("emitEvent")
.requestMappingTemplate(MappingTemplate.fromFile("request.vtl"))
.responseMappingTemplate(MappingTemplate.fromFile("response.vtl"))
.build());
Amazon OpenSearch Service
AppSync has builtin support for Amazon OpenSearch Service (successor to Amazon Elasticsearch Service) from domains that are provisioned through your AWS account. You can use AppSync resolvers to perform GraphQL operations such as queries, mutations, and subscriptions.
import software.amazon.awscdk.services.opensearchservice.*;
GraphqlApi api;
User user = new User(this, "User");
Domain domain = Domain.Builder.create(this, "Domain")
.version(EngineVersion.OPENSEARCH_2_3)
.removalPolicy(RemovalPolicy.DESTROY)
.fineGrainedAccessControl(AdvancedSecurityOptions.builder().masterUserArn(user.getUserArn()).build())
.encryptionAtRest(EncryptionAtRestOptions.builder().enabled(true).build())
.nodeToNodeEncryption(true)
.enforceHttps(true)
.build();
OpenSearchDataSource ds = api.addOpenSearchDataSource("ds", domain);
ds.createResolver("QueryGetTestsResolver", BaseResolverProps.builder()
.typeName("Query")
.fieldName("getTests")
.requestMappingTemplate(MappingTemplate.fromString(JSON.stringify(Map.of(
"version", "2017-02-28",
"operation", "GET",
"path", "/id/post/_search",
"params", Map.of(
"headers", Map.of(),
"queryString", Map.of(),
"body", Map.of("from", 0, "size", 50))))))
.responseMappingTemplate(MappingTemplate.fromString("[\n #foreach($entry in $context.result.hits.hits)\n #if( $velocityCount > 1 ) , #end\n $utils.toJson($entry.get(\"_source\"))\n #end\n ]"))
.build());
Merged APIs
AppSync supports Merged APIs which can be used to merge multiple source APIs into a single API.
import software.amazon.awscdk.*;
// first source API
GraphqlApi firstApi = GraphqlApi.Builder.create(this, "FirstSourceAPI")
.name("FirstSourceAPI")
.definition(Definition.fromFile(join(__dirname, "appsync.merged-api-1.graphql")))
.build();
// second source API
GraphqlApi secondApi = GraphqlApi.Builder.create(this, "SecondSourceAPI")
.name("SecondSourceAPI")
.definition(Definition.fromFile(join(__dirname, "appsync.merged-api-2.graphql")))
.build();
// Merged API
GraphqlApi mergedApi = GraphqlApi.Builder.create(this, "MergedAPI")
.name("MergedAPI")
.definition(Definition.fromSourceApis(SourceApiOptions.builder()
.sourceApis(List.of(SourceApi.builder()
.sourceApi(firstApi)
.mergeType(MergeType.MANUAL_MERGE)
.build(), SourceApi.builder()
.sourceApi(secondApi)
.mergeType(MergeType.AUTO_MERGE)
.build()))
.build()))
.build();
Merged APIs Across Different Stacks
The SourceApiAssociation construct allows you to define a SourceApiAssociation to a Merged API in a different stack or account. This allows a source API owner the ability to associate it to an existing Merged API itself.
GraphqlApi sourceApi = GraphqlApi.Builder.create(this, "FirstSourceAPI")
.name("FirstSourceAPI")
.definition(Definition.fromFile(join(__dirname, "appsync.merged-api-1.graphql")))
.build();
IGraphqlApi importedMergedApi = GraphqlApi.fromGraphqlApiAttributes(this, "ImportedMergedApi", GraphqlApiAttributes.builder()
.graphqlApiId("MyApiId")
.graphqlApiArn("MyApiArn")
.build());
IRole importedExecutionRole = Role.fromRoleArn(this, "ExecutionRole", "arn:aws:iam::ACCOUNT:role/MyExistingRole");
SourceApiAssociation.Builder.create(this, "SourceApiAssociation2")
.sourceApi(sourceApi)
.mergedApi(importedMergedApi)
.mergeType(MergeType.MANUAL_MERGE)
.mergedApiExecutionRole(importedExecutionRole)
.build();
Merge Source API Update Within CDK Deployment
The SourceApiAssociationMergeOperation construct available in the awscdk-appsync-utils package provides the ability to merge a source API to a Merged API via a custom resource. If the merge operation fails with a conflict, the stack update will fail and rollback the changes to the source API in the stack in order to prevent merge conflicts and ensure the source API changes are always propagated to the Merged API.
Custom Domain Names
For many use cases you may want to associate a custom domain name with your GraphQL API. This can be done during the API creation.
import software.amazon.awscdk.services.certificatemanager.*;
import software.amazon.awscdk.services.route53.*;
// hosted zone and route53 features
String hostedZoneId;
String zoneName = "example.com";
String myDomainName = "api.example.com";
Certificate certificate = Certificate.Builder.create(this, "cert").domainName(myDomainName).build();
SchemaFile schema = SchemaFile.Builder.create().filePath("mySchemaFile").build();
GraphqlApi api = GraphqlApi.Builder.create(this, "api")
.name("myApi")
.definition(Definition.fromSchema(schema))
.domainName(DomainOptions.builder()
.certificate(certificate)
.domainName(myDomainName)
.build())
.build();
// hosted zone for adding appsync domain
IHostedZone zone = HostedZone.fromHostedZoneAttributes(this, "HostedZone", HostedZoneAttributes.builder()
.hostedZoneId(hostedZoneId)
.zoneName(zoneName)
.build());
// create a cname to the appsync domain. will map to something like xxxx.cloudfront.net
// create a cname to the appsync domain. will map to something like xxxx.cloudfront.net
CnameRecord.Builder.create(this, "CnameApiRecord")
.recordName("api")
.zone(zone)
.domainName(api.getAppSyncDomainName())
.build();
Log Group
AppSync automatically create a log group with the name /aws/appsync/apis/<graphql_api_id> upon deployment with
log data set to never expire. If you want to set a different expiration period, use the logConfig.retention property.
Also you can choose the log level by setting the logConfig.fieldLogLevel property.
For more information, see CloudWatch logs.
To obtain the GraphQL API's log group as a logs.ILogGroup use the logGroup property of the
GraphqlApi construct.
import software.amazon.awscdk.services.logs.*;
GraphqlApi.Builder.create(this, "api")
.authorizationConfig(AuthorizationConfig.builder().build())
.name("myApi")
.definition(Definition.fromFile(join(__dirname, "myApi.graphql")))
.logConfig(LogConfig.builder()
.fieldLogLevel(FieldLogLevel.INFO)
.retention(RetentionDays.ONE_WEEK)
.build())
.build();
Schema
You can define a schema using from a local file using Definition.fromFile
GraphqlApi api = GraphqlApi.Builder.create(this, "api")
.name("myApi")
.definition(Definition.fromFile(join(__dirname, "schema.graphl")))
.build();
ISchema
Alternative schema sources can be defined by implementing the ISchema
interface. An example of this is the CodeFirstSchema class provided in
awscdk-appsync-utils
Imports
Any GraphQL Api that has been created outside the stack can be imported from
another stack into your CDK app. Utilizing the fromXxx function, you have
the ability to add data sources and resolvers through a IGraphqlApi interface.
GraphqlApi api;
Table table;
IGraphqlApi importedApi = GraphqlApi.fromGraphqlApiAttributes(this, "IApi", GraphqlApiAttributes.builder()
.graphqlApiId(api.getApiId())
.graphqlApiArn(api.getArn())
.build());
importedApi.addDynamoDbDataSource("TableDataSource", table);
If you don't specify graphqlArn in fromXxxAttributes, CDK will autogenerate
the expected arn for the imported api, given the apiId. For creating data
sources and resolvers, an apiId is sufficient.
Private APIs
By default all AppSync GraphQL APIs are public and can be accessed from the internet.
For customers that want to limit access to be from their VPC, the optional API visibility property can be set to Visibility.PRIVATE
at creation time. To explicitly create a public API, the visibility property should be set to Visibility.GLOBAL.
If visibility is not set, the service will default to GLOBAL.
CDK stack file app-stack.ts:
GraphqlApi api = GraphqlApi.Builder.create(this, "api")
.name("MyPrivateAPI")
.definition(Definition.fromFile(join(__dirname, "appsync.schema.graphql")))
.visibility(Visibility.PRIVATE)
.build();
See documentation for more details about Private APIs
Authorization
There are multiple authorization types available for GraphQL API to cater to different access use cases. They are:
- API Keys (
AuthorizationType.API_KEY) - Amazon Cognito User Pools (
AuthorizationType.USER_POOL) - OpenID Connect (
AuthorizationType.OPENID_CONNECT) - AWS Identity and Access Management (
AuthorizationType.AWS_IAM) - AWS Lambda (
AuthorizationType.AWS_LAMBDA)
These types can be used simultaneously in a single API, allowing different types of clients to access data. When you specify an authorization type, you can also specify the corresponding authorization mode to finish defining your authorization. For example, this is a GraphQL API with AWS Lambda Authorization.
import software.amazon.awscdk.services.lambda.*;
Function authFunction;
GraphqlApi.Builder.create(this, "api")
.name("api")
.definition(Definition.fromFile(join(__dirname, "appsync.test.graphql")))
.authorizationConfig(AuthorizationConfig.builder()
.defaultAuthorization(AuthorizationMode.builder()
.authorizationType(AuthorizationType.LAMBDA)
.lambdaAuthorizerConfig(LambdaAuthorizerConfig.builder()
.handler(authFunction)
.build())
.build())
.build())
.build();
Permissions
When using AWS_IAM as the authorization type for GraphQL API, an IAM Role
with correct permissions must be used for access to API.
When configuring permissions, you can specify specific resources to only be
accessible by IAM authorization. For example, if you want to only allow mutability
for IAM authorized access you would configure the following.
In schema.graphql:
type Mutation {
updateExample(...): ...
@aws_iam
}
In IAM:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"appsync:GraphQL"
],
"Resource": [
"arn:aws:appsync:REGION:ACCOUNT_ID:apis/GRAPHQL_ID/types/Mutation/fields/updateExample"
]
}
]
}
See documentation for more details.
To make this easier, CDK provides grant API.
Use the grant function for more granular authorization.
IGraphqlApi api;
Role role = Role.Builder.create(this, "Role")
.assumedBy(new ServicePrincipal("lambda.amazonaws.com"))
.build();
api.grant(role, IamResource.custom("types/Mutation/fields/updateExample"), "appsync:GraphQL");
IamResource
In order to use the grant functions, you need to use the class IamResource.
IamResource.custom(...arns)permits custom ARNs and requires an argument.IamResouce.ofType(type, ...fields)permits ARNs for types and their fields.IamResource.all()permits ALL resources.
Generic Permissions
Alternatively, you can use more generic grant functions to accomplish the same usage.
These include:
- grantMutation (use to grant access to Mutation fields)
- grantQuery (use to grant access to Query fields)
- grantSubscription (use to grant access to Subscription fields)
IGraphqlApi api;
Role role;
// For generic types
api.grantMutation(role, "updateExample");
// For custom types and granular design
api.grant(role, IamResource.ofType("Mutation", "updateExample"), "appsync:GraphQL");
Pipeline Resolvers and AppSync Functions
AppSync Functions are local functions that perform certain operations onto a backend data source. Developers can compose operations (Functions) and execute them in sequence with Pipeline Resolvers.
GraphqlApi api;
AppsyncFunction appsyncFunction = AppsyncFunction.Builder.create(this, "function")
.name("appsync_function")
.api(api)
.dataSource(api.addNoneDataSource("none"))
.requestMappingTemplate(MappingTemplate.fromFile("request.vtl"))
.responseMappingTemplate(MappingTemplate.fromFile("response.vtl"))
.build();
When using the LambdaDataSource, you can control the maximum number of resolver request
inputs that will be sent to a single AWS Lambda function in a BatchInvoke operation
by setting the maxBatchSize property.
GraphqlApi api;
LambdaDataSource lambdaDataSource;
AppsyncFunction appsyncFunction = AppsyncFunction.Builder.create(this, "function")
.name("appsync_function")
.api(api)
.dataSource(lambdaDataSource)
.maxBatchSize(10)
.build();
AppSync Functions are used in tandem with pipeline resolvers to compose multiple operations.
GraphqlApi api;
AppsyncFunction appsyncFunction;
Resolver pipelineResolver = Resolver.Builder.create(this, "pipeline")
.api(api)
.dataSource(api.addNoneDataSource("none"))
.typeName("typeName")
.fieldName("fieldName")
.requestMappingTemplate(MappingTemplate.fromFile("beforeRequest.vtl"))
.pipelineConfig(List.of(appsyncFunction))
.responseMappingTemplate(MappingTemplate.fromFile("afterResponse.vtl"))
.build();
JS Functions and Resolvers
JS Functions and resolvers are also supported. You can use a .js file within your CDK project, or specify your function code inline.
GraphqlApi api;
AppsyncFunction myJsFunction = AppsyncFunction.Builder.create(this, "function")
.name("my_js_function")
.api(api)
.dataSource(api.addNoneDataSource("none"))
.code(Code.fromAsset("directory/function_code.js"))
.runtime(FunctionRuntime.JS_1_0_0)
.build();
Resolver.Builder.create(this, "PipelineResolver")
.api(api)
.typeName("typeName")
.fieldName("fieldName")
.code(Code.fromInline("\n // The before step\n export function request(...args) {\n console.log(args);\n return {}\n }\n\n // The after step\n export function response(ctx) {\n return ctx.prev.result\n }\n "))
.runtime(FunctionRuntime.JS_1_0_0)
.pipelineConfig(List.of(myJsFunction))
.build();
Learn more about Pipeline Resolvers and AppSync Functions here.
Introspection
By default, AppSync allows you to use introspection queries.
For customers that want to limit access to be introspection queries, the introspectionConfig property can be set to IntrospectionConfig.DISABLED at creation time.
If introspectionConfig is not set, the service will default to ENABLED.
GraphqlApi api = GraphqlApi.Builder.create(this, "api")
.name("DisableIntrospectionApi")
.definition(Definition.fromFile(join(__dirname, "appsync.schema.graphql")))
.introspectionConfig(IntrospectionConfig.DISABLED)
.build();
Query Depth Limits
By default, queries are able to process an unlimited amount of nested levels. Limiting queries to a specified amount of nested levels has potential implications for the performance and flexibility of your project.
GraphqlApi api = GraphqlApi.Builder.create(this, "api")
.name("LimitQueryDepths")
.definition(Definition.fromFile(join(__dirname, "appsync.schema.graphql")))
.queryDepthLimit(2)
.build();
Resolver Count Limits
You can control how many resolvers each query can process. By default, each query can process up to 10000 resolvers. By setting a limit AppSync will not handle any resolvers past a certain number limit.
GraphqlApi api = GraphqlApi.Builder.create(this, "api")
.name("LimitResolverCount")
.definition(Definition.fromFile(join(__dirname, "appsync.schema.graphql")))
.resolverCountLimit(2)
.build();
Environment Variables
To use environment variables in resolvers, you can use the environmentVariables property and
the addEnvironmentVariable method.
GraphqlApi api = GraphqlApi.Builder.create(this, "api")
.name("api")
.definition(Definition.fromFile(join(__dirname, "appsync.schema.graphql")))
.environmentVariables(Map.of(
"EnvKey1", "non-empty-1"))
.build();
api.addEnvironmentVariable("EnvKey2", "non-empty-2");
Configure an EventBridge target that invokes an AppSync GraphQL API
Configuring the target relies on the graphQLEndpointArn property.
Use the AppSync event target to trigger an AppSync GraphQL API. You need to
create an AppSync.GraphqlApi configured with AWS_IAM authorization mode.
The code snippet below creates a AppSync GraphQL API target that is invoked, calling the publish mutation.
import software.amazon.awscdk.services.events.*;
import software.amazon.awscdk.services.events.targets.*;
Rule rule;
GraphqlApi api;
rule.addTarget(AppSync.Builder.create(api)
.graphQLOperation("mutation Publish($message: String!){ publish(message: $message) { message } }")
.variables(RuleTargetInput.fromObject(Map.of(
"message", "hello world")))
.build());
Owner Contact
You can set the owner contact information for an API resource. This field accepts any string input with a length of 0 - 256 characters.
GraphqlApi api = GraphqlApi.Builder.create(this, "OwnerContact")
.name("OwnerContact")
.definition(Definition.fromSchema(SchemaFile.fromAsset(join(__dirname, "appsync.test.graphql"))))
.ownerContact("test-owner-contact")
.build();
Events
Example
AWS AppSync Events lets you create secure and performant serverless WebSocket APIs that can broadcast real-time event data to millions of subscribers, without you having to manage connections or resource scaling.
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())
.build();
api.addChannelNamespace("default");
Authorization
AWS AppSync Events offers the following authorization types to secure Event APIs: API keys, Lambda, IAM, OpenID Connect, and Amazon Cognito user pools. Each option provides a different method of security:
- API Keys (
AppSyncAuthorizationType.API_KEY) - Amazon Cognito User Pools (
AppSyncAuthorizationType.USER_POOL) - OpenID Connect (
AppSyncAuthorizationType.OIDC) - AWS Identity and Access Management (
AppSyncAuthorizationType.IAM) - AWS Lambda (
AppSyncAuthorizationType.LAMBDA)
When you define your API, you configure the authorization mode to connect to your Event API WebSocket. You also configure the default authorization modes to use when publishing and subscribing to messages. If you don't specify any authorization providers, an API key will be created for you as the authorization mode for the API.
For mor information, see Configuring authorization and authentication to secure Event APIs.
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();
AppSyncAuthProvider lambdaProvider = AppSyncAuthProvider.builder()
.authorizationType(AppSyncAuthorizationType.LAMBDA)
.lambdaAuthorizerConfig(AppSyncLambdaAuthorizerConfig.builder()
.handler(handler)
.resultsCacheTtl(Duration.minutes(6))
.validationRegex("test")
.build())
.build();
EventApi api = EventApi.Builder.create(this, "api")
.apiName("api")
.authorizationConfig(EventApiAuthConfig.builder()
// set auth providers
.authProviders(List.of(iamProvider, apiKeyProvider, lambdaProvider))
.connectionAuthModeTypes(List.of(AppSyncAuthorizationType.IAM))
.defaultPublishAuthModeTypes(List.of(AppSyncAuthorizationType.API_KEY))
.defaultSubscribeAuthModeTypes(List.of(AppSyncAuthorizationType.LAMBDA))
.build())
.build();
api.addChannelNamespace("default");
If you don't specify any overrides for the connectionAuthModeTypes, defaultPublishAuthModeTypes, and defaultSubscribeAuthModeTypes parameters then all authProviders defined are included as default authorization mode types for connection, publish, and subscribe.
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");
Data Sources
With AWS AppSync Events, you can configure data source integrations with Amazon DynamoDB, Amazon Aurora Serverless, Amazon EventBridge, Amazon Bedrock Runtime, AWS Lambda, Amazon OpenSearch Service, and HTTP endpoints. The Event API can be associated with the data source and you can use the data source as an integration in your channel namespace event handlers for onPublish and onSubscribe operations.
Below are examples for how you add the various data sources to you Event API.
Amazon DynamoDB
EventApi api = EventApi.Builder.create(this, "EventApiDynamoDB")
.apiName("DynamoDBEventApi")
.build();
Table table = Table.Builder.create(this, "table")
.tableName("event-messages")
.partitionKey(Attribute.builder()
.name("id")
.type(AttributeType.STRING)
.build())
.build();
AppSyncDynamoDbDataSource dataSource = api.addDynamoDbDataSource("ddbsource", table);
Amazon Aurora Serverless
import software.amazon.awscdk.services.secretsmanager.*;
Vpc vpc;
String databaseName = "mydb";
DatabaseCluster cluster = DatabaseCluster.Builder.create(this, "Cluster")
.engine(DatabaseClusterEngine.auroraPostgres(AuroraPostgresClusterEngineProps.builder().version(AuroraPostgresEngineVersion.VER_16_6).build()))
.writer(ClusterInstance.serverlessV2("writer"))
.vpc(vpc)
.credentials(Map.of("username", "clusteradmin"))
.defaultDatabaseName(databaseName)
.enableDataApi(true)
.build();
ISecret secret = Secret.fromSecretNameV2(this, "Secret", "db-secretName");
EventApi api = EventApi.Builder.create(this, "EventApiRds")
.apiName("RdsEventApi")
.build();
AppSyncRdsDataSource dataSource = api.addRdsDataSource("rdsds", cluster, secret, databaseName);
Amazon EventBridge
import software.amazon.awscdk.services.events.*;
EventApi api = EventApi.Builder.create(this, "EventApiEventBridge")
.apiName("EventBridgeEventApi")
.build();
EventBus eventBus = new EventBus(this, "test-bus");
AppSyncEventBridgeDataSource dataSource = api.addEventBridgeDataSource("eventbridgeds", eventBus);
AWS Lambda
import software.amazon.awscdk.services.lambda.*;
Function lambdaDs;
EventApi api = EventApi.Builder.create(this, "EventApiLambda")
.apiName("LambdaEventApi")
.build();
AppSyncLambdaDataSource dataSource = api.addLambdaDataSource("lambdads", lambdaDs);
Amazon OpenSearch Service
import software.amazon.awscdk.services.opensearchservice.*;
Domain domain = Domain.Builder.create(this, "Domain")
.version(EngineVersion.OPENSEARCH_2_17)
.encryptionAtRest(EncryptionAtRestOptions.builder()
.enabled(true)
.build())
.nodeToNodeEncryption(true)
.enforceHttps(true)
.capacity(CapacityConfig.builder()
.multiAzWithStandbyEnabled(false)
.build())
.ebs(EbsOptions.builder()
.enabled(true)
.volumeSize(10)
.build())
.build();
EventApi api = EventApi.Builder.create(this, "EventApiOpenSearch")
.apiName("OpenSearchEventApi")
.build();
AppSyncOpenSearchDataSource dataSource = api.addOpenSearchDataSource("opensearchds", domain);
HTTP Endpoints
import software.amazon.awscdk.services.apigateway.*;
EventApi api = EventApi.Builder.create(this, "EventApiHttp")
.apiName("HttpEventApi")
.build();
RestApi randomApi = new RestApi(this, "RandomApi");
Resource randomRoute = randomApi.root.addResource("random");
randomRoute.addMethod("GET", MockIntegration.Builder.create()
.integrationResponses(List.of(IntegrationResponse.builder()
.statusCode("200")
.responseTemplates(Map.of(
"application/json", "my-random-value"))
.build()))
.passthroughBehavior(PassthroughBehavior.NEVER)
.requestTemplates(Map.of(
"application/json", "{ \"statusCode\": 200 }"))
.build(), MethodOptions.builder()
.methodResponses(List.of(MethodResponse.builder().statusCode("200").build()))
.build());
AppSyncHttpDataSource dataSource = api.addHttpDataSource("httpsource", String.format("https://%s.execute-api.%s.amazonaws.com", randomApi.getRestApiId(), this.region));
Custom Domain Names
With AWS AppSync, you can use custom domain names to configure a single, memorable domain that works for your Event APIs.
You can set custom domain by setting domainName. Also you can get custom HTTP/Realtime endpoint by customHttpEndpoint, customRealtimeEndpoint.
For more information, see Configuring custom domain names for Event APIs.
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();
Log Group
AppSync automatically create a log group with the name /aws/appsync/apis/<api_id> upon deployment with log data set to never expire.
If you want to set a different expiration period, use the logConfig.retention property.
Also you can choose the log level by setting the logConfig.fieldLogLevel property.
For more information, see Configuring CloudWatch Logs on Event APIs.
To obtain the Event API's log group as a logs.ILogGroup use the logGroup property of the
Api construct.
import software.amazon.awscdk.services.logs.*;
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())
.logConfig(AppSyncLogConfig.builder()
.fieldLogLevel(AppSyncFieldLogLevel.INFO)
.retention(RetentionDays.ONE_WEEK)
.build())
.build();
api.addChannelNamespace("default");
WAF Protection
You can use AWS WAF to protect your AppSync API from common web exploits, such as SQL injection and cross-site scripting (XSS) attacks. These could affect API availability and performance, compromise security, or consume excessive resources.
For more information, see Using AWS WAF to protect AWS AppSync Event APIs.
EventApi api;
CfnWebACL webAcl;
// Associate waf with Event API
// Associate waf with Event API
CfnWebACLAssociation.Builder.create(this, "WafAssociation")
.resourceArn(api.getApiArn())
.webAclArn(webAcl.getAttrArn())
.build();
Channel namespaces
Channel namespaces define the channels that are available on your Event API, and the capabilities and behaviors of these channels. Channel namespaces provide a scalable approach to managing large numbers of channels.
Instead of configuring each channel individually, developers can apply settings across an entire namespace.
Channel namespace can optionally interact with data sources configured on the Event API by defining optional event handler code or using direct integrations with the data source where applicable.
For more information, see Understanding channel namespaces.
EventApi api;
// create a channel namespace
// create a channel namespace
ChannelNamespace.Builder.create(this, "Namespace")
.api(api)
.build();
// You can also create a namespace through the addChannelNamespace method
api.addChannelNamespace("AnotherNameSpace", ChannelNamespaceOptions.builder().build());
The API's publishing and subscribing authorization configuration is automatically applied to all namespaces. You can override this configuration at the namespace level. Note: the authorization type you select for a namespace must be defined as an authorization provider at the API level.
EventApi api;
ChannelNamespace.Builder.create(this, "Namespace")
.api(api)
.authorizationConfig(NamespaceAuthConfig.builder()
// Override publishing authorization to API Key
.publishAuthModeTypes(List.of(AppSyncAuthorizationType.API_KEY))
// Override subscribing authorization to Lambda
.subscribeAuthModeTypes(List.of(AppSyncAuthorizationType.LAMBDA))
.build())
.build();
You can define event handlers on channel namespaces. Event handlers are functions that run on AWS AppSync's JavaScript runtime and enable you to run custom business logic. You can use an event handler to process published events or process and authorize subscribe requests.
For more information, see Channel namespace handlers and event processing.
EventApi api;
ChannelNamespace.Builder.create(this, "Namespace")
.api(api)
// set a handler from inline code
.code(Code.fromInline("/* event handler code here.*/"))
.build();
ChannelNamespace.Builder.create(this, "Namespace")
.api(api)
// set a handler from an asset
.code(Code.fromAsset("directory/function_code.js"))
.build();
You can define an integration in your event handler for onPublish and/or onSubscribe operations. When defining integrations on your channel namespace, you write code in the event handler to submit requests to and process responses from your data source. For example, if you configure an integration with Amazon DynamoDB for onPublish operations, you can persist those events to DynamoDB using a batchPut operation in the request method, and then return the events as normal in the response method. For an integration with Amazon OpenSearch Service, you may use this for onPublish operations to enrich the events.
When using the AWS Lambda data source integration, you can either invoke the Lambda function using the event handler code or you can directly invoke the Lambda function, bypassing the event handler code all together. When using direct invoke, you can choose to invoke the Lambda function synchronously or asynchronously by specifying the invokeType as REQUEST_RESPONSE or EVENT respectively.
Below are examples using Amazon DynamoDB, Amazon EventBridge, and AWS Lambda. You can leverage any supported data source in the same way.
Amazon DynamoDB & Amazon EventBridge
EventApi api;
AppSyncDynamoDbDataSource ddbDataSource;
AppSyncEventBridgeDataSource ebDataSource;
// DynamoDB data source for publish handler
api.addChannelNamespace("ddb-eb-ns", ChannelNamespaceOptions.builder()
.code(Code.fromInline("/* event handler code here.*/"))
.publishHandlerConfig(HandlerConfig.builder()
.dataSource(ddbDataSource)
.build())
.subscribeHandlerConfig(HandlerConfig.builder()
.dataSource(ebDataSource)
.build())
.build());
AWS Lambda
EventApi api;
AppSyncLambdaDataSource lambdaDataSource;
// Lambda data source for publish handler
api.addChannelNamespace("lambda-ns", ChannelNamespaceOptions.builder()
.code(Code.fromInline("/* event handler code here.*/"))
.publishHandlerConfig(HandlerConfig.builder()
.dataSource(lambdaDataSource)
.build())
.build());
// Direct Lambda data source for publish handler
api.addChannelNamespace("lambda-direct-ns", ChannelNamespaceOptions.builder()
.publishHandlerConfig(HandlerConfig.builder()
.dataSource(lambdaDataSource)
.direct(true)
.build())
.build());
api.addChannelNamespace("lambda-direct-async-ns", ChannelNamespaceOptions.builder()
.publishHandlerConfig(HandlerConfig.builder()
.dataSource(lambdaDataSource)
.direct(true)
.lambdaInvokeType(LambdaInvokeType.EVENT)
.build())
.build());
-
ClassDescriptionBase Class for API.Configuration for API Key authorization in AppSync.A builder for
ApiKeyConfigAn implementation forApiKeyConfigConfiguration for API Key authorization in AppSync.A builder forAppSyncApiKeyConfigAn implementation forAppSyncApiKeyConfigenum with all possible values for AppSync authorization type.Auth provider settings for AppSync Event APIs.A builder forAppSyncAuthProviderAn implementation forAppSyncAuthProviderThe authorization config in case the HTTP endpoint requires authorization.A builder forAppSyncAwsIamConfigAn implementation forAppSyncAwsIamConfigAbstract AppSync datasource implementation.Properties for an AppSync datasource backed by a resource.A builder forAppSyncBackedDataSourcePropsAn implementation forAppSyncBackedDataSourcePropsAbstract AppSync datasource implementation.Base properties for an AppSync datasource.A builder forAppSyncBaseDataSourcePropsAn implementation forAppSyncBaseDataSourcePropsConfiguration for Cognito user-pools in AppSync for Api.A builder forAppSyncCognitoConfigAn implementation forAppSyncCognitoConfigOptional configuration for data sources.A builder forAppSyncDataSourceOptionsAn implementation forAppSyncDataSourceOptionsValid data source types for AppSync.Domain name configuration for AppSync.A builder forAppSyncDomainOptionsAn implementation forAppSyncDomainOptionsAn AppSync datasource backed by a DynamoDB table.A fluent builder forAppSyncDynamoDbDataSource.Properties for an AppSync DynamoDB datasource.A builder forAppSyncDynamoDbDataSourcePropsAn implementation forAppSyncDynamoDbDataSourcePropsAn AppSync datasource backed by EventBridge.A fluent builder forAppSyncEventBridgeDataSource.Properties for an AppSync EventBridge datasource.A builder forAppSyncEventBridgeDataSourcePropsAn implementation forAppSyncEventBridgeDataSourcePropsA class used to generate resource arns for AppSync Event APIs.Props used by implementations of BaseDataSource to provide configuration.A builder forAppSyncExtendedDataSourcePropsAn implementation forAppSyncExtendedDataSourcePropslog-level for fields in AppSync.AppSync Functions are local functions that perform certain operations onto a backend data source.A fluent builder forAppsyncFunction.The attributes for imported AppSync Functions.A builder forAppsyncFunctionAttributesAn implementation forAppsyncFunctionAttributesthe CDK properties for AppSync Functions.A builder forAppsyncFunctionPropsAn implementation forAppsyncFunctionPropsAn AppSync datasource backed by a http endpoint.A fluent builder forAppSyncHttpDataSource.Optional configuration for Http data sources.A builder forAppSyncHttpDataSourceOptionsAn implementation forAppSyncHttpDataSourceOptionsProperties for an AppSync http datasource.A builder forAppSyncHttpDataSourcePropsAn implementation forAppSyncHttpDataSourcePropsConfiguration for Lambda authorization in AppSync.A builder forAppSyncLambdaAuthorizerConfigAn implementation forAppSyncLambdaAuthorizerConfigAn AppSync datasource backed by a Lambda function.A fluent builder forAppSyncLambdaDataSource.Properties for an AppSync Lambda datasource.A builder forAppSyncLambdaDataSourcePropsAn implementation forAppSyncLambdaDataSourcePropsLogging configuration for AppSync.A builder forAppSyncLogConfigAn implementation forAppSyncLogConfigConfiguration for OpenID Connect authorization in AppSync.A builder forAppSyncOpenIdConnectConfigAn implementation forAppSyncOpenIdConnectConfigAn Appsync datasource backed by OpenSearch.A fluent builder forAppSyncOpenSearchDataSource.Properties for the OpenSearch Data Source.A builder forAppSyncOpenSearchDataSourcePropsAn implementation forAppSyncOpenSearchDataSourcePropsAn AppSync datasource backed by RDS.A fluent builder forAppSyncRdsDataSource.Properties for an AppSync RDS datasource Aurora Serverless V1.A builder forAppSyncRdsDataSourcePropsAn implementation forAppSyncRdsDataSourcePropsProperties for an AppSync RDS datasource Aurora Serverless V2.A builder forAppSyncRdsDataSourcePropsV2An implementation forAppSyncRdsDataSourcePropsV2Represents a local file with source code used for an AppSync Function or Resolver.A fluent builder forAssetCode.Utility class representing the assigment of a value to an attribute.Specifies the attribute value assignments.Utility class to allow assigning a value to an attribute.Configuration of the API authorization modes.A builder forAuthorizationConfigAn implementation forAuthorizationConfigInterface to specify default or additional authorization(s).A builder forAuthorizationModeAn implementation forAuthorizationModeenum with all possible values for AppSync authorization type.The authorization config in case the HTTP endpoint requires authorization.A builder forAwsIamConfigAn implementation forAwsIamConfigAbstract AppSync datasource implementation.properties for an AppSync datasource backed by a resource.A builder forBackedDataSourcePropsAn implementation forBackedDataSourcePropsthe base properties for AppSync Functions.A builder forBaseAppsyncFunctionPropsAn implementation forBaseAppsyncFunctionPropsthe base properties for a channel namespace.A builder forBaseChannelNamespacePropsAn implementation forBaseChannelNamespacePropsAbstract AppSync datasource implementation.Base properties for an AppSync datasource.A builder forBaseDataSourcePropsAn implementation forBaseDataSourcePropsBasic properties for an AppSync resolver.A builder forBaseResolverPropsAn implementation forBaseResolverPropsCachingConfig for AppSync resolvers.A builder forCachingConfigAn implementation forCachingConfigTheAWS::AppSync::Apiresource creates an AWS AppSync API that you can use for an AWS AppSync API with your preferred configuration, such as an Event API that provides real-time message publishing and message subscriptions over WebSockets.Describes an authorization configuration.A builder forCfnApi.AuthModePropertyAn implementation forCfnApi.AuthModePropertyDescribes an authorization provider.A builder forCfnApi.AuthProviderPropertyAn implementation forCfnApi.AuthProviderPropertyA fluent builder forCfnApi.Describes an Amazon Cognito configuration.A builder forCfnApi.CognitoConfigPropertyAn implementation forCfnApi.CognitoConfigPropertyA map of DNS names for the Api.A builder forCfnApi.DnsMapPropertyAn implementation forCfnApi.DnsMapPropertyDescribes the authorization configuration for connections, message publishing, message subscriptions, and logging for an Event API.A builder forCfnApi.EventConfigPropertyAn implementation forCfnApi.EventConfigPropertyDescribes the CloudWatch Logs configuration for the Event API.A builder forCfnApi.EventLogConfigPropertyAn implementation forCfnApi.EventLogConfigPropertyALambdaAuthorizerConfigspecifies how to authorize AWS AppSync API access when using theAWS_LAMBDAauthorizer mode.A builder forCfnApi.LambdaAuthorizerConfigPropertyAn implementation forCfnApi.LambdaAuthorizerConfigPropertyDescribes an OpenID Connect (OIDC) configuration.A builder forCfnApi.OpenIDConnectConfigPropertyAn implementation forCfnApi.OpenIDConnectConfigPropertyTheAWS::AppSync::ApiCacheresource represents the input of aCreateApiCacheoperation.A fluent builder forCfnApiCache.Properties for defining aCfnApiCache.A builder forCfnApiCachePropsAn implementation forCfnApiCachePropsTheAWS::AppSync::ApiKeyresource creates a unique key that you can distribute to clients who are executing GraphQL operations with AWS AppSync that require an API key.A fluent builder forCfnApiKey.Properties for defining aCfnApiKey.A builder forCfnApiKeyPropsAn implementation forCfnApiKeyPropsProperties for defining aCfnApi.A builder forCfnApiPropsAn implementation forCfnApiPropsTheAWS::AppSync::ChannelNamespaceresource creates a channel namespace associated with anApi.Describes an authorization configuration.A builder forCfnChannelNamespace.AuthModePropertyAn implementation forCfnChannelNamespace.AuthModePropertyA fluent builder forCfnChannelNamespace.TheHandlerConfigproperty type specifies the configuration for the handler.A builder forCfnChannelNamespace.HandlerConfigPropertyAn implementation forCfnChannelNamespace.HandlerConfigPropertyTheHandlerConfigsproperty type specifies the configuration for theOnPublishandOnSubscribehandlers.A builder forCfnChannelNamespace.HandlerConfigsPropertyAn implementation forCfnChannelNamespace.HandlerConfigsPropertyTheIntegrationproperty type specifies the integration data source configuration for the handler.A builder forCfnChannelNamespace.IntegrationPropertyAn implementation forCfnChannelNamespace.IntegrationPropertyTheLambdaConfigproperty type specifies the integration configuration for a Lambda data source.A builder forCfnChannelNamespace.LambdaConfigPropertyAn implementation forCfnChannelNamespace.LambdaConfigPropertyProperties for defining aCfnChannelNamespace.A builder forCfnChannelNamespacePropsAn implementation forCfnChannelNamespacePropsTheAWS::AppSync::DataSourceresource creates data sources for resolvers in AWS AppSync to connect to, such as Amazon DynamoDB , AWS Lambda , and Amazon OpenSearch Service .TheAuthorizationConfigproperty type specifies the authorization type and configuration for an AWS AppSync http data source.A builder forCfnDataSource.AuthorizationConfigPropertyAn implementation forCfnDataSource.AuthorizationConfigPropertyUse theAwsIamConfigproperty type to specifyAwsIamConfigfor a AWS AppSync authorizaton.A builder forCfnDataSource.AwsIamConfigPropertyAn implementation forCfnDataSource.AwsIamConfigPropertyA fluent builder forCfnDataSource.Describes a Delta Sync configuration.A builder forCfnDataSource.DeltaSyncConfigPropertyAn implementation forCfnDataSource.DeltaSyncConfigPropertyTheDynamoDBConfigproperty type specifies theAwsRegionandTableNamefor an Amazon DynamoDB table in your account for an AWS AppSync data source.A builder forCfnDataSource.DynamoDBConfigPropertyAn implementation forCfnDataSource.DynamoDBConfigPropertyExample:A builder forCfnDataSource.ElasticsearchConfigPropertyAn implementation forCfnDataSource.ElasticsearchConfigPropertyThe data source.A builder forCfnDataSource.EventBridgeConfigPropertyAn implementation forCfnDataSource.EventBridgeConfigPropertyUse theHttpConfigproperty type to specifyHttpConfigfor an AWS AppSync data source.A builder forCfnDataSource.HttpConfigPropertyAn implementation forCfnDataSource.HttpConfigPropertyTheLambdaConfigproperty type specifies the Lambda function ARN for an AWS AppSync data source.A builder forCfnDataSource.LambdaConfigPropertyAn implementation forCfnDataSource.LambdaConfigPropertyTheOpenSearchServiceConfigproperty type specifies theAwsRegionandEndpointsfor an Amazon OpenSearch Service domain in your account for an AWS AppSync data source.A builder forCfnDataSource.OpenSearchServiceConfigPropertyAn implementation forCfnDataSource.OpenSearchServiceConfigPropertyUse theRdsHttpEndpointConfigproperty type to specify theRdsHttpEndpointfor an AWS AppSync relational database.A builder forCfnDataSource.RdsHttpEndpointConfigPropertyAn implementation forCfnDataSource.RdsHttpEndpointConfigPropertyUse theRelationalDatabaseConfigproperty type to specifyRelationalDatabaseConfigfor an AWS AppSync data source.A builder forCfnDataSource.RelationalDatabaseConfigPropertyAn implementation forCfnDataSource.RelationalDatabaseConfigPropertyProperties for defining aCfnDataSource.A builder forCfnDataSourcePropsAn implementation forCfnDataSourcePropsTheAWS::AppSync::DomainNameresource creates aDomainNameConfigobject to configure a custom domain.A fluent builder forCfnDomainName.TheAWS::AppSync::DomainNameApiAssociationresource represents the mapping of your custom domain name to the assigned API URL.A fluent builder forCfnDomainNameApiAssociation.Properties for defining aCfnDomainNameApiAssociation.A builder forCfnDomainNameApiAssociationPropsAn implementation forCfnDomainNameApiAssociationPropsProperties for defining aCfnDomainName.A builder forCfnDomainNamePropsAn implementation forCfnDomainNamePropsTheAWS::AppSync::FunctionConfigurationresource defines the functions in GraphQL APIs to perform certain operations.Describes a runtime used by an AWS AppSync resolver or AWS AppSync function.A builder forCfnFunctionConfiguration.AppSyncRuntimePropertyAn implementation forCfnFunctionConfiguration.AppSyncRuntimePropertyA fluent builder forCfnFunctionConfiguration.TheLambdaConflictHandlerConfigobject when configuringLAMBDAas the Conflict Handler.An implementation forCfnFunctionConfiguration.LambdaConflictHandlerConfigPropertyDescribes a Sync configuration for a resolver.A builder forCfnFunctionConfiguration.SyncConfigPropertyAn implementation forCfnFunctionConfiguration.SyncConfigPropertyProperties for defining aCfnFunctionConfiguration.A builder forCfnFunctionConfigurationPropsAn implementation forCfnFunctionConfigurationPropsTheAWS::AppSync::GraphQLApiresource creates a new AWS AppSync GraphQL API.Describes an additional authentication provider.A builder forCfnGraphQLApi.AdditionalAuthenticationProviderPropertyAn implementation forCfnGraphQLApi.AdditionalAuthenticationProviderPropertyA fluent builder forCfnGraphQLApi.Describes an Amazon Cognito user pool configuration.A builder forCfnGraphQLApi.CognitoUserPoolConfigPropertyAn implementation forCfnGraphQLApi.CognitoUserPoolConfigPropertyDescribes an enhanced metrics configuration.A builder forCfnGraphQLApi.EnhancedMetricsConfigPropertyAn implementation forCfnGraphQLApi.EnhancedMetricsConfigPropertyConfiguration for AWS Lambda function authorization.A builder forCfnGraphQLApi.LambdaAuthorizerConfigPropertyAn implementation forCfnGraphQLApi.LambdaAuthorizerConfigPropertyTheLogConfigproperty type specifies the logging configuration when writing GraphQL operations and tracing to Amazon CloudWatch for an AWS AppSync GraphQL API.A builder forCfnGraphQLApi.LogConfigPropertyAn implementation forCfnGraphQLApi.LogConfigPropertyTheOpenIDConnectConfigproperty type specifies the optional authorization configuration for using an OpenID Connect compliant service with your GraphQL endpoint for an AWS AppSync GraphQL API.A builder forCfnGraphQLApi.OpenIDConnectConfigPropertyAn implementation forCfnGraphQLApi.OpenIDConnectConfigPropertyTheUserPoolConfigproperty type specifies the optional authorization configuration for using Amazon Cognito user pools with your GraphQL endpoint for an AWS AppSync GraphQL API.A builder forCfnGraphQLApi.UserPoolConfigPropertyAn implementation forCfnGraphQLApi.UserPoolConfigPropertyProperties for defining aCfnGraphQLApi.A builder forCfnGraphQLApiPropsAn implementation forCfnGraphQLApiPropsTheAWS::AppSync::GraphQLSchemaresource is used for your AWS AppSync GraphQL schema that controls the data model for your API.A fluent builder forCfnGraphQLSchema.Properties for defining aCfnGraphQLSchema.A builder forCfnGraphQLSchemaPropsAn implementation forCfnGraphQLSchemaPropsTheAWS::AppSync::Resolverresource defines the logical GraphQL resolver that you attach to fields in a schema.Describes a runtime used by an AWS AppSync resolver or AWS AppSync function.A builder forCfnResolver.AppSyncRuntimePropertyAn implementation forCfnResolver.AppSyncRuntimePropertyA fluent builder forCfnResolver.The caching configuration for a resolver that has caching activated.A builder forCfnResolver.CachingConfigPropertyAn implementation forCfnResolver.CachingConfigPropertyTheLambdaConflictHandlerConfigwhen configuring LAMBDA as the Conflict Handler.A builder forCfnResolver.LambdaConflictHandlerConfigPropertyAn implementation forCfnResolver.LambdaConflictHandlerConfigPropertyUse thePipelineConfigproperty type to specifyPipelineConfigfor an AWS AppSync resolver.A builder forCfnResolver.PipelineConfigPropertyAn implementation forCfnResolver.PipelineConfigPropertyDescribes a Sync configuration for a resolver.A builder forCfnResolver.SyncConfigPropertyAn implementation forCfnResolver.SyncConfigPropertyProperties for defining aCfnResolver.A builder forCfnResolverPropsAn implementation forCfnResolverPropsDescribes the configuration of a source API.A fluent builder forCfnSourceApiAssociation.Describes properties used to specify configurations related to a source API.An implementation forCfnSourceApiAssociation.SourceApiAssociationConfigPropertyProperties for defining aCfnSourceApiAssociation.A builder forCfnSourceApiAssociationPropsAn implementation forCfnSourceApiAssociationPropsA Channel Namespace.A fluent builder forChannelNamespace.Option configuration for channel namespace.A builder forChannelNamespaceOptionsAn implementation forChannelNamespaceOptionsAdditional property for an AppSync channel namespace for an Event API reference.A builder forChannelNamespacePropsAn implementation forChannelNamespacePropsRepresents source code for an AppSync Function or Resolver.Result of bindingCodeinto aFunction.A builder forCodeConfigAn implementation forCodeConfigOptional configuration for data sources.A builder forDataSourceOptionsAn implementation forDataSourceOptionsAppSync definition.Domain name configuration for AppSync.A builder forDomainOptionsAn implementation forDomainOptionsAn AppSync datasource backed by a DynamoDB table.A fluent builder forDynamoDbDataSource.Properties for an AppSync DynamoDB datasource.A builder forDynamoDbDataSourcePropsAn implementation forDynamoDbDataSourcePropsDeprecated.Deprecated.Deprecated.useOpenSearchDataSourcePropswithOpenSearchDataSourceDeprecated.Deprecated.An AppSync Event API.A fluent builder forEventApi.Attributes for Event API imports.A builder forEventApiAttributesAn implementation forEventApiAttributesAuthorization configuration for the Event API.A builder forEventApiAuthConfigAn implementation forEventApiAuthConfigBase Class for Event API.Properties for an AppSync Event API.A builder forEventApiPropsAn implementation forEventApiPropsAn AppSync datasource backed by EventBridge.A fluent builder forEventBridgeDataSource.Properties for an AppSync EventBridge datasource.A builder forEventBridgeDataSourcePropsAn implementation forEventBridgeDataSourcePropsprops used by implementations of BaseDataSource to provide configuration.A builder forExtendedDataSourcePropsAn implementation forExtendedDataSourcePropsAdditional property for an AppSync resolver for data source reference.A builder forExtendedResolverPropsAn implementation forExtendedResolverPropslog-level for fields in AppSync.Utility class for specifying specific appsync runtime versions.Appsync supported runtimes.An AppSync GraphQL API.A fluent builder forGraphqlApi.Attributes for GraphQL imports.A builder forGraphqlApiAttributesAn implementation forGraphqlApiAttributesBase Class for GraphQL API.Properties for an AppSync GraphQL API.A builder forGraphqlApiPropsAn implementation forGraphqlApiPropsEnumerated type for the handler behavior for a channel namespace.Handler configuration construct for onPublish and onSubscribe.A builder forHandlerConfigAn implementation forHandlerConfigAn AppSync datasource backed by a http endpoint.A fluent builder forHttpDataSource.Optional configuration for Http data sources.A builder forHttpDataSourceOptionsAn implementation forHttpDataSourceOptionsProperties for an AppSync http datasource.A builder forHttpDataSourcePropsAn implementation forHttpDataSourcePropsA class used to generate resource arns for AppSync.Interface for an API.Internal default implementation forIApi.A proxy class which represents a concrete javascript instance of this type.Exposes methods for defining authorization config for AppSync APIs.Internal default implementation forIAppSyncAuthConfig.A proxy class which represents a concrete javascript instance of this type.Interface for AppSync Functions.Internal default implementation forIAppsyncFunction.A proxy class which represents a concrete javascript instance of this type.An AppSync channel namespace.Internal default implementation forIChannelNamespace.A proxy class which represents a concrete javascript instance of this type.Interface for Event API.Internal default implementation forIEventApi.A proxy class which represents a concrete javascript instance of this type.Interface for GraphQL.Internal default implementation forIGraphqlApi.A proxy class which represents a concrete javascript instance of this type.AppSync function code from an inline string.Introspection configuration for a GraphQL API.Interface for implementing your own schema.Internal default implementation forISchema.A proxy class which represents a concrete javascript instance of this type.Configuration for bound graphql schema.Internal default implementation forISchemaConfig.A proxy class which represents a concrete javascript instance of this type.Interface for AppSync Source Api Association.Internal default implementation forISourceApiAssociation.A proxy class which represents a concrete javascript instance of this type.Factory class for DynamoDB key conditions.Configuration for Lambda authorization in AppSync.A builder forLambdaAuthorizerConfigAn implementation forLambdaAuthorizerConfigAn AppSync datasource backed by a Lambda function.A fluent builder forLambdaDataSource.Properties for an AppSync Lambda datasource.A builder forLambdaDataSourcePropsAn implementation forLambdaDataSourcePropsInvoke types for direct Lambda data sources.Logging configuration for AppSync.A builder forLogConfigAn implementation forLogConfigMappingTemplates for AppSync resolvers.Merge type used to associate the source API.Authorization configuration for the Channel Namespace.A builder forNamespaceAuthConfigAn implementation forNamespaceAuthConfigAn AppSync dummy datasource.A fluent builder forNoneDataSource.Properties for an AppSync dummy datasource.A builder forNoneDataSourcePropsAn implementation forNoneDataSourcePropsConfiguration for OpenID Connect authorization in AppSync.A builder forOpenIdConnectConfigAn implementation forOpenIdConnectConfigAn Appsync datasource backed by OpenSearch.A fluent builder forOpenSearchDataSource.Properties for the OpenSearch Data Source.A builder forOpenSearchDataSourcePropsAn implementation forOpenSearchDataSourcePropsSpecifies the assignment to the partition key.Utility class to allow assigning a value or an auto-generated id to a partition key.Specifies the assignment to the primary key.An AppSync datasource backed by RDS.A fluent builder forRdsDataSource.Properties for an AppSync RDS datasource Aurora Serverless V1.A builder forRdsDataSourcePropsAn implementation forRdsDataSourcePropsProperties for an AppSync RDS datasource Aurora Serverless V2.A builder forRdsDataSourcePropsV2An implementation forRdsDataSourcePropsV2An AppSync resolver.A fluent builder forResolver.Additional property for an AppSync resolver for GraphQL API reference.A builder forResolverPropsAn implementation forResolverPropsConfig for binding runtime to a function or resolver.A builder forRuntimeConfigAn implementation forRuntimeConfigUsed for configuring schema bind behavior.A builder forSchemaBindOptionsAn implementation forSchemaBindOptionsThe Schema for a GraphQL Api.A fluent builder forSchemaFile.The options for configuring a schema from an existing file.A builder forSchemaPropsAn implementation forSchemaPropsUtility class to allow assigning a value or an auto-generated id to a sort key.Configuration of source API.A builder forSourceApiAn implementation forSourceApiAppSync SourceApiAssociation which associates an AppSync source API to an AppSync Merged API.A fluent builder forSourceApiAssociation.The attributes for imported AppSync Source Api Association.A builder forSourceApiAssociationAttributesAn implementation forSourceApiAssociationAttributesProperties for SourceApiAssociation which associates an AppSync Source API with an AppSync Merged API.A builder forSourceApiAssociationPropsAn implementation forSourceApiAssociationPropsAdditional API configuration for creating a AppSync Merged API.A builder forSourceApiOptionsAn implementation forSourceApiOptionsConfiguration for Cognito user-pools in AppSync.A builder forUserPoolConfigAn implementation forUserPoolConfigenum with all possible values for Cognito user-pool default actions.Factory class for attribute value assignments.Visibility type for a GraphQL API.
OpenSearchDataSource