This documentation is for the developer preview release of the AWS CDK. Do not use this version of the AWS CDK in production. Subsequent releases of the AWS CDK will likely include breaking changes.

@aws-cdk/aws-dynamodb

AWS DynamoDB Construct Library

Here is a minimal deployable DynamoDB table definition:

import dynamodb = require('@aws-cdk/aws-dynamodb');

const table = new dynamodb.Table(this, 'Table', {
  partitionKey: { name: 'id', type: dynamodb.AttributeType.String }
});

Keys

When a table is defined, you must define it’s schema using the partitionKey (required) and sortKey (optional) properties.

Billing Mode

DynamoDB supports two billing modes:

  • PROVISIONED - the default mode where the table and global secondary indexes have configured read and write capacity.
  • PAY_PER_REQUEST - on-demand pricing and scaling. You only pay for what you use and there is no read and write capacity for the table or its global secondary indexes.
import dynamodb = require('@aws-cdk/aws-dynamodb');

const table = new dynamodb.Table(this, 'Table', {
  partitionKey: { name: 'id', type: dynamodb.AttributeType.String },
  billingMode: dynamodb.BillingMode.PayPerRequest
});

Further reading: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadWriteCapacityMode.

Configure AutoScaling for your table

You can have DynamoDB automatically raise and lower the read and write capacities of your table by setting up autoscaling. You can use this to either keep your tables at a desired utilization level, or by scaling up and down at preconfigured times of the day:

Auto-scaling is only relevant for tables with the billing mode, PROVISIONED.

const readScaling = table.autoScaleReadCapacity({ minCapacity: 1, maxCapacity: 50 });

readScaling.scaleOnUtilization({
  targetUtilizationPercent: 50
});

readScaling.scaleOnSchedule('ScaleUpInTheMorning', {
  schedule: appscaling.Cron.dailyUtc(8),
  minCapacity: 20,
});

readScaling.scaleOnSchedule('ScaleDownAtNight', {
  schedule: appscaling.Cron.dailyUtc(20),
  maxCapacity: 20
});

Further reading: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/AutoScaling.html https://aws.amazon.com/blogs/database/how-to-use-aws-cloudformation-to-configure-auto-scaling-for-amazon-dynamodb-tables-and-indexes/

Reference

View in Nuget

csproj:

<PackageReference Include="Amazon.CDK.AWS.DynamoDB" Version="0.25.3" />

dotnet:

dotnet add package Amazon.CDK.AWS.DynamoDB --version 0.25.3

packages.config:

<package id="Amazon.CDK.AWS.DynamoDB" version="0.25.3" />

View in Maven Central

Apache Buildr:

'software.amazon.awscdk:dynamodb:jar:0.25.3'

Apache Ivy:

<dependency groupId="software.amazon.awscdk" name="dynamodb" rev="0.25.3"/>

Apache Maven:

<dependency>
  <groupId>software.amazon.awscdk</groupId>
  <artifactId>dynamodb</artifactId>
  <version>0.25.3</version>
</dependency>

Gradle / Grails:

compile 'software.amazon.awscdk:dynamodb:0.25.3'

Groovy Grape:

@Grapes(
@Grab(group='software.amazon.awscdk', module='dynamodb', version='0.25.3')
)

View in NPM

npm:

$ npm i @aws-cdk/aws-dynamodb@0.25.3

package.json:

{
  "@aws-cdk/aws-dynamodb": "^0.25.3"
}

yarn:

$ yarn add @aws-cdk/aws-dynamodb@0.25.3

View in NPM

npm:

$ npm i @aws-cdk/aws-dynamodb@0.25.3

package.json:

{
  "@aws-cdk/aws-dynamodb": "^0.25.3"
}

yarn:

$ yarn add @aws-cdk/aws-dynamodb@0.25.3

Attribute (interface)

class @aws-cdk/aws-dynamodb.Attribute

Language-specific names:

using Amazon.CDK.AWS.DynamoDB;
import software.amazon.awscdk.services.dynamodb.Attribute;
// Attribute is an interface
import { Attribute } from '@aws-cdk/aws-dynamodb';
name

The name of an attribute.

Type:string
type

The data type of an attribute.

Type:AttributeType

AttributeType (enum)

class @aws-cdk/aws-dynamodb.AttributeType

Language-specific names:

using Amazon.CDK.AWS.DynamoDB;
import software.amazon.awscdk.services.dynamodb.AttributeType;
const { AttributeType } = require('@aws-cdk/aws-dynamodb');
import { AttributeType } from '@aws-cdk/aws-dynamodb';
Binary
Number
String

