# AppSyncBackedDataSource

Abstract AppSync datasource implementation.

Do not use directly but use subclasses for resource backed datasources

Extends: Construct › AppSyncBaseDataSource › AppSyncBackedDataSource
Implements: IGrantable, IConstruct, IDependable
Superclass of: AppSyncDynamoDbDataSource, AppSyncEventBridgeDataSource, AppSyncHttpDataSource, AppSyncLambdaDataSource, AppSyncOpenSearchDataSource, AppSyncRdsDataSource

- Source: [`aws-appsync/lib/data-source-common.ts`](https://github.com/aws/aws-cdk/blob/v2.273.0/packages/aws-cdk-lib/aws-appsync/lib/data-source-common.ts#L220)
- Type last changed: v2.193.0 · 30 Apr 2025

## Example

```ts
declare const api: appsync.EventApi;
declare const ddbDataSource: appsync.AppSyncDynamoDbDataSource;
declare const ebDataSource: appsync.AppSyncEventBridgeDataSource;

// DynamoDB data source for publish handler
api.addChannelNamespace('ddb-eb-ns', {
  code: appsync.Code.fromInline('/* event handler code here.*/'),
  publishHandlerConfig: {
    dataSource: ddbDataSource,
  },
  subscribeHandlerConfig: {
    dataSource: ebDataSource,
  },
});
```

## Initializer

```ts
new AppSyncBackedDataSource(scope: Construct, id: string, props: AppSyncBackedDataSourceProps, extended: AppSyncExtendedDataSourceProps)
```

## Construct Props

- `api`: [IApiRef](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_appsync.IApiRef.html) (required) — The API to attach this data source to.

- `description`: string = None — The description of the data source.

- `name`: string = id of data source — The name of the data source.

  The only allowed pattern is: {[_A-Za-z][_0-9A-Za-z]*}.
  Any invalid characters will be automatically removed.

- `serviceRole`: [IRole](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) = Create a new role — The IAM service role to be assumed by AppSync to interact with the data source.

## Construct Props

- `dynamoDbConfig`: [IResolvable](/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnDataSource.DynamoDBConfigProperty](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.CfnDataSource.DynamoDBConfigProperty.html) = No config — Configuration for DynamoDB Datasource.

- `eventBridgeConfig`: [IResolvable](/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnDataSource.EventBridgeConfigProperty](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.CfnDataSource.EventBridgeConfigProperty.html) = No config — Configuration for EventBridge Datasource.

- `httpConfig`: [IResolvable](/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnDataSource.HttpConfigProperty](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.CfnDataSource.HttpConfigProperty.html) = No config — Configuration for HTTP Datasource.

- `lambdaConfig`: [IResolvable](/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnDataSource.LambdaConfigProperty](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.CfnDataSource.LambdaConfigProperty.html) = No config — Configuration for Lambda Datasource.

- `openSearchServiceConfig`: [IResolvable](/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnDataSource.OpenSearchServiceConfigProperty](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.CfnDataSource.OpenSearchServiceConfigProperty.html) = No config — Configuration for OpenSearch data source.

- `relationalDatabaseConfig`: [IResolvable](/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnDataSource.RelationalDatabaseConfigProperty](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.CfnDataSource.RelationalDatabaseConfigProperty.html) = No config — Configuration for RDS Datasource.

- `type`: [AppSyncDataSourceType](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.AppSyncDataSourceType.html) (required) — The type of the AppSync datasource.

## Properties

- `grantPrincipal`: [IPrincipal](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IPrincipal.html) (required) — The principal of the data source to be IGrantable.

- `name`: string (required) — The name of the data source.

- `node`: [Node](/cdk/api/v2/docs/constructs.Node.html) (required) — The tree node.

- `resource`: [CfnDataSource](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.CfnDataSource.html) (required) — The underlying CFN data source resource.

## Methods

- `isConstruct(x: any): boolean` (static) — Checks if `x` is a construct.

  Use this method instead of `instanceof` to properly detect `Construct`
  instances, even when the construct library is symlinked.

  Explanation: in JavaScript, multiple copies of the `constructs` library on
  disk are seen as independent, completely different libraries. As a
  consequence, the class `Construct` in each copy of the `constructs` library
  is seen as a different class, and an instance of one class will not test as
  `instanceof` the other class. `npm install` will not create installations
  like this, but users may manually symlink construct libraries together or
  use a monorepo tool: in those cases, multiple copies of the `constructs`
  library can be accidentally installed, and `instanceof` will behave
  unpredictably. It is safest to avoid using `instanceof`, and using
  this type-testing method instead.

  **Parameters**

  - `x` — Any object.

  **Returns:** true if `x` is an object created from a class which extends `Construct`.

- `toString(): string` — Returns a string representation of this construct.

- `with(...mixins: IMixin[]): IConstruct` — Applies one or more mixins to this construct.

  Mixins are applied in order. The list of constructs is captured at the
  start of the call, so constructs added by a mixin will not be visited.
  Use multiple `with()` calls if subsequent mixins should apply to added
  constructs.

  **Parameters**

  - `mixins` — The mixins to apply.

  **Returns:** This construct for chaining
