Skip to content
v2.275.0

AppSyncDynamoDbDataSource ​

An AppSync datasource backed by a DynamoDB table.

Example ​

ts
const api = new appsync.EventApi(this, 'EventApiDynamoDB', {
  apiName: 'DynamoDBEventApi',
});

const table = new dynamodb.Table(this, 'table', {
  tableName: 'event-messages',
  partitionKey: {
    name: 'id',
    type: dynamodb.AttributeType.STRING,
  },
});

const dataSource = api.addDynamoDbDataSource('ddbsource', table);
python
api = appsync.EventApi(self, "EventApiDynamoDB",
    api_name="DynamoDBEventApi"
)

table = dynamodb.Table(self, "table",
    table_name="event-messages",
    partition_key=dynamodb.Attribute(
        name="id",
        type=dynamodb.AttributeType.STRING
    )
)

data_source = api.add_dynamo_db_data_source("ddbsource", table)
java
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);
csharp
// Install: dotnet add package Amazon.CDK.Lib
var api = new EventApi(this, "EventApiDynamoDB", new EventApiProps {
    ApiName = "DynamoDBEventApi"
});

var table = new Table(this, "table", new TableProps {
    TableName = "event-messages",
    PartitionKey = new Attribute {
        Name = "id",
        Type = AttributeType.STRING
    }
});

var dataSource = api.AddDynamoDbDataSource("ddbsource", table);
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
api := appsync.NewEventApi(this, jsii.String("EventApiDynamoDB"), &EventApiProps{
	ApiName: jsii.String("DynamoDBEventApi"),
})

table := dynamodb.NewTable(this, jsii.String("table"), &TableProps{
	TableName: jsii.String("event-messages"),
	PartitionKey: &Attribute{
		Name: jsii.String("id"),
		Type: dynamodb.AttributeType_STRING,
	},
})

dataSource := api.AddDynamoDbDataSource(jsii.String("ddbsource"), table)

Initializer ​

ts
new AppSyncDynamoDbDataSource(scope: Construct, id: string, props: AppSyncDynamoDbDataSourceProps)
python
AppSyncDynamoDbDataSource(scope: Construct, id: str, props: AppSyncDynamoDbDataSourceProps)
java
new AppSyncDynamoDbDataSource(Construct scope, String id, AppSyncDynamoDbDataSourceProps props)
csharp
new AppSyncDynamoDbDataSource(Construct scope, string id, AppSyncDynamoDbDataSourceProps props)
go
NewAppSyncDynamoDbDataSource(Scope Construct, Id *string, Props AppSyncDynamoDbDataSourceProps)

Construct Props ​

The API to attach this data source to.
descriptionoptionalstringdescriptionoptionalstrdescriptionoptionalStringDescriptionoptionalstringDescriptionoptional*string= None#
The description of the data source.
nameoptionalstringnameoptionalstrnameoptionalStringNameoptionalstringNameoptional*string#
The name of the data source.

Default: id of data source

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

readOnlyAccessoptionalbooleanread_only_accessoptionalboolreadOnlyAccessoptionalBooleanReadOnlyAccessoptionalboolReadOnlyAccessoptional*bool= false#
Specify whether this Data Source is read only or has read and write permissions to the DynamoDB table.
serviceRoleoptionalIRoleservice_roleoptionalIRoleserviceRoleoptionalIRoleServiceRoleoptionalIRoleServiceRoleoptionalIRole#
The IAM service role to be assumed by AppSync to interact with the data source.

Default: Create a new role

tableITabletableITabletableITableTableITableTableITablerequired#
The DynamoDB table backing this data source.
useCallerCredentialsoptionalbooleanuse_caller_credentialsoptionalbooluseCallerCredentialsoptionalBooleanUseCallerCredentialsoptionalboolUseCallerCredentialsoptional*bool= false#
Use credentials of caller to access DynamoDB.

Properties ​

grantPrincipalIPrincipalgrant_principalIPrincipalgrantPrincipalIPrincipalGrantPrincipalIPrincipalGrantPrincipalIPrincipal#
The principal of the data source to be IGrantable.
namestringnamestrnameStringNamestringName*string#
The name of the data source.
nodeNodenodeNodenodeNodeNodeNodeNodeNode#
The tree node.
The underlying CFN data source resource.

Methods ​

isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#
Checks if `x` is a construct.
notes · 1 parameter · returns

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

  • xxxxX — Any object.

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

toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Returns a string representation of this construct.
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func 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.

1 parameter · returns

Parameters

  • mixinsmixinsmixinsmixinsMixins — The mixins to apply.

Returns: This construct for chaining