BillingMode (enum)

class @aws-cdk/aws-dynamodb.BillingMode

Language-specific names:

using Amazon.CDK.AWS.DynamoDB;
import software.amazon.awscdk.services.dynamodb.BillingMode;
const { BillingMode } = require('@aws-cdk/aws-dynamodb');
import { BillingMode } from '@aws-cdk/aws-dynamodb';

DyanmoDB’s Read/Write capacity modes.

PayPerRequest

Pay only for what you use. You don’t configure Read/Write capacity units.

Provisioned

Explicitly specified Read/Write capacity units.

CfnTable

class @aws-cdk/aws-dynamodb.CfnTable(scope, id, props)

Language-specific names:

using Amazon.CDK.AWS.DynamoDB;
import software.amazon.awscdk.services.dynamodb.CfnTable;
const { CfnTable } = require('@aws-cdk/aws-dynamodb');
import { CfnTable } from '@aws-cdk/aws-dynamodb';
Extends:

@aws-cdk/cdk.Resource

Parameters:
renderProperties(properties) → string => any

Overrides @aws-cdk/cdk.Resource.renderProperties()

Protected method

Parameters:properties (any) –
Return type:string => any
resourceTypeName

The CloudFormation resource type name for this resource class.

Type:string (readonly) (static)
propertyOverrides
Type:CfnTableProps (readonly)
tableArn
Type:string (readonly)
tableName
Type:string (readonly)
tableStreamArn
Type:string (readonly)
tags

The TagManager handles setting, removing and formatting tags

Tags should be managed either passing them as properties during

initiation or by calling methods on this object. If both techniques are

used only the tags from the TagManager will be used. Tag (aspect)

will use the manager.

Type:@aws-cdk/cdk.TagManager (readonly)
class AttributeDefinitionProperty

Language-specific names:

using Amazon.CDK.AWS.DynamoDB;
import software.amazon.awscdk.services.dynamodb.CfnTable.AttributeDefinitionProperty;
// CfnTable.AttributeDefinitionProperty is an interface
import { CfnTable.AttributeDefinitionProperty } from '@aws-cdk/aws-dynamodb';
attributeName

CfnTable.AttributeDefinitionProperty.AttributeName

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-attributedef.html#cfn-dynamodb-attributedef-attributename

Type:string
attributeType

CfnTable.AttributeDefinitionProperty.AttributeType

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-attributedef.html#cfn-dynamodb-attributedef-attributename-attributetype

Type:string
class GlobalSecondaryIndexProperty

Language-specific names:

using Amazon.CDK.AWS.DynamoDB;
import software.amazon.awscdk.services.dynamodb.CfnTable.GlobalSecondaryIndexProperty;
// CfnTable.GlobalSecondaryIndexProperty is an interface
import { CfnTable.GlobalSecondaryIndexProperty } from '@aws-cdk/aws-dynamodb';
indexName

CfnTable.GlobalSecondaryIndexProperty.IndexName

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-gsi.html#cfn-dynamodb-gsi-indexname

Type:string
keySchema

CfnTable.GlobalSecondaryIndexProperty.KeySchema

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-gsi.html#cfn-dynamodb-gsi-keyschema

Type:@aws-cdk/cdk.Token or (KeySchemaProperty or @aws-cdk/cdk.Token)[]
projection

CfnTable.GlobalSecondaryIndexProperty.Projection

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-gsi.html#cfn-dynamodb-gsi-projection

Type:@aws-cdk/cdk.Token or ProjectionProperty
provisionedThroughput

CfnTable.GlobalSecondaryIndexProperty.ProvisionedThroughput

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-gsi.html#cfn-dynamodb-gsi-provisionedthroughput

Type:@aws-cdk/cdk.Token or ProvisionedThroughputProperty (optional)
class KeySchemaProperty

Language-specific names:

using Amazon.CDK.AWS.DynamoDB;
import software.amazon.awscdk.services.dynamodb.CfnTable.KeySchemaProperty;
// CfnTable.KeySchemaProperty is an interface
import { CfnTable.KeySchemaProperty } from '@aws-cdk/aws-dynamodb';
attributeName

CfnTable.KeySchemaProperty.AttributeName

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-keyschema.html#aws-properties-dynamodb-keyschema-attributename

Type:string
keyType

CfnTable.KeySchemaProperty.KeyType

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-keyschema.html#aws-properties-dynamodb-keyschema-keytype

Type:string
class LocalSecondaryIndexProperty

Language-specific names:

