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

@Generated(value="jsii-pacmak/1.103.1 (build bef2dea)", date="2024-10-25T14:21:13.494Z") @Stability(Stable) public class TableV2 extends TableBaseV2
A DynamoDB Table.

Example:

 import software.amazon.awscdk.*;
 App app = new App();
 Stack stack = Stack.Builder.create(app, "Stack").env(Environment.builder().region("us-west-2").build()).build();
 TableV2 globalTable = TableV2.Builder.create(stack, "GlobalTable")
         .partitionKey(Attribute.builder().name("pk").type(AttributeType.STRING).build())
         // applys to all replicas, i.e., us-west-2, us-east-1, us-east-2
         .removalPolicy(RemovalPolicy.DESTROY)
         .replicas(List.of(ReplicaTableProps.builder().region("us-east-1").build(), ReplicaTableProps.builder().region("us-east-2").build()))
         .build();
 
  • Constructor Details

    • TableV2

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

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

      @Stability(Stable) public TableV2(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull TablePropsV2 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 ITableV2 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 ITableV2 fromTableAttributes(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull TableAttributesV2 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 - attributes of the table. This parameter is required.
    • fromTableName

      @Stability(Stable) @NotNull public static ITableV2 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 GlobalSecondaryIndexPropsV2 props)
      Add a global secondary index to the table.

      Note: Global secondary indexes will be inherited by all replica tables.

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

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

      Note: Local secondary indexes will be inherited by all replica tables.

      Parameters:
      props - the properties of the local secondary index. This parameter is required.
    • addReplica

      @Stability(Stable) public void addReplica(@NotNull ReplicaTableProps props)
      Add a replica table.

      Note: Adding a replica table will allow you to use your table as a global table.

      Parameters:
      props - the properties of the replica table to add. This parameter is required.
    • replica

      @Stability(Stable) @NotNull public ITableV2 replica(@NotNull String region)
      Retrieve a replica table.

      Note: Replica tables are not supported in a region agnostic stack.

      Parameters:
      region - the region of the replica table. This parameter is required.
    • getHasIndex

      @Stability(Stable) @NotNull protected Boolean getHasIndex()
      Specified by:
      getHasIndex in class TableBaseV2
    • getRegion

      @Stability(Stable) @NotNull protected String getRegion()
      Specified by:
      getRegion in class TableBaseV2
    • getTableArn

      @Stability(Stable) @NotNull public String getTableArn()
      The ARN of the table.
      Specified by:
      getTableArn in interface ITable
      Specified by:
      getTableArn in class TableBaseV2
    • getTableName

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

      @Stability(Stable) @Nullable public IKey getEncryptionKey()
      The KMS encryption key for the table.
      Specified by:
      getEncryptionKey in interface ITable
      Specified by:
      getEncryptionKey in class TableBaseV2
    • getTableId

      @Stability(Stable) @Nullable public String getTableId()
      The ID of the table.
      Specified by:
      getTableId in interface ITableV2
      Specified by:
      getTableId in class TableBaseV2
    • getTableStreamArn

      @Stability(Stable) @Nullable public String getTableStreamArn()
      The stream ARN of the table.
      Specified by:
      getTableStreamArn in interface ITable
      Specified by:
      getTableStreamArn in class TableBaseV2
    • getResourcePolicy

      @Stability(Stable) @Nullable public PolicyDocument getResourcePolicy()
      The resource policy for the table.
      Specified by:
      getResourcePolicy in class TableBaseV2
    • setResourcePolicy

      @Stability(Stable) public void setResourcePolicy(@Nullable PolicyDocument value)
      The resource policy for the table.
      Specified by:
      setResourcePolicy in class TableBaseV2