Skip to content
v2.273.0

Table L2 construct ​

Provides a DynamoDB table.

Example ​

ts
import * as eventsources from 'aws-cdk-lib/aws-lambda-event-sources';
import * as dynamodb from 'aws-cdk-lib/aws-dynamodb';
import { Key } from 'aws-cdk-lib/aws-kms';

declare const fn: lambda.Function;
const table = new dynamodb.Table(this, 'Table', {
  partitionKey: {
    name: 'id',
    type: dynamodb.AttributeType.STRING,
  },
  stream: dynamodb.StreamViewType.NEW_IMAGE,
});
// Your self managed KMS key
const myKey = Key.fromKeyArn(
  this,
  'SourceBucketEncryptionKey',
  'arn:aws:kms:us-east-1:123456789012:key/<key-id>',
);

fn.addEventSource(new eventsources.DynamoEventSource(table, {
  startingPosition: lambda.StartingPosition.LATEST,
  filters: [lambda.FilterCriteria.filter({ eventName: lambda.FilterRule.isEqual('INSERT') })],
  filterEncryption: myKey,
}));
python
import aws_cdk.aws_lambda_event_sources as eventsources
import aws_cdk.aws_dynamodb as dynamodb
from aws_cdk.aws_kms import Key

# fn: lambda.Function

table = dynamodb.Table(self, "Table",
    partition_key=dynamodb.Attribute(
        name="id",
        type=dynamodb.AttributeType.STRING
    ),
    stream=dynamodb.StreamViewType.NEW_IMAGE
)
# Your self managed KMS key
my_key = Key.from_key_arn(self, "SourceBucketEncryptionKey", "arn:aws:kms:us-east-1:123456789012:key/<key-id>")

fn.add_event_source(eventsources.DynamoEventSource(table,
    starting_position=lambda_.StartingPosition.LATEST,
    filters=[lambda_.FilterCriteria.filter({"event_name": lambda_.FilterRule.is_equal("INSERT")})],
    filter_encryption=my_key
))
java
import software.amazon.awscdk.services.lambda.eventsources.*;
import software.amazon.awscdk.services.dynamodb.*;
import software.amazon.awscdk.services.kms.Key;

Function fn;

Table table = Table.Builder.create(this, "Table")
        .partitionKey(Attribute.builder()
                .name("id")
                .type(AttributeType.STRING)
                .build())
        .stream(StreamViewType.NEW_IMAGE)
        .build();
// Your self managed KMS key
IKey myKey = Key.fromKeyArn(this, "SourceBucketEncryptionKey", "arn:aws:kms:us-east-1:123456789012:key/<key-id>");