using Amazon.CDK.AWS.DynamoDB;
import software.amazon.awscdk.services.dynamodb.CfnTable.LocalSecondaryIndexProperty;
// CfnTable.LocalSecondaryIndexProperty is an interface
import { CfnTable.LocalSecondaryIndexProperty } from '@aws-cdk/aws-dynamodb';
indexName

CfnTable.LocalSecondaryIndexProperty.IndexName

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-lsi.html#cfn-dynamodb-lsi-indexname

Type:string
keySchema

CfnTable.LocalSecondaryIndexProperty.KeySchema

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-lsi.html#cfn-dynamodb-lsi-keyschema

Type:@aws-cdk/cdk.Token or (KeySchemaProperty or @aws-cdk/cdk.Token)[]
projection

CfnTable.LocalSecondaryIndexProperty.Projection

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-lsi.html#cfn-dynamodb-lsi-projection

Type:@aws-cdk/cdk.Token or ProjectionProperty
class PointInTimeRecoverySpecificationProperty

Language-specific names:

using Amazon.CDK.AWS.DynamoDB;
import software.amazon.awscdk.services.dynamodb.CfnTable.PointInTimeRecoverySpecificationProperty;
// CfnTable.PointInTimeRecoverySpecificationProperty is an interface
import { CfnTable.PointInTimeRecoverySpecificationProperty } from '@aws-cdk/aws-dynamodb';
pointInTimeRecoveryEnabled

CfnTable.PointInTimeRecoverySpecificationProperty.PointInTimeRecoveryEnabled

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-table-pointintimerecoveryspecification.html#cfn-dynamodb-table-pointintimerecoveryspecification-pointintimerecoveryenabled

Type:boolean or @aws-cdk/cdk.Token (optional)
class ProjectionProperty

Language-specific names:

using Amazon.CDK.AWS.DynamoDB;
import software.amazon.awscdk.services.dynamodb.CfnTable.ProjectionProperty;
// CfnTable.ProjectionProperty is an interface
import { CfnTable.ProjectionProperty } from '@aws-cdk/aws-dynamodb';
nonKeyAttributes

CfnTable.ProjectionProperty.NonKeyAttributes

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-projectionobject.html#cfn-dynamodb-projectionobj-nonkeyatt

Type:@aws-cdk/cdk.Token or (string or @aws-cdk/cdk.Token)[] (optional)
projectionType

CfnTable.ProjectionProperty.ProjectionType

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-projectionobject.html#cfn-dynamodb-projectionobj-projtype

Type:string (optional)
class ProvisionedThroughputProperty

Language-specific names:

using Amazon.CDK.AWS.DynamoDB;
import software.amazon.awscdk.services.dynamodb.CfnTable.ProvisionedThroughputProperty;
// CfnTable.ProvisionedThroughputProperty is an interface
import { CfnTable.ProvisionedThroughputProperty } from '@aws-cdk/aws-dynamodb';
readCapacityUnits

CfnTable.ProvisionedThroughputProperty.ReadCapacityUnits

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-provisionedthroughput.html#cfn-dynamodb-provisionedthroughput-readcapacityunits

Type:number or @aws-cdk/cdk.Token
writeCapacityUnits

CfnTable.ProvisionedThroughputProperty.WriteCapacityUnits

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-provisionedthroughput.html#cfn-dynamodb-provisionedthroughput-writecapacityunits

Type:number or @aws-cdk/cdk.Token
class SSESpecificationProperty

Language-specific names:

using Amazon.CDK.AWS.DynamoDB;
import software.amazon.awscdk.services.dynamodb.CfnTable.SSESpecificationProperty;
// CfnTable.SSESpecificationProperty is an interface
import { CfnTable.SSESpecificationProperty } from '@aws-cdk/aws-dynamodb';
sseEnabled

CfnTable.SSESpecificationProperty.SSEEnabled

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-table-ssespecification.html#cfn-dynamodb-table-ssespecification-sseenabled

Type:boolean or @aws-cdk/cdk.Token
class StreamSpecificationProperty

Language-specific names:

using Amazon.CDK.AWS.DynamoDB;
import software.amazon.awscdk.services.dynamodb.CfnTable.StreamSpecificationProperty;
// CfnTable.StreamSpecificationProperty is an interface
import { CfnTable.StreamSpecificationProperty } from '@aws-cdk/aws-dynamodb';
streamViewType

CfnTable.StreamSpecificationProperty.StreamViewType

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-streamspecification.html#cfn-dynamodb-streamspecification-streamviewtype

Type:string
class TimeToLiveSpecificationProperty

Language-specific names:

