java.lang.Object
software.amazon.jsii.JsiiObject
All Implemented Interfaces:
IConstruct, IDependable, IInspectable, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:30:42.236Z") @Stability(Stable) public class CfnTable extends CfnResource implements IInspectable
A CloudFormation AWS::DynamoDB::Table.

The 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 here 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.*;
 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)
                 .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)
                         .build())
                 .provisionedThroughput(ProvisionedThroughputProperty.builder()
                         .readCapacityUnits(123)
                         .writeCapacityUnits(123)
                         .build())
                 .build()))
         .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")
                 .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()))
         .pointInTimeRecoverySpecification(PointInTimeRecoverySpecificationProperty.builder()
                 .pointInTimeRecoveryEnabled(false)
                 .build())
         .provisionedThroughput(ProvisionedThroughputProperty.builder()
                 .readCapacityUnits(123)
                 .writeCapacityUnits(123)
                 .build())
         .sseSpecification(SSESpecificationProperty.builder()
                 .sseEnabled(false)
                 // the properties below are optional
                 .kmsMasterKeyId("kmsMasterKeyId")
                 .sseType("sseType")
                 .build())
         .streamSpecification(StreamSpecificationProperty.builder()
                 .streamViewType("streamViewType")
                 .build())
         .tableClass("tableClass")
         .tableName("tableName")
         .tags(List.of(CfnTag.builder()
                 .key("key")
                 .value("value")
                 .build()))
         .timeToLiveSpecification(TimeToLiveSpecificationProperty.builder()
                 .attributeName("attributeName")
                 .enabled(false)
                 .build())
         .build();
 
  • Field Details

    • CFN_RESOURCE_TYPE_NAME

      @Stability(Stable) public static final String 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 Construct scope, @NotNull String id, @NotNull CfnTableProps props)
      Create a new AWS::DynamoDB::Table.

      Parameters:
      scope -
      • scope in which this resource is defined.
      This parameter is required.
      id -
      • scoped id of the resource.
      This parameter is required.
      props -
      • resource properties.
      This parameter is required.
  • Method Details

    • inspect

      @Stability(Stable) public void inspect(@NotNull TreeInspector inspector)
      Examines the CloudFormation resource and discloses attributes.

      Specified by:
      inspect in interface IInspectable
      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:
      renderProperties in class CfnResource
      Parameters:
      props - This parameter is required.
    • getAttrArn

      @Stability(Stable) @NotNull public String getAttrArn()
      The Amazon Resource Name (ARN) of the DynamoDB table, such as arn:aws:dynamodb:us-east-2:123456789012:table/myDynamoDBTable .
    • getAttrStreamArn

      @Stability(Stable) @NotNull public String getAttrStreamArn()
      The ARN of the DynamoDB stream, such as arn:aws:dynamodb:us-east-1:123456789012:table/testddbstack-myDynamoDBTable-012A1SL7SMP5Q/stream/2015-11-30T20:10:00.000 .

      You must specify the StreamSpecification property to use this attribute.

    • getCfnProperties

      @Stability(Stable) @NotNull protected Map<String,Object> getCfnProperties()
      Overrides:
      getCfnProperties in class CfnResource
    • getTags

      @Stability(Stable) @NotNull public TagManager getTags()
      An array of key-value pairs to apply to this resource.

      For more information, see Tag .

    • getKeySchema

      @Stability(Stable) @NotNull public Object getKeySchema()
      Specifies the attributes that make up the primary key for the table.

      The attributes in the KeySchema property must also be defined in the AttributeDefinitions property.

    • setKeySchema

      @Stability(Stable) public void setKeySchema(@NotNull IResolvable value)
      Specifies the attributes that make up the primary key for the table.

      The attributes in the KeySchema property must also be defined in the AttributeDefinitions property.

    • setKeySchema

      @Stability(Stable) public void setKeySchema(@NotNull List<Object> value)
      Specifies the attributes that make up the primary key for the table.

      The attributes in the KeySchema property must also be defined in the AttributeDefinitions property.

    • getAttributeDefinitions

      @Stability(Stable) @Nullable public Object getAttributeDefinitions()
      A list of attributes that describe the key schema for the table and indexes.

      This property is required to create a DynamoDB table.

      Update requires: Some interruptions . Replacement if you edit an existing AttributeDefinition.

    • setAttributeDefinitions

      @Stability(Stable) public void setAttributeDefinitions(@Nullable IResolvable value)
      A list of attributes that describe the key schema for the table and indexes.

      This property is required to create a DynamoDB table.

      Update requires: Some interruptions . Replacement if you edit an existing AttributeDefinition.

    • setAttributeDefinitions

      @Stability(Stable) public void setAttributeDefinitions(@Nullable List<Object> value)
      A list of attributes that describe the key schema for the table and indexes.

      This property is required to create a DynamoDB table.

      Update requires: Some interruptions . Replacement if you edit an existing AttributeDefinition.

    • getBillingMode

      @Stability(Stable) @Nullable public String getBillingMode()
      Specify how you are charged for read and write throughput and how you manage capacity.

      Valid values include:

      • PROVISIONED - We recommend using PROVISIONED for predictable workloads. PROVISIONED sets the billing mode to Provisioned Mode .
      • PAY_PER_REQUEST - We recommend using PAY_PER_REQUEST for unpredictable workloads. PAY_PER_REQUEST sets the billing mode to On-Demand Mode .

      If not specified, the default is PROVISIONED .

    • setBillingMode

      @Stability(Stable) public void setBillingMode(@Nullable String value)
      Specify how you are charged for read and write throughput and how you manage capacity.

      Valid values include:

      • PROVISIONED - We recommend using PROVISIONED for predictable workloads. PROVISIONED sets the billing mode to Provisioned Mode .
      • PAY_PER_REQUEST - We recommend using PAY_PER_REQUEST for unpredictable workloads. PAY_PER_REQUEST sets the billing mode to On-Demand Mode .

      If not specified, the default is PROVISIONED .

    • getContributorInsightsSpecification

      @Stability(Stable) @Nullable public Object getContributorInsightsSpecification()
      The settings used to enable or disable CloudWatch Contributor Insights for the specified table.
    • setContributorInsightsSpecification

      @Stability(Stable) public void setContributorInsightsSpecification(@Nullable IResolvable value)
      The settings used to enable or disable CloudWatch Contributor Insights for the specified table.
    • setContributorInsightsSpecification

      @Stability(Stable) public void setContributorInsightsSpecification(@Nullable CfnTable.ContributorInsightsSpecificationProperty value)
      The settings used to enable or disable CloudWatch Contributor Insights for the specified table.
    • getDeletionProtectionEnabled

      @Stability(Stable) @Nullable public Object getDeletionProtectionEnabled()
      Determines if a table is protected from deletion.

      When enabled, the table cannot be deleted by any user or process. This setting is disabled by default. For more information, see Using deletion protection in the Amazon DynamoDB Developer Guide .

    • setDeletionProtectionEnabled

      @Stability(Stable) public void setDeletionProtectionEnabled(@Nullable Boolean value)
      Determines if a table is protected from deletion.

      When enabled, the table cannot be deleted by any user or process. This setting is disabled by default. For more information, see Using deletion protection in the Amazon DynamoDB Developer Guide .

    • setDeletionProtectionEnabled

      @Stability(Stable) public void setDeletionProtectionEnabled(@Nullable IResolvable value)
      Determines if a table is protected from deletion.

      When enabled, the table cannot be deleted by any user or process. This setting is disabled by default. For more information, see Using deletion protection in the Amazon DynamoDB Developer Guide .

    • getGlobalSecondaryIndexes

      @Stability(Stable) @Nullable public Object getGlobalSecondaryIndexes()
      Global secondary indexes to be created on the table. You can create up to 20 global secondary indexes.

      If you update a table to include a new global secondary index, AWS CloudFormation initiates the index creation and then proceeds with the stack update. AWS CloudFormation doesn't wait for the index to complete creation because the backfilling phase can take a long time, depending on the size of the table. You can't use the index or update the table until the index's status is ACTIVE . You can track its status by using the DynamoDB DescribeTable command.

      If you add or delete an index during an update, we recommend that you don't update any other resources. If your stack fails to update and is rolled back while adding a new index, you must manually delete the index.

      Updates are not supported. The following are exceptions:

      • If you update either the contributor insights specification or the provisioned throughput values of global secondary indexes, you can update the table without interruption.
      • You can delete or add one global secondary index without interruption. If you do both in the same update (for example, by changing the index's logical ID), the update fails.

    • setGlobalSecondaryIndexes

      @Stability(Stable) public void setGlobalSecondaryIndexes(@Nullable IResolvable value)
      Global secondary indexes to be created on the table. You can create up to 20 global secondary indexes.

      If you update a table to include a new global secondary index, AWS CloudFormation initiates the index creation and then proceeds with the stack update. AWS CloudFormation doesn't wait for the index to complete creation because the backfilling phase can take a long time, depending on the size of the table. You can't use the index or update the table until the index's status is ACTIVE . You can track its status by using the DynamoDB DescribeTable command.

      If you add or delete an index during an update, we recommend that you don't update any other resources. If your stack fails to update and is rolled back while adding a new index, you must manually delete the index.

      Updates are not supported. The following are exceptions:

      • If you update either the contributor insights specification or the provisioned throughput values of global secondary indexes, you can update the table without interruption.
      • You can delete or add one global secondary index without interruption. If you do both in the same update (for example, by changing the index's logical ID), the update fails.

    • setGlobalSecondaryIndexes

      @Stability(Stable) public void setGlobalSecondaryIndexes(@Nullable List<Object> value)
      Global secondary indexes to be created on the table. You can create up to 20 global secondary indexes.

      If you update a table to include a new global secondary index, AWS CloudFormation initiates the index creation and then proceeds with the stack update. AWS CloudFormation doesn't wait for the index to complete creation because the backfilling phase can take a long time, depending on the size of the table. You can't use the index or update the table until the index's status is ACTIVE . You can track its status by using the DynamoDB DescribeTable command.

      If you add or delete an index during an update, we recommend that you don't update any other resources. If your stack fails to update and is rolled back while adding a new index, you must manually delete the index.

      Updates are not supported. The following are exceptions:

      • If you update either the contributor insights specification or the provisioned throughput values of global secondary indexes, you can update the table without interruption.
      • You can delete or add one global secondary index without interruption. If you do both in the same update (for example, by changing the index's logical ID), the update fails.

    • getImportSourceSpecification

      @Stability(Stable) @Nullable public Object getImportSourceSpecification()
      Specifies the properties of data being imported from the S3 bucket source to the table.

      If you specify the ImportSourceSpecification property, and also specify either the StreamSpecification , the TableClass property, or the DeletionProtectionEnabled property, the IAM entity creating/updating stack must have UpdateTable permission.

    • setImportSourceSpecification

      @Stability(Stable) public void setImportSourceSpecification(@Nullable IResolvable value)
      Specifies the properties of data being imported from the S3 bucket source to the table.

      If you specify the ImportSourceSpecification property, and also specify either the StreamSpecification , the TableClass property, or the DeletionProtectionEnabled property, the IAM entity creating/updating stack must have UpdateTable permission.

    • 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.

      If you specify the ImportSourceSpecification property, and also specify either the StreamSpecification , the TableClass property, or the DeletionProtectionEnabled property, the IAM entity creating/updating stack must have UpdateTable permission.

    • getKinesisStreamSpecification

      @Stability(Stable) @Nullable public Object getKinesisStreamSpecification()
      The Kinesis Data Streams configuration for the specified table.
    • setKinesisStreamSpecification

      @Stability(Stable) public void setKinesisStreamSpecification(@Nullable IResolvable value)
      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

      @Stability(Stable) @Nullable public Object getLocalSecondaryIndexes()
      Local secondary indexes to be created on the table.

      You can create up to 5 local secondary indexes. Each index is scoped to a given hash key value. The size of each hash key can be up to 10 gigabytes.

    • setLocalSecondaryIndexes

      @Stability(Stable) public void setLocalSecondaryIndexes(@Nullable IResolvable value)
      Local secondary indexes to be created on the table.

      You can create up to 5 local secondary indexes. Each index is scoped to a given hash key value. The size of each hash key can be up to 10 gigabytes.

    • setLocalSecondaryIndexes

      @Stability(Stable) public void setLocalSecondaryIndexes(@Nullable List<Object> value)
      Local secondary indexes to be created on the table.

      You can create up to 5 local secondary indexes. Each index is scoped to a given hash key value. The size of each hash key can be up to 10 gigabytes.

    • getPointInTimeRecoverySpecification

      @Stability(Stable) @Nullable public Object getPointInTimeRecoverySpecification()
      The settings used to enable point in time recovery.
    • setPointInTimeRecoverySpecification

      @Stability(Stable) public void setPointInTimeRecoverySpecification(@Nullable IResolvable value)
      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

      @Stability(Stable) @Nullable public Object getProvisionedThroughput()
      Throughput for the specified table, which consists of values for ReadCapacityUnits and WriteCapacityUnits .

      For more information about the contents of a provisioned throughput structure, see Amazon DynamoDB Table ProvisionedThroughput .

      If you set BillingMode as PROVISIONED , you must specify this property. If you set BillingMode as PAY_PER_REQUEST , you cannot specify this property.

    • setProvisionedThroughput

      @Stability(Stable) public void setProvisionedThroughput(@Nullable IResolvable value)
      Throughput for the specified table, which consists of values for ReadCapacityUnits and WriteCapacityUnits .

      For more information about the contents of a provisioned throughput structure, see Amazon DynamoDB Table ProvisionedThroughput .

      If you set BillingMode as PROVISIONED , you must specify this property. If you set BillingMode as PAY_PER_REQUEST , you cannot specify this property.

    • setProvisionedThroughput

      @Stability(Stable) public void setProvisionedThroughput(@Nullable CfnTable.ProvisionedThroughputProperty value)
      Throughput for the specified table, which consists of values for ReadCapacityUnits and WriteCapacityUnits .

      For more information about the contents of a provisioned throughput structure, see Amazon DynamoDB Table ProvisionedThroughput .

      If you set BillingMode as PROVISIONED , you must specify this property. If you set BillingMode as PAY_PER_REQUEST , you cannot specify this property.

    • getSseSpecification

      @Stability(Stable) @Nullable public Object getSseSpecification()
      Specifies the settings to enable server-side encryption.
    • setSseSpecification

      @Stability(Stable) public void setSseSpecification(@Nullable IResolvable value)
      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

      @Stability(Stable) @Nullable public Object getStreamSpecification()
      The settings for the DynamoDB table stream, which capture changes to items stored in the table.
    • setStreamSpecification

      @Stability(Stable) public void setStreamSpecification(@Nullable IResolvable value)
      The settings for the DynamoDB table stream, which capture 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 capture changes to items stored in the table.
    • getTableClass

      @Stability(Stable) @Nullable public String getTableClass()
      The table class of the new table.

      Valid values are STANDARD and STANDARD_INFREQUENT_ACCESS .

    • setTableClass

      @Stability(Stable) public void setTableClass(@Nullable String value)
      The table class of the new table.

      Valid values are STANDARD and STANDARD_INFREQUENT_ACCESS .

    • getTableName

      @Stability(Stable) @Nullable public String getTableName()
      A name for the table.

      If you don't specify a name, AWS CloudFormation generates a unique physical ID and uses that ID for the table name. For more information, see Name Type .

      If you specify a name, you cannot perform updates that require replacement of this resource. You can perform updates that require no or some interruption. If you must replace the resource, specify a new name.

    • setTableName

      @Stability(Stable) public void setTableName(@Nullable String value)
      A name for the table.

      If you don't specify a name, AWS CloudFormation generates a unique physical ID and uses that ID for the table name. For more information, see Name Type .

      If you specify a name, you cannot perform updates that require replacement of this resource. You can perform updates that require no or some interruption. If you must replace the resource, specify a new name.

    • getTimeToLiveSpecification

      @Stability(Stable) @Nullable public Object getTimeToLiveSpecification()
      Specifies the Time to Live (TTL) settings for the table.

      For detailed information about the limits in DynamoDB, see Limits in Amazon DynamoDB in the Amazon DynamoDB Developer Guide.

    • setTimeToLiveSpecification

      @Stability(Stable) public void setTimeToLiveSpecification(@Nullable IResolvable value)
      Specifies the Time to Live (TTL) settings for the table.

      For detailed information about the limits in DynamoDB, see Limits in Amazon DynamoDB in the Amazon DynamoDB Developer Guide.

    • setTimeToLiveSpecification

      @Stability(Stable) public void setTimeToLiveSpecification(@Nullable CfnTable.TimeToLiveSpecificationProperty value)
      Specifies the Time to Live (TTL) settings for the table.

      For detailed information about the limits in DynamoDB, see Limits in Amazon DynamoDB in the Amazon DynamoDB Developer Guide.