fn.addEventSource(DynamoEventSource.Builder.create(table)
        .startingPosition(StartingPosition.LATEST)
        .filters(List.of(FilterCriteria.filter(Map.of("eventName", FilterRule.isEqual("INSERT")))))
        .filterEncryption(myKey)
        .build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.Lambda.EventSources;
using Amazon.CDK.AWS.DynamoDB;
using Amazon.CDK.AWS.KMS;

Function fn;

var table = new Table(this, "Table", new TableProps {
    PartitionKey = new Attribute {
        Name = "id",
        Type = AttributeType.STRING
    },
    Stream = StreamViewType.NEW_IMAGE
});
// Your self managed KMS key
var myKey = Key.FromKeyArn(this, "SourceBucketEncryptionKey", "arn:aws:kms:us-east-1:123456789012:key/<key-id>");

fn.AddEventSource(new DynamoEventSource(table, new DynamoEventSourceProps {
    StartingPosition = StartingPosition.LATEST,
    Filters = new [] { FilterCriteria.Filter(new Dictionary<string, object> { { "eventName", FilterRule.IsEqual("INSERT") } }) },
    FilterEncryption = myKey
}));
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import eventsources "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var fn Function

table := dynamodb.NewTable(this, jsii.String("Table"), &TableProps{
	PartitionKey: &Attribute{
		Name: jsii.String("id"),
		Type: dynamodb.AttributeType_STRING,
	},
	Stream: dynamodb.StreamViewType_NEW_IMAGE,
})
// Your self managed KMS key
myKey := awscdk.Key_FromKeyArn(this, jsii.String("SourceBucketEncryptionKey"), jsii.String("arn:aws:kms:us-east-1:123456789012:key/<key-id>"))

fn.AddEventSource(eventsources.NewDynamoEventSource(table, &DynamoEventSourceProps{
	StartingPosition: lambda.StartingPosition_LATEST,
	Filters: []map[string]interface{}{
		lambda.FilterCriteria_Filter(map[string]interface{}{
			"eventName": lambda.FilterRule_isEqual(jsii.String("INSERT")),
		}),
	},
	FilterEncryption: myKey,
}))

Initializer ​

ts
new Table(scope: Construct, id: string, props: TableProps)
python
Table(scope: Construct, id: str, props: TableProps)
java
new Table(Construct scope, String id, TableProps props)
csharp
new Table(Construct scope, string id, TableProps props)
go
NewTable(Scope Construct, Id *string, Props TableProps)

Construct Props ​

billingModeBillingModebilling_modeBillingModebillingModeBillingModeBillingModeBillingModeBillingModeBillingMode= PROVISIONED if `replicationRegio…#
Specify how you are charged for read and write throughput and how you manage capacity.
default

Default: PROVISIONED if replicationRegions is not specified, PAY_PER_REQUEST otherwise

contributorInsightsEnabledbooleancontributor_insights_enabledboolcontributorInsightsEnabledBooleanContributorInsightsEnabledboolContributorInsightsEnabled*bool= falsedeprecated#
use `contributorInsightsSpecification instead
contributorInsightsSpecificationContributorInsightsSpecificationcontributor_insights_specificationContributorInsightsSpecificationcontributorInsightsSpecificationContributorInsightsSpecificationContributorInsightsSpecificationContributorInsightsSpecificationContributorInsightsSpecificationContributorInsightsSpecification= contributor insights is not enab…#
Whether CloudWatch contributor insights is enabled and what mode is selected.
default

Default: contributor insights is not enabled

deletionProtectionbooleandeletion_protectionbooldeletionProtectionBooleanDeletionProtectionboolDeletionProtection*bool= false#
Enables deletion protection for the table.
encryptionTableEncryptionencryptionTableEncryptionencryptionTableEncryptionEncryptionTableEncryptionEncryptionTableEncryption= The table is encrypted with an e…#
Whether server-side encryption with an AWS managed customer master key is enabled.
notes · default

This property cannot be set if serverSideEncryption is set.

NOTE: if you set this to CUSTOMER_MANAGED and encryptionKey is not specified, the key that the Tablet generates for you will be created with default permissions. If you are using CDKv2, these permissions will be sufficient to enable the key for use with DynamoDB tables. If you are using CDKv1, make sure the feature flag @aws-cdk/aws-kms:defaultKeyPolicies is set to true in your cdk.json.

Default: The table is encrypted with an encryption key managed by DynamoDB, and you are not charged any fee for using it.

encryptionKeyIKeyencryption_keyIKeyencryptionKeyIKeyEncryptionKeyIKeyEncryptionKeyIKey= If `encryption` is set to `Table…#
External KMS key to use for table encryption.

This property can only be set if encryption is set to TableEncryption.CUSTOMER_MANAGED.

default

Default: If encryption is set to TableEncryption.CUSTOMER_MANAGED and this property is undefined, a new KMS key will be created and associated with this table. If encryption and this property are both undefined, then the table is encrypted with an encryption key managed by DynamoDB, and you are not charged any fee for using it.

importSourceImportSourceSpecificationimport_sourceImportSourceSpecificationimportSourceImportSourceSpecificationImportSourceImportSourceSpecificationImportSourceImportSourceSpecification= no data import from the S3 bucke…#
The properties of data being imported from the S3 bucket source to the table.
default

Default: no data import from the S3 bucket

kinesisPrecisionTimestampApproximateCreationDateTimePrecisionkinesis_precision_timestampApproximateCreationDateTimePrecisionkinesisPrecisionTimestampApproximateCreationDateTimePrecisionKinesisPrecisionTimestampApproximateCreationDateTimePrecisionKinesisPrecisionTimestampApproximateCreationDateTimePrecision= ApproximateCreationDateTimePreci…#
Kinesis Data Stream approximate creation timestamp precision.
default

Default: ApproximateCreationDateTimePrecision.MICROSECOND

kinesisStreamIStreamkinesis_streamIStreamkinesisStreamIStreamKinesisStreamIStreamKinesisStreamIStream= no Kinesis Data Stream#
Kinesis Data Stream to capture item-level changes for the table.
maxReadRequestUnitsnumbermax_read_request_unitsint | floatmaxReadRequestUnitsNumberMaxReadRequestUnitsdoubleMaxReadRequestUnits*float64= on-demand throughput is disabled#
The maximum read request units for the table.

Careful if you add Global Secondary Indexes, as those will share the table's maximum on-demand throughput.

Can only be provided if billingMode is PAY_PER_REQUEST.

maxWriteRequestUnitsnumbermax_write_request_unitsint | floatmaxWriteRequestUnitsNumberMaxWriteRequestUnitsdoubleMaxWriteRequestUnits*float64= on-demand throughput is disabled#
The write request units for the table.

Careful if you add Global Secondary Indexes, as those will share the table's maximum on-demand throughput.

Can only be provided if billingMode is PAY_PER_REQUEST.

partitionKeyAttributepartition_keyAttributepartitionKeyAttributePartitionKeyAttributePartitionKeyAttribute= exactly one of `partitionKey` an…#
Partition key attribute definition.

If a single field forms the partition key, you can use this field. Use the partitionKeys field if the partition key is a multi-attribute key (consists of multiple fields).

default

Default: exactly one of partitionKey and partitionKeys must be specified.

pointInTimeRecoverybooleanpoint_in_time_recoveryboolpointInTimeRecoveryBooleanPointInTimeRecoveryboolPointInTimeRecovery*bool= false - point in time recovery i…deprecated#
use `pointInTimeRecoverySpecification` instead
default

Default: false - point in time recovery is not enabled.

pointInTimeRecoverySpecificationPointInTimeRecoverySpecificationpoint_in_time_recovery_specificationPointInTimeRecoverySpecificationpointInTimeRecoverySpecificationPointInTimeRecoverySpecificationPointInTimeRecoverySpecificationPointInTimeRecoverySpecificationPointInTimeRecoverySpecificationPointInTimeRecoverySpecification= point in time recovery is not en…#
Whether point-in-time recovery is enabled and recoveryPeriodInDays is set.
default

Default: point in time recovery is not enabled.

readCapacitynumberread_capacityint | floatreadCapacityNumberReadCapacitydoubleReadCapacity*float64= 5#
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.

removalPolicyRemovalPolicyremoval_policyRemovalPolicyremovalPolicyRemovalPolicyRemovalPolicyRemovalPolicyRemovalPolicyRemovalPolicy= RemovalPolicy.RETAIN#
The removal policy to apply to the DynamoDB Table.
replicaRemovalPolicyRemovalPolicyreplica_removal_policyRemovalPolicyreplicaRemovalPolicyRemovalPolicyReplicaRemovalPolicyRemovalPolicyReplicaRemovalPolicyRemovalPolicy= undefined - use DynamoDB Table's…#
The removal policy to apply to the DynamoDB replica tables.
default

Default: undefined - use DynamoDB Table's removal policy

replicationRegionsstring[]replication_regionstyping.List[str]replicationRegionsList<String>ReplicationRegionsstring[]ReplicationRegions*[]*string= no replica tables are created#
Regions where replica tables will be created.
replicationTimeoutDurationreplication_timeoutDurationreplicationTimeoutDurationReplicationTimeoutDurationReplicationTimeoutDuration= Duration.minutes(30)#
The timeout for a table replication operation in a single region.
resourcePolicyPolicyDocumentresource_policyPolicyDocumentresourcePolicyPolicyDocumentResourcePolicyPolicyDocumentResourcePolicyPolicyDocument= No resource policy statement#
Resource policy to assign to table.
sortKeyAttributesort_keyAttributesortKeyAttributeSortKeyAttributeSortKeyAttribute= no sort key#
Sort key attribute definition.

If a single field forms the sort key, you can use this field. Use the sortKeys field if the sort key is a multi-attribute key (consists of multiple fields).

streamStreamViewTypestreamStreamViewTypestreamStreamViewTypeStreamStreamViewTypeStreamStreamViewType= streams are disabled unless `rep…#
When an item in the table is modified, StreamViewType determines what information is written to the stream for this table.
default

Default: streams are disabled unless replicationRegions is specified

tableClassTableClasstable_classTableClasstableClassTableClassTableClassTableClassTableClassTableClass= STANDARD#
Specify the table class.
tableNamestringtable_namestrtableNameStringTableNamestringTableName*string= <generated>#
Enforces a particular physical table name.
timeToLiveAttributestringtime_to_live_attributestrtimeToLiveAttributeStringTimeToLiveAttributestringTimeToLiveAttribute*string= TTL is disabled#
The name of TTL attribute.
waitForReplicationToFinishbooleanwait_for_replication_to_finishboolwaitForReplicationToFinishBooleanWaitForReplicationToFinishboolWaitForReplicationToFinish*bool= true#
[WARNING: Use this flag with caution, misusing this flag may cause deleting existing replicas, refer to the detailed documentation for more information] Indicates whether CloudFormation stack waits for replication to finish.
notes

If set to false, the CloudFormation resource will mark the resource as created and replication will be completed asynchronously. This property is ignored if replicationRegions property is not set.

WARNING: DO NOT UNSET this property if adding/removing multiple replicationRegions in one deployment, as CloudFormation only supports one region replication at a time. CDK overcomes this limitation by waiting for replication to finish before starting new replicationRegion.

If the custom resource which handles replication has a physical resource ID with the format region instead of tablename-region (this would happen if the custom resource hasn't received an event since v1.91.0), DO NOT SET this property to false without making a change to the table name. This will cause the existing replicas to be deleted.

warmThroughputWarmThroughputwarm_throughputWarmThroughputwarmThroughputWarmThroughputWarmThroughputWarmThroughputWarmThroughputWarmThroughput= warm throughput is not configure…#
Specify values to pre-warm you DynamoDB Table Warm Throughput feature is not available for Global Table replicas using the `Table` construct.

To enable Warm Throughput, use the TableV2 construct instead.

default

Default: warm throughput is not configured

writeCapacitynumberwrite_capacityint | floatwriteCapacityNumberWriteCapacitydoubleWriteCapacity*float64= 5#
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.

Properties ​

encryptionKeyIKeyencryption_keyIKeyencryptionKeyIKeyEncryptionKeyIKeyEncryptionKeyIKey#
KMS encryption key, if this table uses a customer-managed encryption key.
The environment this resource belongs to.
notes

For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.

For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.

grantsTableGrantsgrantsTableGrantsgrantsTableGrantsGrantsTableGrantsGrantsTableGrantsrequired#
Grant a predefined set of permissions on this Table.
nodeNodenodeNodenodeNodeNodeNodeNodeNoderequired#
The tree node.
PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#
Uniquely identifies this class.
regionsstring[]regionstyping.List[str]regionsList<String>Regionsstring[]Regions*[]*string#
Additional regions other than the main one that this table is replicated to.
resourcePolicyPolicyDocumentresource_policyPolicyDocumentresourcePolicyPolicyDocumentResourcePolicyPolicyDocumentResourcePolicyPolicyDocument= No resource policy statements ar…#
Resource policy to assign to DynamoDB Table.
default

Default: No resource policy statements are added to the created table.

stackStackstackStackstackStackStackStackStackStackrequired#
The stack in which this resource is defined.
streamGrantsStreamGrantsstream_grantsStreamGrantsstreamGrantsStreamGrantsStreamGrantsStreamGrantsStreamGrantsStreamGrantsrequired#
Grant a predefined set of permissions on this Table's Stream, if present.

Will throw if the Table has not been configured for streaming.

tableArnstringtable_arnstrtableArnStringTableArnstringTableArn*stringrequired#
Arn of the dynamodb table.
tableNamestringtable_namestrtableNameStringTableNamestringTableName*stringrequired#
Table name of the dynamodb table.
tableRefTableReferencetable_refTableReferencetableRefTableReferenceTableRefTableReferenceTableRefTableReferencerequired#
A reference to a Table resource.
tableStreamArnstringtable_stream_arnstrtableStreamArnStringTableStreamArnstringTableStreamArn*string#
ARN of the table's stream, if there is one.

Methods ​

addGlobalSecondaryIndex(props: GlobalSecondaryIndexProps): voiddef add_global_secondary_index(self, props: GlobalSecondaryIndexProps) -> Nonepublic void addGlobalSecondaryIndex(GlobalSecondaryIndexProps props)public void AddGlobalSecondaryIndex(GlobalSecondaryIndexProps props)func AddGlobalSecondaryIndex(Props GlobalSecondaryIndexProps)#
Add a global secondary index of table.
1 parameter

Parameters

  • propspropspropspropsProps — the property of global secondary index.
addLocalSecondaryIndex(props: LocalSecondaryIndexProps): voiddef add_local_secondary_index(self, props: LocalSecondaryIndexProps) -> Nonepublic void addLocalSecondaryIndex(LocalSecondaryIndexProps props)public void AddLocalSecondaryIndex(LocalSecondaryIndexProps props)func AddLocalSecondaryIndex(Props LocalSecondaryIndexProps)#
Add a local secondary index of table.
1 parameter

Parameters

  • propspropspropspropsProps — the property of local secondary index.
addToResourcePolicy(statement: PolicyStatement): AddToResourcePolicyResultdef add_to_resource_policy(self, statement: PolicyStatement) -> AddToResourcePolicyResultpublic AddToResourcePolicyResult addToResourcePolicy(PolicyStatement statement)public AddToResourcePolicyResult AddToResourcePolicy(PolicyStatement statement)func AddToResourcePolicy(Statement PolicyStatement) AddToResourcePolicyResult#
Adds a statement to the resource policy associated with this table.

A resource policy will be automatically created upon the first call to addToResourcePolicy.

Note that this does not work with imported tables.

1 parameter

Parameters

  • statementstatementstatementstatementStatement — The policy statement to add.
applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#
Override the cross-stack reference strength for this resource.
notes · 1 parameter

When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.

Parameters

  • strengthstrengthstrengthstrengthStrength — - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#
Apply the given removal policy to this resource.
notes

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

autoScaleGlobalSecondaryIndexReadCapacity(indexName: string, props: EnableScalingProps): IScalableTableAttributedef auto_scale_global_secondary_index_read_capacity(self, index_name: str, props: EnableScalingProps) -> IScalableTableAttributepublic IScalableTableAttribute autoScaleGlobalSecondaryIndexReadCapacity(String indexName, EnableScalingProps props)public IScalableTableAttribute AutoScaleGlobalSecondaryIndexReadCapacity(string indexName, EnableScalingProps props)func AutoScaleGlobalSecondaryIndexReadCapacity(IndexName *string, Props EnableScalingProps) IScalableTableAttribute#
Enable read capacity scaling for the given GSI.
returns

Returns: An object to configure additional AutoScaling settings for this attribute

autoScaleGlobalSecondaryIndexWriteCapacity(indexName: string, props: EnableScalingProps): IScalableTableAttributedef auto_scale_global_secondary_index_write_capacity(self, index_name: str, props: EnableScalingProps) -> IScalableTableAttributepublic IScalableTableAttribute autoScaleGlobalSecondaryIndexWriteCapacity(String indexName, EnableScalingProps props)public IScalableTableAttribute AutoScaleGlobalSecondaryIndexWriteCapacity(string indexName, EnableScalingProps props)func AutoScaleGlobalSecondaryIndexWriteCapacity(IndexName *string, Props EnableScalingProps) IScalableTableAttribute#
Enable write capacity scaling for the given GSI.
returns

Returns: An object to configure additional AutoScaling settings for this attribute

autoScaleReadCapacity(props: EnableScalingProps): IScalableTableAttributedef auto_scale_read_capacity(self, props: EnableScalingProps) -> IScalableTableAttributepublic IScalableTableAttribute autoScaleReadCapacity(EnableScalingProps props)public IScalableTableAttribute AutoScaleReadCapacity(EnableScalingProps props)func AutoScaleReadCapacity(Props EnableScalingProps) IScalableTableAttribute#
Enable read capacity scaling for this table.
returns

Returns: An object to configure additional AutoScaling settings

autoScaleWriteCapacity(props: EnableScalingProps): IScalableTableAttributedef auto_scale_write_capacity(self, props: EnableScalingProps) -> IScalableTableAttributepublic IScalableTableAttribute autoScaleWriteCapacity(EnableScalingProps props)public IScalableTableAttribute AutoScaleWriteCapacity(EnableScalingProps props)func AutoScaleWriteCapacity(Props EnableScalingProps) IScalableTableAttribute#
Enable write capacity scaling for this table.
returns

Returns: An object to configure additional AutoScaling settings for this attribute

fromTableArn(scope: Construct, id: string, tableArn: string): ITable@staticmethod def from_table_arn(scope: Construct, id: str, table_arn: str) -> ITablepublic static ITable fromTableArn(Construct scope, String id, String tableArn)public static ITable FromTableArn(Construct scope, string id, string tableArn)func FromTableArn(Scope Construct, Id *string, TableArn *string) ITablestatic#
Creates a Table construct that represents an external table via table arn.
3 parameters

Parameters

  • scopescopescopescopeScope — The parent creating construct (usually this).
  • ididididId — The construct's name.
  • tableArntable_arntableArntableArnTableArn — The table's ARN.
fromTableAttributes(scope: Construct, id: string, attrs: TableAttributes): ITable@staticmethod def from_table_attributes(scope: Construct, id: str, attrs: TableAttributes) -> ITablepublic static ITable fromTableAttributes(Construct scope, String id, TableAttributes attrs)public static ITable FromTableAttributes(Construct scope, string id, TableAttributes attrs)func FromTableAttributes(Scope Construct, Id *string, Attrs TableAttributes) ITablestatic#
Creates a Table construct that represents an external table.
3 parameters

Parameters

  • scopescopescopescopeScope — The parent creating construct (usually this).
  • ididididId — The construct's name.
  • attrsattrsattrsattrsAttrs — A TableAttributes object.
fromTableName(scope: Construct, id: string, tableName: string): ITable@staticmethod def from_table_name(scope: Construct, id: str, table_name: str) -> ITablepublic static ITable fromTableName(Construct scope, String id, String tableName)public static ITable FromTableName(Construct scope, string id, string tableName)func FromTableName(Scope Construct, Id *string, TableName *string) ITablestatic#
Creates a Table construct that represents an external table via table name.
3 parameters

Parameters

  • scopescopescopescopeScope — The parent creating construct (usually this).
  • ididididId — The construct's name.
  • tableNametable_nametableNametableNameTableName — The table's name.
grant(grantee: IGrantable, ...actions: string[]): Grantdef grant(self, grantee: IGrantable, actions: str) -> Grantpublic Grant grant(IGrantable grantee, String actions)public Grant Grant(IGrantable grantee, string actions)func Grant(Grantee IGrantable, Actions *string) Grant#
Adds an IAM policy statement associated with this table to an IAM principal's policy.

If encryptionKey is present, appropriate grants to the key needs to be added separately using the table.encryptionKey.grant* methods. [disable-awslint:no-grants]

2 parameters

Parameters

  • granteegranteegranteegranteeGrantee — The principal (no-op if undefined).
  • actionsactionsactionsactionsActions — The set of actions to allow (i.e. "dynamodb:PutItem", "dynamodb:GetItem", ...).
grantFullAccess(grantee: IGrantable): Grantdef grant_full_access(self, grantee: IGrantable) -> Grantpublic Grant grantFullAccess(IGrantable grantee)public Grant GrantFullAccess(IGrantable grantee)func GrantFullAccess(Grantee IGrantable) Grant#
Permits all DynamoDB operations ("dynamodb:*") to an IAM principal.

Appropriate grants will also be added to the customer-managed KMS key if one was configured.

The use of this method is discouraged. Please use grants.fullAccess() instead.

[disable-awslint:no-grants]

1 parameter

Parameters

  • granteegranteegranteegranteeGrantee — The principal to grant access to.
grantOnKey(grantee: IGrantable, ...actions: string[]): GrantOnKeyResultdef grant_on_key(self, grantee: IGrantable, actions: str) -> GrantOnKeyResultpublic GrantOnKeyResult grantOnKey(IGrantable grantee, String actions)public GrantOnKeyResult GrantOnKey(IGrantable grantee, string actions)func GrantOnKey(Grantee IGrantable, Actions *string) GrantOnKeyResult#
Gives permissions to a grantable entity to perform actions on the encryption key.
grantReadData(grantee: IGrantable): Grantdef grant_read_data(self, grantee: IGrantable) -> Grantpublic Grant grantReadData(IGrantable grantee)public Grant GrantReadData(IGrantable grantee)func GrantReadData(Grantee IGrantable) Grant#
Permits an IAM principal all data read operations from this table: BatchGetItem, GetRecords, GetShardIterator, Query, GetItem, Scan, DescribeTable.

Appropriate grants will also be added to the customer-managed KMS key if one was configured.

The use of this method is discouraged. Please use grants.readData() instead.

[disable-awslint:no-grants]

1 parameter

Parameters

  • granteegranteegranteegranteeGrantee — The principal to grant access to.
grantReadWriteData(grantee: IGrantable): Grantdef grant_read_write_data(self, grantee: IGrantable) -> Grantpublic Grant grantReadWriteData(IGrantable grantee)public Grant GrantReadWriteData(IGrantable grantee)func GrantReadWriteData(Grantee IGrantable) Grant#
Permits an IAM principal to all data read/write operations to this table.
notes · 1 parameter

BatchGetItem, GetRecords, GetShardIterator, Query, GetItem, Scan, BatchWriteItem, PutItem, UpdateItem, DeleteItem, DescribeTable

Appropriate grants will also be added to the customer-managed KMS key if one was configured.

The use of this method is discouraged. Please use grants.readWriteData() instead.

[disable-awslint:no-grants]

Parameters

  • granteegranteegranteegranteeGrantee — The principal to grant access to.
grantStream(grantee: IGrantable, ...actions: string[]): Grantdef grant_stream(self, grantee: IGrantable, actions: str) -> Grantpublic Grant grantStream(IGrantable grantee, String actions)public Grant GrantStream(IGrantable grantee, string actions)func GrantStream(Grantee IGrantable, Actions *string) Grant#
Adds an IAM policy statement associated with this table's stream to an IAM principal's policy.
notes · 2 parameters

If encryptionKey is present, appropriate grants to the key needs to be added separately using the table.encryptionKey.grant* methods.

The use of this method is discouraged. Please use streamGrants.stream() instead.

[disable-awslint:no-grants]

Parameters

  • granteegranteegranteegranteeGrantee — The principal (no-op if undefined).
  • actionsactionsactionsactionsActions — The set of actions to allow (i.e. "dynamodb:DescribeStream", "dynamodb:GetRecords", ...).
grantStreamRead(grantee: IGrantable): Grantdef grant_stream_read(self, grantee: IGrantable) -> Grantpublic Grant grantStreamRead(IGrantable grantee)public Grant GrantStreamRead(IGrantable grantee)func GrantStreamRead(Grantee IGrantable) Grant#
Permits an IAM principal all stream data read operations for this table's stream: DescribeStream, GetRecords, GetShardIterator, ListStreams.

Appropriate grants will also be added to the customer-managed KMS key if one was configured.

The use of this method is discouraged. Please use streamGrants.streamRead() instead.

[disable-awslint:no-grants]

1 parameter

Parameters

  • granteegranteegranteegranteeGrantee — The principal to grant access to.
grantTableListStreams(grantee: IGrantable): Grantdef grant_table_list_streams(self, grantee: IGrantable) -> Grantpublic Grant grantTableListStreams(IGrantable grantee)public Grant GrantTableListStreams(IGrantable grantee)func GrantTableListStreams(Grantee IGrantable) Grant#
Permits an IAM Principal to list streams attached to current dynamodb table.

The use of this method is discouraged. Please use streamGrants.tableListStreams() instead.

[disable-awslint:no-grants]

1 parameter

Parameters

  • granteegranteegranteegranteeGrantee — The principal (no-op if undefined).
grantWriteData(grantee: IGrantable): Grantdef grant_write_data(self, grantee: IGrantable) -> Grantpublic Grant grantWriteData(IGrantable grantee)public Grant GrantWriteData(IGrantable grantee)func GrantWriteData(Grantee IGrantable) Grant#
Permits an IAM principal all data write operations to this table: BatchWriteItem, PutItem, UpdateItem, DeleteItem, DescribeTable.

Appropriate grants will also be added to the customer-managed KMS key if one was configured.

The use of this method is discouraged. Please use grants.writeData() instead.

[disable-awslint:no-grants]

1 parameter

Parameters

  • granteegranteegranteegranteeGrantee — The principal to grant access to.
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.

isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#
Returns true if the construct was created by CDK, and false otherwise.
isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#
Check whether the given construct is a Resource.
metric(metricName: string, props?: MetricOptions): Metricdef metric(self, metric_name: str, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metric(String metricName, MetricOptions props)public Metric Metric(string metricName, MetricOptions? props = null)func Metric(MetricName *string, Props MetricOptions) Metric#
Return the given named metric for this Table.

By default, the metric will be calculated as a sum over a period of 5 minutes. You can customize this by using the statistic and period properties.

metricConditionalCheckFailedRequests(props?: MetricOptions): Metricdef metric_conditional_check_failed_requests(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricConditionalCheckFailedRequests(MetricOptions props)public Metric MetricConditionalCheckFailedRequests(MetricOptions? props = null)func MetricConditionalCheckFailedRequests(Props MetricOptions) Metric#
Metric for the conditional check failed requests this table.

By default, the metric will be calculated as a sum over a period of 5 minutes. You can customize this by using the statistic and period properties.

metricConsumedReadCapacityUnits(props?: MetricOptions): Metricdef metric_consumed_read_capacity_units(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricConsumedReadCapacityUnits(MetricOptions props)public Metric MetricConsumedReadCapacityUnits(MetricOptions? props = null)func MetricConsumedReadCapacityUnits(Props MetricOptions) Metric#
Metric for the consumed read capacity units this table.

By default, the metric will be calculated as a sum over a period of 5 minutes. You can customize this by using the statistic and period properties.

metricConsumedWriteCapacityUnits(props?: MetricOptions): Metricdef metric_consumed_write_capacity_units(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricConsumedWriteCapacityUnits(MetricOptions props)public Metric MetricConsumedWriteCapacityUnits(MetricOptions? props = null)func MetricConsumedWriteCapacityUnits(Props MetricOptions) Metric#
Metric for the consumed write capacity units this table.

By default, the metric will be calculated as a sum over a period of 5 minutes. You can customize this by using the statistic and period properties.

metricSuccessfulRequestLatency(props?: MetricOptions): Metricdef metric_successful_request_latency(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricSuccessfulRequestLatency(MetricOptions props)public Metric MetricSuccessfulRequestLatency(MetricOptions? props = null)func MetricSuccessfulRequestLatency(Props MetricOptions) Metric#
Metric for the successful request latency this table.

By default, the metric will be calculated as an average over a period of 5 minutes. You can customize this by using the statistic and period properties.

metricSystemErrors(props?: MetricOptions): Metricdef metric_system_errors(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricSystemErrors(MetricOptions props)public Metric MetricSystemErrors(MetricOptions? props = null)func MetricSystemErrors(Props MetricOptions) Metricdeprecated#
use `metricSystemErrorsForOperations`.
metricSystemErrorsForOperations(props?: SystemErrorsForOperationsMetricOptions): IMetricdef metric_system_errors_for_operations(self, props: typing.Optional[SystemErrorsForOperationsMetricOptions] = None) -> IMetricpublic IMetric metricSystemErrorsForOperations(SystemErrorsForOperationsMetricOptions props)public IMetric MetricSystemErrorsForOperations(SystemErrorsForOperationsMetricOptions? props = null)func MetricSystemErrorsForOperations(Props SystemErrorsForOperationsMetricOptions) IMetric#
Metric for the system errors this table.

This will sum errors across all possible operations. Note that by default, each individual metric will be calculated as a sum over a period of 5 minutes. You can customize this by using the statistic and period properties.

metricThrottledRequests(props?: MetricOptions): Metricdef metric_throttled_requests(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricThrottledRequests(MetricOptions props)public Metric MetricThrottledRequests(MetricOptions? props = null)func MetricThrottledRequests(Props MetricOptions) Metricdeprecated#
Do not use this function. It returns an invalid metric. Use `metricThrottledRequestsForOperation` instead.

Default: sum over 5 minutes

metricThrottledRequestsForOperation(operation: string, props?: MetricOptions): Metricdef metric_throttled_requests_for_operation(self, operation: str, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricThrottledRequestsForOperation(String operation, MetricOptions props)public Metric MetricThrottledRequestsForOperation(string operation, MetricOptions? props = null)func MetricThrottledRequestsForOperation(Operation *string, Props MetricOptions) Metric#
How many requests are throttled on this table, for the given operation.

Default: sum over 5 minutes

metricThrottledRequestsForOperations(props?: OperationsMetricOptions): IMetricdef metric_throttled_requests_for_operations(self, props: typing.Optional[OperationsMetricOptions] = None) -> IMetricpublic IMetric metricThrottledRequestsForOperations(OperationsMetricOptions props)public IMetric MetricThrottledRequestsForOperations(OperationsMetricOptions? props = null)func MetricThrottledRequestsForOperations(Props OperationsMetricOptions) IMetric#
How many requests are throttled on this table.

This will sum errors across all possible operations. Note that by default, each individual metric will be calculated as a sum over a period of 5 minutes. You can customize this by using the statistic and period properties.

metricUserErrors(props?: MetricOptions): Metricdef metric_user_errors(self, props: typing.Optional[MetricOptions] = None) -> Metricpublic Metric metricUserErrors(MetricOptions props)public Metric MetricUserErrors(MetricOptions? props = null)func MetricUserErrors(Props MetricOptions) Metric#
Metric for the user errors.
notes

Note that this metric reports user errors across all the tables in the account and region the table resides in.

By default, the metric will be calculated as a sum over a period of 5 minutes. You can customize this by using the statistic and period properties.

schema(indexName?: string): SchemaOptionsdef schema(self, index_name: typing.Optional[str] = None) -> SchemaOptionspublic SchemaOptions schema(String indexName)public SchemaOptions Schema(string? indexName = null)func Schema(IndexName *string) SchemaOptionsdeprecated#
- use `schemaV2()` instead
returns

Returns: Schema of table or index.

schemaV2(indexName?: string): KeySchemadef schema_v2(self, index_name: typing.Optional[str] = None) -> KeySchemapublic KeySchema schemaV2(String indexName)public KeySchema SchemaV2(string? indexName = null)func SchemaV2(IndexName *string) KeySchema#
Get schema attributes of table or index.
returns

Returns: Schema of table or index.

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.