using Amazon.CDK.AWS.DynamoDB;
import software.amazon.awscdk.services.dynamodb.CfnTable.TimeToLiveSpecificationProperty;
// CfnTable.TimeToLiveSpecificationProperty is an interface
import { CfnTable.TimeToLiveSpecificationProperty } from '@aws-cdk/aws-dynamodb';
attributeName

CfnTable.TimeToLiveSpecificationProperty.AttributeName

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-timetolivespecification.html#cfn-dynamodb-timetolivespecification-attributename

Type:string
enabled

CfnTable.TimeToLiveSpecificationProperty.Enabled

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-dynamodb-timetolivespecification.html#cfn-dynamodb-timetolivespecification-enabled

Type:boolean or @aws-cdk/cdk.Token
toString() → string

Inherited from @aws-cdk/cdk.Construct

Returns a string representation of this construct.

Return type:string
validate() → string[]

Inherited from @aws-cdk/cdk.Construct

Validate the current construct.

This method can be implemented by derived constructs in order to perform

validation logic. It is called on all constructs before synthesis.

Protected method

Returns:An array of validation error messages, or an empty array if there the construct is valid.
Return type:string[]
dependencyRoots

Inherited from @aws-cdk/cdk.Construct

The set of constructs that form the root of this dependable

All resources under all returned constructs are included in the ordering

dependency.

Type:@aws-cdk/cdk.IConstruct[] (readonly)
node

Inherited from @aws-cdk/cdk.Construct

Construct node.

Type:@aws-cdk/cdk.ConstructNode (readonly)
ref

Inherited from @aws-cdk/cdk.Referenceable

Returns a token to a CloudFormation { Ref } that references this entity based on it’s logical ID.

Type:string (readonly)
addDeletionOverride(path)

Inherited from @aws-cdk/cdk.Resource

Syntactic sugar for addOverride(path, undefined).

Parameters:path (string) – The path of the value to delete
addDependsOn(resource)

Inherited from @aws-cdk/cdk.Resource

Indicates that this resource depends on another resource and cannot be provisioned

unless the other resource has been successfully provisioned.

Parameters:resource (@aws-cdk/cdk.Resource) –
addOverride(path, value)

Inherited from @aws-cdk/cdk.Resource

Adds an override to the synthesized CloudFormation resource. To add a

property override, either use addPropertyOverride or prefix path with

“Properties.” (i.e. Properties.TopicName).

Parameters:
  • path (string) – The path of the property, you can use dot notation to override values in complex types. Any intermdediate keys will be created as needed.
  • value (any) – The value. Could be primitive or complex.
addPropertyDeletionOverride(propertyPath)

Inherited from @aws-cdk/cdk.Resource

Adds an override that deletes the value of a property from the resource definition.

Parameters:propertyPath (string) – The path to the property.
addPropertyOverride(propertyPath, value)

Inherited from @aws-cdk/cdk.Resource

Adds an override to a resource property.

Syntactic sugar for addOverride(“Properties.<…>”, value).

Parameters:
  • propertyPath (string) – The path of the property
  • value (any) – The value
getAtt(attributeName) → @aws-cdk/cdk.CfnReference

Inherited from @aws-cdk/cdk.Resource

Returns a token for an runtime attribute of this resource.

Ideally, use generated attribute accessors (e.g. resource.arn), but this can be used for future compatibility

in case there is no generated attribute.

Parameters:attributeName (string) – The name of the attribute.
Return type:@aws-cdk/cdk.CfnReference
toCloudFormation() → json

Inherited from @aws-cdk/cdk.Resource

Emits CloudFormation for this resource.

Return type:json
options

Inherited from @aws-cdk/cdk.Resource

Options for this resource, such as condition, update policy etc.

Type:@aws-cdk/cdk.ResourceOptions (readonly)
properties

Inherited from @aws-cdk/cdk.Resource

AWS resource properties.

This object is rendered via a call to “renderProperties(this.properties)”.

Protected property

Type:any (readonly)
resourceType

Inherited from @aws-cdk/cdk.Resource

AWS resource type.

Type:string (readonly)
untypedPropertyOverrides

Inherited from @aws-cdk/cdk.Resource

AWS resource property overrides.

During synthesis, the method “renderProperties(this.overrides)” is called

with this object, and merged on top of the output of

“renderProperties(this.properties)”.

Derived classes should expose a strongly-typed version of this object as

a public property called propertyOverrides.

Protected property

Type:any (readonly)
overrideLogicalId(newLogicalId)

Inherited from @aws-cdk/cdk.StackElement

Overrides the auto-generated logical ID with a specific ID.

