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

@Generated(value="jsii-pacmak/1.92.0 (build db7f27d)", date="2023-12-06T04:49:37.157Z") @Stability(Stable) public class Table extends TableBase
Provides a DynamoDB table.

Example:

 import software.amazon.awscdk.services.dynamodb.*;
 // create a table
 Table table = Table.Builder.create(this, "montable")
         .partitionKey(Attribute.builder()
                 .name("id")
                 .type(AttributeType.STRING)
                 .build())
         .build();
 Pass finalStatus = new Pass(this, "final step");
 // States language JSON to put an item into DynamoDB
 // snippet generated from https://docs.aws.amazon.com/step-functions/latest/dg/tutorial-code-snippet.html#tutorial-code-snippet-1
 Map<String, Object> stateJson = Map.of(
         "Type", "Task",
         "Resource", "arn:aws:states:::dynamodb:putItem",
         "Parameters", Map.of(
                 "TableName", table.getTableName(),
                 "Item", Map.of(
                         "id", Map.of(
                                 "S", "MyEntry"))),
         "ResultPath", null);
 // custom state which represents a task to insert data into DynamoDB
 CustomState custom = CustomState.Builder.create(this, "my custom task")
         .stateJson(stateJson)
         .build();
 Chain chain = Chain.start(custom).next(finalStatus);
 StateMachine sm = StateMachine.Builder.create(this, "StateMachine")
         .definitionBody(DefinitionBody.fromChainable(chain))
         .timeout(Duration.seconds(30))
         .comment("a super cool state machine")
         .build();
 // don't forget permissions. You need to assign them
 table.grantWriteData(sm);
 
  • Constructor Details

    • Table

      protected Table(software.amazon.jsii.JsiiObjectRef objRef)
    • Table

      protected Table(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • Table

      @Stability(Stable) public Table(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull TableProps props)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      props - This parameter is required.
  • Method Details

    • fromTableArn

      @Stability(Stable) @NotNull public static ITable fromTableArn(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String tableArn)
      Creates a Table construct that represents an external table via table arn.

      Parameters:
      scope - The parent creating construct (usually this). This parameter is required.
      id - The construct's name. This parameter is required.
      tableArn - The table's ARN. This parameter is required.
    • fromTableAttributes

      @Stability(Stable) @NotNull public static ITable fromTableAttributes(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull TableAttributes attrs)
      Creates a Table construct that represents an external table.

      Parameters:
      scope - The parent creating construct (usually this). This parameter is required.
      id - The construct's name. This parameter is required.
      attrs - A TableAttributes object. This parameter is required.
    • fromTableName

      @Stability(Stable) @NotNull public static ITable fromTableName(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String tableName)
      Creates a Table construct that represents an external table via table name.

      Parameters:
      scope - The parent creating construct (usually this). This parameter is required.
      id - The construct's name. This parameter is required.
      tableName - The table's name. This parameter is required.
    • addGlobalSecondaryIndex

      @Stability(Stable) public void addGlobalSecondaryIndex(@NotNull GlobalSecondaryIndexProps props)
      Add a global secondary index of table.

      Parameters:
      props - the property of global secondary index. This parameter is required.
    • addLocalSecondaryIndex

      @Stability(Stable) public void addLocalSecondaryIndex(@NotNull LocalSecondaryIndexProps props)
      Add a local secondary index of table.

      Parameters:
      props - the property of local secondary index. This parameter is required.
    • autoScaleGlobalSecondaryIndexReadCapacity

      @Stability(Stable) @NotNull public IScalableTableAttribute autoScaleGlobalSecondaryIndexReadCapacity(@NotNull String indexName, @NotNull EnableScalingProps props)
      Enable read capacity scaling for the given GSI.

      Parameters:
      indexName - This parameter is required.
      props - This parameter is required.
      Returns:
      An object to configure additional AutoScaling settings for this attribute
    • autoScaleGlobalSecondaryIndexWriteCapacity

      @Stability(Stable) @NotNull public IScalableTableAttribute autoScaleGlobalSecondaryIndexWriteCapacity(@NotNull String indexName, @NotNull EnableScalingProps props)
      Enable write capacity scaling for the given GSI.

      Parameters:
      indexName - This parameter is required.
      props - This parameter is required.
      Returns:
      An object to configure additional AutoScaling settings for this attribute
    • autoScaleReadCapacity

      @Stability(Stable) @NotNull public IScalableTableAttribute autoScaleReadCapacity(@NotNull EnableScalingProps props)
      Enable read capacity scaling for this table.

      Parameters:
      props - This parameter is required.
      Returns:
      An object to configure additional AutoScaling settings
    • autoScaleWriteCapacity

      @Stability(Stable) @NotNull public IScalableTableAttribute autoScaleWriteCapacity(@NotNull EnableScalingProps props)
      Enable write capacity scaling for this table.

      Parameters:
      props - This parameter is required.
      Returns:
      An object to configure additional AutoScaling settings for this attribute
    • schema

      @Stability(Stable) @NotNull public SchemaOptions schema(@Nullable String indexName)
      Get schema attributes of table or index.

      Parameters:
      indexName -
      Returns:
      Schema of table or index.
    • schema

      @Stability(Stable) @NotNull public SchemaOptions schema()
      Get schema attributes of table or index.

      Returns:
      Schema of table or index.
    • getHasIndex

      @Stability(Stable) @NotNull protected Boolean getHasIndex()
      Whether this table has indexes.
      Specified by:
      getHasIndex in class TableBase
    • getTableArn

      @Stability(Stable) @NotNull public String getTableArn()
      Arn of the dynamodb table.
      Specified by:
      getTableArn in interface ITable
      Specified by:
      getTableArn in class TableBase
    • getTableName

      @Stability(Stable) @NotNull public String getTableName()
      Table name of the dynamodb table.
      Specified by:
      getTableName in interface ITable
      Specified by:
      getTableName in class TableBase
    • getEncryptionKey

      @Stability(Stable) @Nullable public IKey getEncryptionKey()
      KMS encryption key, if this table uses a customer-managed encryption key.
      Specified by:
      getEncryptionKey in interface ITable
      Specified by:
      getEncryptionKey in class TableBase
    • getTableStreamArn

      @Stability(Stable) @Nullable public String getTableStreamArn()
      ARN of the table's stream, if there is one.
      Specified by:
      getTableStreamArn in interface ITable
      Specified by:
      getTableStreamArn in class TableBase