Class CfnTable
- All Implemented Interfaces:
IInspectable,ITaggable,ITableRef,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct,software.constructs.IDependable
AWS::DynamoDB::Table resource creates a DynamoDB table. For more information, see CreateTable in the Amazon DynamoDB API Reference .
You should be aware of the following behaviors when working with DynamoDB tables:
- AWS CloudFormation typically creates DynamoDB tables in parallel. However, if your template includes multiple DynamoDB tables with indexes, you must declare dependencies so that the tables are created sequentially. Amazon DynamoDB limits the number of tables with secondary indexes that are in the creating state. If you create multiple tables with indexes at the same time, DynamoDB returns an error and the stack operation fails. For an example, see DynamoDB Table with a DependsOn Attribute .
Our guidance is to use the latest schema documented for your AWS CloudFormation templates. This schema supports the provisioning of all table settings below. When using this schema in your AWS CloudFormation templates, please ensure that your Identity and Access Management ( IAM ) policies are updated with appropriate permissions to allow for the authorization of these setting changes.
Example:
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.dynamodb.*;
Object policyDocument;
CfnTable cfnTable = CfnTable.Builder.create(this, "MyCfnTable")
.keySchema(List.of(KeySchemaProperty.builder()
.attributeName("attributeName")
.keyType("keyType")
.build()))
// the properties below are optional
.attributeDefinitions(List.of(AttributeDefinitionProperty.builder()
.attributeName("attributeName")
.attributeType("attributeType")
.build()))
.billingMode("billingMode")
.contributorInsightsSpecification(ContributorInsightsSpecificationProperty.builder()
.enabled(false)
// the properties below are optional
.mode("mode")
.build())
.deletionProtectionEnabled(false)
.globalSecondaryIndexes(List.of(GlobalSecondaryIndexProperty.builder()
.indexName("indexName")
.keySchema(List.of(KeySchemaProperty.builder()
.attributeName("attributeName")
.keyType("keyType")
.build()))
.projection(ProjectionProperty.builder()
.nonKeyAttributes(List.of("nonKeyAttributes"))
.projectionType("projectionType")
.build())
// the properties below are optional
.contributorInsightsSpecification(ContributorInsightsSpecificationProperty.builder()
.enabled(false)
// the properties below are optional
.mode("mode")
.build())
.onDemandThroughput(OnDemandThroughputProperty.builder()
.maxReadRequestUnits(123)
.maxWriteRequestUnits(123)
.build())
.provisionedThroughput(ProvisionedThroughputProperty.builder()
.readCapacityUnits(123)
.writeCapacityUnits(123)
.build())
.warmThroughput(WarmThroughputProperty.builder()
.readUnitsPerSecond(123)
.writeUnitsPerSecond(123)
.build())
.build()))
.globalTableSettingsReplicationMode("globalTableSettingsReplicationMode")
.importSourceSpecification(ImportSourceSpecificationProperty.builder()
.inputFormat("inputFormat")
.s3BucketSource(S3BucketSourceProperty.builder()
.s3Bucket("s3Bucket")
// the properties below are optional
.s3BucketOwner("s3BucketOwner")
.s3KeyPrefix("s3KeyPrefix")
.build())
// the properties below are optional
.inputCompressionType("inputCompressionType")
.inputFormatOptions(InputFormatOptionsProperty.builder()
.csv(CsvProperty.builder()
.delimiter("delimiter")
.headerList(List.of("headerList"))
.build())
.build())
.build())
.kinesisStreamSpecification(KinesisStreamSpecificationProperty.builder()
.streamArn("streamArn")
// the properties below are optional
.approximateCreationDateTimePrecision("approximateCreationDateTimePrecision")
.build())
.localSecondaryIndexes(List.of(LocalSecondaryIndexProperty.builder()
.indexName("indexName")
.keySchema(List.of(KeySchemaProperty.builder()
.attributeName("attributeName")
.keyType("keyType")
.build()))
.projection(ProjectionProperty.builder()
.nonKeyAttributes(List.of("nonKeyAttributes"))
.projectionType("projectionType")
.build())
.build()))
.onDemandThroughput(OnDemandThroughputProperty.builder()
.maxReadRequestUnits(123)
.maxWriteRequestUnits(123)
.build())
.pointInTimeRecoverySpecification(PointInTimeRecoverySpecificationProperty.builder()
.pointInTimeRecoveryEnabled(false)
.recoveryPeriodInDays(123)
.build())
.provisionedThroughput(ProvisionedThroughputProperty.builder()
.readCapacityUnits(123)
.writeCapacityUnits(123)
.build())
.resourcePolicy(ResourcePolicyProperty.builder()
.policyDocument(policyDocument)
.build())
.sseSpecification(SSESpecificationProperty.builder()
.sseEnabled(false)
// the properties below are optional
.kmsMasterKeyId("kmsMasterKeyId")
.sseType("sseType")
.build())
.streamSpecification(StreamSpecificationProperty.builder()
.streamViewType("streamViewType")
// the properties below are optional
.resourcePolicy(ResourcePolicyProperty.builder()
.policyDocument(policyDocument)
.build())
.build())
.tableClass("tableClass")
.tableName("tableName")
.tags(List.of(CfnTag.builder()
.key("key")
.value("value")
.build()))
.timeToLiveSpecification(TimeToLiveSpecificationProperty.builder()
.enabled(false)
// the properties below are optional
.attributeName("attributeName")
.build())
.warmThroughput(WarmThroughputProperty.builder()
.readUnitsPerSecond(123)
.writeUnitsPerSecond(123)
.build())
.build();
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceRepresents an attribute for describing the schema for the table and indexes.static final classA fluent builder forCfnTable.static interfaceConfigures contributor insights settings for a table or one of its indexes.static interfaceThe options for imported source files in CSV format.static interfaceRepresents the properties of a global secondary index.static interfaceSpecifies the properties of data being imported from the S3 bucket source to the table.static interfaceThe format options for the data that was imported into the target table.static interfaceRepresents a single element of a key schema.static interfaceThe Kinesis Data Streams configuration for the specified table.static interfaceRepresents the properties of a local secondary index.static interfaceSets the maximum number of read and write units for the specified on-demand table.static interfaceThe settings used to enable point in time recovery.static interfaceRepresents attributes that are copied (projected) from the table into an index.static interfaceThroughput for the specified table, which consists of values forReadCapacityUnitsandWriteCapacityUnits.static interfaceCreates or updates a resource-based policy document that contains the permissions for DynamoDB resources, such as a table, its indexes, and stream.static interfaceThe S3 bucket that is being imported from.static interfaceRepresents the settings used to enable server-side encryption.static interfaceRepresents the DynamoDB Streams configuration for a table in DynamoDB.static interfaceRepresents the settings used to enable or disable Time to Live (TTL) for the specified table.static interfaceProvides visibility into the number of read and write operations your table or secondary index can instantaneously support.Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.IInspectable
IInspectable.Jsii$Default, IInspectable.Jsii$ProxyNested classes/interfaces inherited from interface software.amazon.awscdk.services.dynamodb.ITableRef
ITableRef.Jsii$Default, ITableRef.Jsii$ProxyNested classes/interfaces inherited from interface software.amazon.awscdk.ITaggable
ITaggable.Jsii$Default, ITaggable.Jsii$Proxy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe CloudFormation resource type name for this resource class. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCfnTable(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedCfnTable(software.amazon.jsii.JsiiObjectRef objRef) CfnTable(software.constructs.Construct scope, String id, CfnTableProps props) -
Method Summary
Modifier and TypeMethodDescriptionstatic ITableReffromTableArn(software.constructs.Construct scope, String id, String arn) Creates a new ITableRef from an ARN.static ITableReffromTableName(software.constructs.Construct scope, String id, String tableName) Creates a new ITableRef from a tableName.The Amazon Resource Name (ARN) of the DynamoDB table, such asarn:aws:dynamodb:us-east-2:123456789012:table/myDynamoDBTable.A list of attributes that describe the key schema for the table and indexes.The ARN of the DynamoDB stream, such asarn:aws:dynamodb:us-east-1:123456789012:table/testddbstack-myDynamoDBTable-012A1SL7SMP5Q/stream/2015-11-30T20:10:00.000.Specify how you are charged for read and write throughput and how you manage capacity.The settings used to specify whether to enable CloudWatch Contributor Insights for the table and define which events to monitor.Determines if a table is protected from deletion.Global secondary indexes to be created on the table.Specifies the properties of data being imported from the S3 bucket source to the" table.Specifies the attributes that make up the primary key for the table.The Kinesis Data Streams configuration for the specified table.Local secondary indexes to be created on the table.Sets the maximum number of read and write units for the specified on-demand table.The settings used to enable point in time recovery.Throughput for the specified table, which consists of values forReadCapacityUnitsandWriteCapacityUnits.An AWS resource-based policy document in JSON format that will be attached to the table.Specifies the settings to enable server-side encryption.The settings for the DynamoDB table stream, which captures changes to items stored in the table.The table class of the new table.A name for the table.A reference to a Table resource.getTags()Tag Manager which manages the tags for this resource.An array of key-value pairs to apply to this resource.Specifies the Time to Live (TTL) settings for the table.Represents the warm throughput (in read units per second and write units per second) for creating a table.voidinspect(TreeInspector inspector) Examines the CloudFormation resource and discloses attributes.renderProperties(Map<String, Object> props) voidsetAttributeDefinitions(List<Object> value) A list of attributes that describe the key schema for the table and indexes.voidA list of attributes that describe the key schema for the table and indexes.voidsetBillingMode(String value) Specify how you are charged for read and write throughput and how you manage capacity.voidThe settings used to specify whether to enable CloudWatch Contributor Insights for the table and define which events to monitor.voidThe settings used to specify whether to enable CloudWatch Contributor Insights for the table and define which events to monitor.voidDetermines if a table is protected from deletion.voidDetermines if a table is protected from deletion.voidsetGlobalSecondaryIndexes(List<Object> value) Global secondary indexes to be created on the table.voidGlobal secondary indexes to be created on the table.voidvoidSpecifies the properties of data being imported from the S3 bucket source to the" table.voidSpecifies the properties of data being imported from the S3 bucket source to the" table.voidsetKeySchema(List<Object> value) Specifies the attributes that make up the primary key for the table.voidsetKeySchema(IResolvable value) Specifies the attributes that make up the primary key for the table.voidThe Kinesis Data Streams configuration for the specified table.voidThe Kinesis Data Streams configuration for the specified table.voidsetLocalSecondaryIndexes(List<Object> value) Local secondary indexes to be created on the table.voidLocal secondary indexes to be created on the table.voidsetOnDemandThroughput(IResolvable value) Sets the maximum number of read and write units for the specified on-demand table.voidSets the maximum number of read and write units for the specified on-demand table.voidThe settings used to enable point in time recovery.voidThe settings used to enable point in time recovery.voidThroughput for the specified table, which consists of values forReadCapacityUnitsandWriteCapacityUnits.voidThroughput for the specified table, which consists of values forReadCapacityUnitsandWriteCapacityUnits.voidsetResourcePolicy(IResolvable value) An AWS resource-based policy document in JSON format that will be attached to the table.voidAn AWS resource-based policy document in JSON format that will be attached to the table.voidsetSseSpecification(IResolvable value) Specifies the settings to enable server-side encryption.voidSpecifies the settings to enable server-side encryption.voidThe settings for the DynamoDB table stream, which captures changes to items stored in the table.voidThe settings for the DynamoDB table stream, which captures changes to items stored in the table.voidsetTableClass(String value) The table class of the new table.voidsetTableName(String value) A name for the table.voidsetTagsRaw(List<CfnTag> value) An array of key-value pairs to apply to this resource.voidSpecifies the Time to Live (TTL) settings for the table.voidSpecifies the Time to Live (TTL) settings for the table.voidsetWarmThroughput(IResolvable value) Represents the warm throughput (in read units per second and write units per second) for creating a table.voidRepresents the warm throughput (in read units per second and write units per second) for creating a table.Methods inherited from class software.amazon.awscdk.CfnResource
addDeletionOverride, addDependency, addDependsOn, addMetadata, addOverride, addPropertyDeletionOverride, addPropertyOverride, applyRemovalPolicy, applyRemovalPolicy, applyRemovalPolicy, getAtt, getAtt, getCfnOptions, getCfnResourceType, getMetadata, getUpdatedProperites, getUpdatedProperties, isCfnResource, obtainDependencies, obtainResourceDependencies, removeDependency, replaceDependency, shouldSynthesize, toString, validatePropertiesMethods inherited from class software.amazon.awscdk.CfnRefElement
getRefMethods inherited from class software.amazon.awscdk.CfnElement
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalIdMethods inherited from class software.constructs.Construct
getNode, isConstructMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.constructs.IConstruct
getNodeMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Field Details
-
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
-
-
Constructor Details
-
CfnTable
protected CfnTable(software.amazon.jsii.JsiiObjectRef objRef) -
CfnTable
protected CfnTable(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
CfnTable
@Stability(Stable) public CfnTable(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull CfnTableProps props) - Parameters:
scope- Scope in which this resource is defined. This parameter is required.id- Construct identifier for this resource (unique in its scope). This parameter is required.props- Resource properties. This parameter is required.
-
-
Method Details
-
fromTableArn
@Stability(Stable) @NotNull public static ITableRef fromTableArn(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String arn) Creates a new ITableRef from an ARN.- Parameters:
scope- This parameter is required.id- This parameter is required.arn- This parameter is required.
-
fromTableName
@Stability(Stable) @NotNull public static ITableRef fromTableName(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String tableName) Creates a new ITableRef from a tableName.- Parameters:
scope- This parameter is required.id- This parameter is required.tableName- This parameter is required.
-
inspect
Examines the CloudFormation resource and discloses attributes.- Specified by:
inspectin interfaceIInspectable- Parameters:
inspector- tree inspector to collect and process attributes. This parameter is required.
-
renderProperties
@Stability(Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String, Object> props) - Overrides:
renderPropertiesin classCfnResource- Parameters:
props- This parameter is required.
-
getAttrArn
The Amazon Resource Name (ARN) of the DynamoDB table, such asarn:aws:dynamodb:us-east-2:123456789012:table/myDynamoDBTable. -
getAttrStreamArn
The ARN of the DynamoDB stream, such asarn:aws:dynamodb:us-east-1:123456789012:table/testddbstack-myDynamoDBTable-012A1SL7SMP5Q/stream/2015-11-30T20:10:00.000.You must specify the
StreamSpecificationproperty to use this attribute. -
getCfnProperties
- Overrides:
getCfnPropertiesin classCfnResource
-
getTableRef
A reference to a Table resource.- Specified by:
getTableRefin interfaceITableRef
-
getTags
Tag Manager which manages the tags for this resource. -
getKeySchema
Specifies the attributes that make up the primary key for the table.Returns union: either
IResolvableor Listinvalid input: '<'eitherIResolvableorCfnTable.KeySchemaProperty> -
setKeySchema
Specifies the attributes that make up the primary key for the table. -
setKeySchema
Specifies the attributes that make up the primary key for the table. -
getAttributeDefinitions
A list of attributes that describe the key schema for the table and indexes.Returns union: either
IResolvableor Listinvalid input: '<'eitherIResolvableorCfnTable.AttributeDefinitionProperty> -
setAttributeDefinitions
A list of attributes that describe the key schema for the table and indexes. -
setAttributeDefinitions
A list of attributes that describe the key schema for the table and indexes. -
getBillingMode
Specify how you are charged for read and write throughput and how you manage capacity. -
setBillingMode
Specify how you are charged for read and write throughput and how you manage capacity. -
getContributorInsightsSpecification
The settings used to specify whether to enable CloudWatch Contributor Insights for the table and define which events to monitor.Returns union: either
IResolvableorCfnTable.ContributorInsightsSpecificationProperty -
setContributorInsightsSpecification
The settings used to specify whether to enable CloudWatch Contributor Insights for the table and define which events to monitor. -
setContributorInsightsSpecification
@Stability(Stable) public void setContributorInsightsSpecification(@Nullable CfnTable.ContributorInsightsSpecificationProperty value) The settings used to specify whether to enable CloudWatch Contributor Insights for the table and define which events to monitor. -
getDeletionProtectionEnabled
Determines if a table is protected from deletion.Returns union: either
BooleanorIResolvable -
setDeletionProtectionEnabled
Determines if a table is protected from deletion. -
setDeletionProtectionEnabled
Determines if a table is protected from deletion. -
getGlobalSecondaryIndexes
Global secondary indexes to be created on the table.You can create up to 20 global secondary indexes.
Returns union: either
IResolvableor Listinvalid input: '<'eitherIResolvableorCfnTable.GlobalSecondaryIndexProperty> -
setGlobalSecondaryIndexes
Global secondary indexes to be created on the table.You can create up to 20 global secondary indexes.
-
setGlobalSecondaryIndexes
Global secondary indexes to be created on the table.You can create up to 20 global secondary indexes.
-
getGlobalTableSettingsReplicationMode
-
setGlobalTableSettingsReplicationMode
-
getImportSourceSpecification
Specifies the properties of data being imported from the S3 bucket source to the" table.Returns union: either
IResolvableorCfnTable.ImportSourceSpecificationProperty -
setImportSourceSpecification
Specifies the properties of data being imported from the S3 bucket source to the" table. -
setImportSourceSpecification
@Stability(Stable) public void setImportSourceSpecification(@Nullable CfnTable.ImportSourceSpecificationProperty value) Specifies the properties of data being imported from the S3 bucket source to the" table. -
getKinesisStreamSpecification
The Kinesis Data Streams configuration for the specified table.Returns union: either
IResolvableorCfnTable.KinesisStreamSpecificationProperty -
setKinesisStreamSpecification
The Kinesis Data Streams configuration for the specified table. -
setKinesisStreamSpecification
@Stability(Stable) public void setKinesisStreamSpecification(@Nullable CfnTable.KinesisStreamSpecificationProperty value) The Kinesis Data Streams configuration for the specified table. -
getLocalSecondaryIndexes
Local secondary indexes to be created on the table.Returns union: either
IResolvableor Listinvalid input: '<'eitherIResolvableorCfnTable.LocalSecondaryIndexProperty> -
setLocalSecondaryIndexes
Local secondary indexes to be created on the table. -
setLocalSecondaryIndexes
Local secondary indexes to be created on the table. -
getOnDemandThroughput
Sets the maximum number of read and write units for the specified on-demand table.Returns union: either
IResolvableorCfnTable.OnDemandThroughputProperty -
setOnDemandThroughput
Sets the maximum number of read and write units for the specified on-demand table. -
setOnDemandThroughput
@Stability(Stable) public void setOnDemandThroughput(@Nullable CfnTable.OnDemandThroughputProperty value) Sets the maximum number of read and write units for the specified on-demand table. -
getPointInTimeRecoverySpecification
The settings used to enable point in time recovery.Returns union: either
IResolvableorCfnTable.PointInTimeRecoverySpecificationProperty -
setPointInTimeRecoverySpecification
The settings used to enable point in time recovery. -
setPointInTimeRecoverySpecification
@Stability(Stable) public void setPointInTimeRecoverySpecification(@Nullable CfnTable.PointInTimeRecoverySpecificationProperty value) The settings used to enable point in time recovery. -
getProvisionedThroughput
Throughput for the specified table, which consists of values forReadCapacityUnitsandWriteCapacityUnits.Returns union: either
IResolvableorCfnTable.ProvisionedThroughputProperty -
setProvisionedThroughput
Throughput for the specified table, which consists of values forReadCapacityUnitsandWriteCapacityUnits. -
setProvisionedThroughput
@Stability(Stable) public void setProvisionedThroughput(@Nullable CfnTable.ProvisionedThroughputProperty value) Throughput for the specified table, which consists of values forReadCapacityUnitsandWriteCapacityUnits. -
getResourcePolicy
An AWS resource-based policy document in JSON format that will be attached to the table.Returns union: either
IResolvableorCfnTable.ResourcePolicyProperty -
setResourcePolicy
An AWS resource-based policy document in JSON format that will be attached to the table. -
setResourcePolicy
An AWS resource-based policy document in JSON format that will be attached to the table. -
getSseSpecification
Specifies the settings to enable server-side encryption.Returns union: either
IResolvableorCfnTable.SSESpecificationProperty -
setSseSpecification
Specifies the settings to enable server-side encryption. -
setSseSpecification
@Stability(Stable) public void setSseSpecification(@Nullable CfnTable.SSESpecificationProperty value) Specifies the settings to enable server-side encryption. -
getStreamSpecification
The settings for the DynamoDB table stream, which captures changes to items stored in the table.Returns union: either
IResolvableorCfnTable.StreamSpecificationProperty -
setStreamSpecification
The settings for the DynamoDB table stream, which captures changes to items stored in the table. -
setStreamSpecification
@Stability(Stable) public void setStreamSpecification(@Nullable CfnTable.StreamSpecificationProperty value) The settings for the DynamoDB table stream, which captures changes to items stored in the table. -
getTableClass
The table class of the new table. -
setTableClass
The table class of the new table. -
getTableName
A name for the table. -
setTableName
A name for the table. -
getTagsRaw
An array of key-value pairs to apply to this resource. -
setTagsRaw
An array of key-value pairs to apply to this resource. -
getTimeToLiveSpecification
Specifies the Time to Live (TTL) settings for the table.Returns union: either
IResolvableorCfnTable.TimeToLiveSpecificationProperty -
setTimeToLiveSpecification
Specifies the Time to Live (TTL) settings for the table. -
setTimeToLiveSpecification
@Stability(Stable) public void setTimeToLiveSpecification(@Nullable CfnTable.TimeToLiveSpecificationProperty value) Specifies the Time to Live (TTL) settings for the table. -
getWarmThroughput
Represents the warm throughput (in read units per second and write units per second) for creating a table.Returns union: either
IResolvableorCfnTable.WarmThroughputProperty -
setWarmThroughput
Represents the warm throughput (in read units per second and write units per second) for creating a table. -
setWarmThroughput
Represents the warm throughput (in read units per second and write units per second) for creating a table.
-