Parameters:newLogicalId (string) – The new logical ID to use for this stack element.
prepare()

Inherited from @aws-cdk/cdk.StackElement

Automatically detect references in this StackElement

Protected method

creationStackTrace

Inherited from @aws-cdk/cdk.StackElement

Type:string[] (readonly)
logicalId

Inherited from @aws-cdk/cdk.StackElement

The logical ID for this CloudFormation stack element. The logical ID of the element

is calculated from the path of the resource node in the construct tree.

To override this value, use overrideLogicalId(newLogicalId).

Type:string (readonly)
stackPath

Inherited from @aws-cdk/cdk.StackElement

Return the path with respect to the stack

Type:string (readonly)

CfnTableProps (interface)

class @aws-cdk/aws-dynamodb.CfnTableProps

Language-specific names:

using Amazon.CDK.AWS.DynamoDB;
import software.amazon.awscdk.services.dynamodb.CfnTableProps;
// CfnTableProps is an interface
import { CfnTableProps } from '@aws-cdk/aws-dynamodb';
keySchema

AWS::DynamoDB::Table.KeySchema

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html#cfn-dynamodb-table-keyschema

Type:@aws-cdk/cdk.Token or (KeySchemaProperty or @aws-cdk/cdk.Token)[]
attributeDefinitions

AWS::DynamoDB::Table.AttributeDefinitions

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html#cfn-dynamodb-table-attributedef

Type:@aws-cdk/cdk.Token or (@aws-cdk/cdk.Token or AttributeDefinitionProperty)[] (optional)
billingMode

AWS::DynamoDB::Table.BillingMode

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html#cfn-dynamodb-table-billingmode

Type:string (optional)
globalSecondaryIndexes

AWS::DynamoDB::Table.GlobalSecondaryIndexes

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html#cfn-dynamodb-table-gsi

Type:@aws-cdk/cdk.Token or (@aws-cdk/cdk.Token or GlobalSecondaryIndexProperty)[] (optional)
localSecondaryIndexes

AWS::DynamoDB::Table.LocalSecondaryIndexes

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html#cfn-dynamodb-table-lsi

Type:@aws-cdk/cdk.Token or (@aws-cdk/cdk.Token or LocalSecondaryIndexProperty)[] (optional)
pointInTimeRecoverySpecification

AWS::DynamoDB::Table.PointInTimeRecoverySpecification

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html#cfn-dynamodb-table-pointintimerecoveryspecification

Type:@aws-cdk/cdk.Token or PointInTimeRecoverySpecificationProperty (optional)
provisionedThroughput

AWS::DynamoDB::Table.ProvisionedThroughput

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html#cfn-dynamodb-table-provisionedthroughput

Type:@aws-cdk/cdk.Token or ProvisionedThroughputProperty (optional)
sseSpecification

AWS::DynamoDB::Table.SSESpecification

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html#cfn-dynamodb-table-ssespecification

Type:@aws-cdk/cdk.Token or SSESpecificationProperty (optional)
streamSpecification

AWS::DynamoDB::Table.StreamSpecification

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html#cfn-dynamodb-table-streamspecification

Type:@aws-cdk/cdk.Token or StreamSpecificationProperty (optional)
tableName

AWS::DynamoDB::Table.TableName

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html#cfn-dynamodb-table-tablename

Type:string (optional)
tags

AWS::DynamoDB::Table.Tags

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html#cfn-dynamodb-table-tags

Type:@aws-cdk/cdk.Token or (@aws-cdk/cdk.Token or @aws-cdk/cdk.CfnTag)[] (optional)
timeToLiveSpecification

AWS::DynamoDB::Table.TimeToLiveSpecification

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html#cfn-dynamodb-table-timetolivespecification

Type:@aws-cdk/cdk.Token or TimeToLiveSpecificationProperty (optional)

EnableScalingProps (interface)

class @aws-cdk/aws-dynamodb.EnableScalingProps

Language-specific names:

using Amazon.CDK.AWS.DynamoDB;
import software.amazon.awscdk.services.dynamodb.EnableScalingProps;
// EnableScalingProps is an interface
import { EnableScalingProps } from '@aws-cdk/aws-dynamodb';

Properties for enabling DynamoDB capacity scaling

maxCapacity

Maximum capacity to scale to

Type:number
minCapacity

Minimum capacity to scale to

Type:number

GlobalSecondaryIndexProps (interface)

class @aws-cdk/aws-dynamodb.GlobalSecondaryIndexProps

Language-specific names:

using Amazon.CDK.AWS.DynamoDB;
import software.amazon.awscdk.services.dynamodb.GlobalSecondaryIndexProps;
// GlobalSecondaryIndexProps is an interface
import { GlobalSecondaryIndexProps } from '@aws-cdk/aws-dynamodb';
Extends:SecondaryIndexProps
partitionKey

The attribute of a partition key for the global secondary index.

Type:Attribute
readCapacity

The read capacity for the global secondary index.

Can only be provided if table billingMode is Provisioned or undefined.

Type:number (optional)
Default:5
sortKey

The attribute of a sort key for the global secondary index.

Type:Attribute (optional)
Default:undefined
writeCapacity

The write capacity for the global secondary index.

Can only be provided if table billingMode is Provisioned or undefined.

Type:number (optional)
Default:5
indexName

Inherited from @aws-cdk/aws-dynamodb.SecondaryIndexProps

The name of the secondary index.

Type:string
nonKeyAttributes

Inherited from @aws-cdk/aws-dynamodb.SecondaryIndexProps

The non-key attributes that are projected into the secondary index.

Type:string[] (optional)
Default:undefined
projectionType

Inherited from @aws-cdk/aws-dynamodb.SecondaryIndexProps

The set of attributes that are projected into the secondary index.

Type:ProjectionType (optional)
Default:ALL

IScalableTableAttribute (interface)

class @aws-cdk/aws-dynamodb.IScalableTableAttribute

Language-specific names:

using Amazon.CDK.AWS.DynamoDB;
import software.amazon.awscdk.services.dynamodb.IScalableTableAttribute;
// IScalableTableAttribute is an interface
import { IScalableTableAttribute } from '@aws-cdk/aws-dynamodb';

Interface for scalable attributes

scaleOnSchedule(id, actions)

Add scheduled scaling for this scaling attribute

Parameters:
Abstract:

Yes

scaleOnUtilization(props)

Scale out or in to keep utilization at a given level

Parameters:props (UtilizationScalingProps) –
Abstract:Yes

LocalSecondaryIndexProps (interface)

class @aws-cdk/aws-dynamodb.LocalSecondaryIndexProps

Language-specific names:

using Amazon.CDK.AWS.DynamoDB;
import software.amazon.awscdk.services.dynamodb.LocalSecondaryIndexProps;
// LocalSecondaryIndexProps is an interface
import { LocalSecondaryIndexProps } from '@aws-cdk/aws-dynamodb';
Extends:SecondaryIndexProps
sortKey

The attribute of a sort key for the local secondary index.

Type:Attribute
indexName

Inherited from @aws-cdk/aws-dynamodb.SecondaryIndexProps

The name of the secondary index.

Type:string
nonKeyAttributes

Inherited from @aws-cdk/aws-dynamodb.SecondaryIndexProps

The non-key attributes that are projected into the secondary index.

Type:string[] (optional)
Default:undefined
projectionType

Inherited from @aws-cdk/aws-dynamodb.SecondaryIndexProps

The set of attributes that are projected into the secondary index.

Type:ProjectionType (optional)
Default:ALL

ProjectionType (enum)

class @aws-cdk/aws-dynamodb.ProjectionType

Language-specific names:

using Amazon.CDK.AWS.DynamoDB;
import software.amazon.awscdk.services.dynamodb.ProjectionType;
const { ProjectionType } = require('@aws-cdk/aws-dynamodb');
import { ProjectionType } from '@aws-cdk/aws-dynamodb';
KeysOnly
Include
All

SecondaryIndexProps (interface)

class @aws-cdk/aws-dynamodb.SecondaryIndexProps

Language-specific names:

using Amazon.CDK.AWS.DynamoDB;
import software.amazon.awscdk.services.dynamodb.SecondaryIndexProps;
// SecondaryIndexProps is an interface
import { SecondaryIndexProps } from '@aws-cdk/aws-dynamodb';
indexName

The name of the secondary index.

Type:string
nonKeyAttributes

The non-key attributes that are projected into the secondary index.

Type:string[] (optional)
Default:undefined
projectionType

The set of attributes that are projected into the secondary index.

Type:ProjectionType (optional)
Default:ALL

StreamViewType (enum)

class @aws-cdk/aws-dynamodb.StreamViewType

Language-specific names:

using Amazon.CDK.AWS.DynamoDB;
import software.amazon.awscdk.services.dynamodb.StreamViewType;
const { StreamViewType } = require('@aws-cdk/aws-dynamodb');
import { StreamViewType } from '@aws-cdk/aws-dynamodb';

When an item in the table is modified, StreamViewType determines what information

is written to the stream for this table. Valid values for StreamViewType are:

https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_StreamSpecification.html

NewImage

The entire item, as it appears after it was modified, is written to the stream.

OldImage

The entire item, as it appeared before it was modified, is written to the stream.

NewAndOldImages

Both the new and the old item images of the item are written to the stream.

KeysOnly

Only the key attributes of the modified item are written to the stream.

Table

class @aws-cdk/aws-dynamodb.Table(scope, id, props)

Language-specific names:

using Amazon.CDK.AWS.DynamoDB;
import software.amazon.awscdk.services.dynamodb.Table;
const { Table } = require('@aws-cdk/aws-dynamodb');
import { Table } from '@aws-cdk/aws-dynamodb';

Provides a DynamoDB table.

Extends:

@aws-cdk/cdk.Construct

Parameters:
static grantListStreams([principal])

Permits an IAM Principal to list all DynamoDB Streams.

Parameters:principal (@aws-cdk/aws-iam.IPrincipal (optional)) – The principal (no-op if undefined)
addGlobalSecondaryIndex(props)

Add a global secondary index of table.

Parameters:props (GlobalSecondaryIndexProps) – the property of global secondary index
addLocalSecondaryIndex(props)

Add a local secondary index of table.

Parameters:props (LocalSecondaryIndexProps) – the property of local secondary index
autoScaleGlobalSecondaryIndexReadCapacity(indexName, props) → @aws-cdk/aws-dynamodb.IScalableTableAttribute

Enable read capacity scaling for the given GSI

Parameters:
Returns:

An object to configure additional AutoScaling settings for this attribute

Return type:

IScalableTableAttribute

autoScaleGlobalSecondaryIndexWriteCapacity(indexName, props) → @aws-cdk/aws-dynamodb.IScalableTableAttribute

Enable write capacity scaling for the given GSI

Parameters:
Returns:

An object to configure additional AutoScaling settings for this attribute

Return type:

IScalableTableAttribute

autoScaleReadCapacity(props) → @aws-cdk/aws-dynamodb.IScalableTableAttribute

Enable read capacity scaling for this table

Parameters:props (EnableScalingProps) –
Returns:An object to configure additional AutoScaling settings
Return type:IScalableTableAttribute
autoScaleWriteCapacity(props) → @aws-cdk/aws-dynamodb.IScalableTableAttribute

Enable write capacity scaling for this table

Parameters:props (EnableScalingProps) –
Returns:An object to configure additional AutoScaling settings for this attribute
Return type:IScalableTableAttribute
grant(principal, *actions)

Adds an IAM policy statement associated with this table to an IAM

principal’s policy.

Parameters:
  • principal (@aws-cdk/aws-iam.IPrincipal (optional)) – The principal (no-op if undefined)
  • *actions (string) – The set of actions to allow (i.e. “dynamodb:PutItem”, “dynamodb:GetItem”, …)
grantFullAccess([principal])

Permits all DynamoDB operations (“dynamodb:*”) to an IAM principal.

Parameters:principal (@aws-cdk/aws-iam.IPrincipal (optional)) – The principal to grant access to
grantReadData([principal])

Permits an IAM principal all data read operations from this table:

BatchGetItem, GetRecords, GetShardIterator, Query, GetItem, Scan.

Parameters:principal (@aws-cdk/aws-iam.IPrincipal (optional)) – The principal to grant access to
grantReadWriteData([principal])

Permits an IAM principal to all data read/write operations to this table.

BatchGetItem, GetRecords, GetShardIterator, Query, GetItem, Scan,

BatchWriteItem, PutItem, UpdateItem, DeleteItem

Parameters:principal (@aws-cdk/aws-iam.IPrincipal (optional)) – The principal to grant access to
grantStream(principal, *actions)

Adds an IAM policy statement associated with this table’s stream to an

IAM principal’s policy.

Parameters:
  • principal (@aws-cdk/aws-iam.IPrincipal (optional)) – The principal (no-op if undefined)
  • *actions (string) – The set of actions to allow (i.e. “dynamodb:DescribeStream”, “dynamodb:GetRecords”, …)
grantStreamRead([principal])

Permis an IAM principal all stream data read operations for this

table’s stream:

DescribeStream, GetRecords, GetShardIterator, ListStreams.

Parameters:principal (@aws-cdk/aws-iam.IPrincipal (optional)) – The principal to grant access to
grantWriteData([principal])

Permits an IAM principal all data write operations to this table:

BatchWriteItem, PutItem, UpdateItem, DeleteItem.

Parameters:principal (@aws-cdk/aws-iam.IPrincipal (optional)) – The principal to grant access to
validate() → string[]

Overrides @aws-cdk/cdk.Construct.validate()

Validate the table construct.

Protected method

Returns:an array of validation error message
Return type:string[]
tableArn
Type:string (readonly)
tableName
Type:string (readonly)
tableStreamArn
Type:string (readonly)
prepare()

Inherited from @aws-cdk/cdk.Construct

Perform final modifications before synthesis

This method can be implemented by derived constructs in order to perform

final changes before synthesis. prepare() will be called after child

constructs have been prepared.

This is an advanced framework feature. Only use this if you

understand the implications.

Protected method

toString() → string

Inherited from @aws-cdk/cdk.Construct

Returns a string representation of this construct.

Return type:string
dependencyRoots

Inherited from @aws-cdk/cdk.Construct

The set of constructs that form the root of this dependable

All resources under all returned constructs are included in the ordering

dependency.

Type:@aws-cdk/cdk.IConstruct[] (readonly)
node

Inherited from @aws-cdk/cdk.Construct

Construct node.

Type:@aws-cdk/cdk.ConstructNode (readonly)

TableProps (interface)

class @aws-cdk/aws-dynamodb.TableProps

Language-specific names:

using Amazon.CDK.AWS.DynamoDB;
import software.amazon.awscdk.services.dynamodb.TableProps;
// TableProps is an interface
import { TableProps } from '@aws-cdk/aws-dynamodb';
partitionKey

Partition key attribute definition.

Type:Attribute
billingMode

Specify how you are charged for read and write throughput and how you manage capacity.

Type:BillingMode (optional)
Default:Provisioned
pitrEnabled

Whether point-in-time recovery is enabled.

Type:boolean (optional)
Default:undefined, point-in-time recovery is disabled
readCapacity

The read capacity for the table. Careful if you add Global Secondary Indexes, as

those will share the table’s provisioned throughput.

Can only be provided if billingMode is Provisioned.

Type:number (optional)
Default:5
sortKey

Table sort key attribute definition.

Type:Attribute (optional)
Default:no sort key
sseEnabled

Whether server-side encryption with an AWS managed customer master key is enabled.

Type:boolean (optional)
Default:undefined, server-side encryption is enabled with an AWS owned customer master key
streamSpecification

When an item in the table is modified, StreamViewType determines what information

is written to the stream for this table. Valid values for StreamViewType are:

Type:StreamViewType (optional)
Default:undefined, streams are disabled
tableName

Enforces a particular physical table name.

Type:string (optional)
Default:<generated>
ttlAttributeName

The name of TTL attribute.

Type:string (optional)
Default:undefined, TTL is disabled
writeCapacity

The write capacity for the table. Careful if you add Global Secondary Indexes, as

those will share the table’s provisioned throughput.

Can only be provided if billingMode is Provisioned.

Type:number (optional)
Default:5

UtilizationScalingProps (interface)

class @aws-cdk/aws-dynamodb.UtilizationScalingProps

Language-specific names:

using Amazon.CDK.AWS.DynamoDB;
import software.amazon.awscdk.services.dynamodb.UtilizationScalingProps;
// UtilizationScalingProps is an interface
import { UtilizationScalingProps } from '@aws-cdk/aws-dynamodb';

Properties for enabling DynamoDB utilization tracking

Extends:@aws-cdk/aws-applicationautoscaling.BaseTargetTrackingProps
targetUtilizationPercent

Target utilization percentage for the attribute

Type:number
disableScaleIn

Inherited from @aws-cdk/aws-applicationautoscaling.BaseTargetTrackingProps

Indicates whether scale in by the target tracking policy is disabled.

If the value is true, scale in is disabled and the target tracking policy

won’t remove capacity from the scalable resource. Otherwise, scale in is

enabled and the target tracking policy can remove capacity from the

scalable resource.

Type:boolean (optional)
Default:false
policyName

Inherited from @aws-cdk/aws-applicationautoscaling.BaseTargetTrackingProps

A name for the scaling policy

Type:string (optional)
Default:Automatically generated name
scaleInCooldownSec

Inherited from @aws-cdk/aws-applicationautoscaling.BaseTargetTrackingProps

Period after a scale in activity completes before another scale in activity can start.

Type:number (optional)
Default:No scale in cooldown
scaleOutCooldownSec

Inherited from @aws-cdk/aws-applicationautoscaling.BaseTargetTrackingProps

Period after a scale out activity completes before another scale out activity can start.

Type:number (optional)
Default:No scale out cooldown