java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.core.Construct
software.amazon.awscdk.core.Resource
software.amazon.awscdk.services.dynamodb.Table
All Implemented Interfaces:
IConstruct, IDependable, IResource, ITable, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:30:42.291Z") @Stability(Stable) public class Table extends Resource implements ITable
Provides a DynamoDB table.

Example:

 Table globalTable = Table.Builder.create(this, "Table")
         .partitionKey(Attribute.builder().name("id").type(AttributeType.STRING).build())
         .replicationRegions(List.of("us-east-1", "us-east-2", "us-west-2"))
         .billingMode(BillingMode.PROVISIONED)
         .build();
 globalTable.autoScaleWriteCapacity(EnableScalingProps.builder()
         .minCapacity(1)
         .maxCapacity(10)
         .build()).scaleOnUtilization(UtilizationScalingProps.builder().targetUtilizationPercent(75).build());
 
  • 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.
    • grantListStreams

      @Stability(Deprecated) @Deprecated @NotNull public static Grant grantListStreams(@NotNull IGrantable grantee)
      Deprecated.
      (deprecated) Permits an IAM Principal to list all DynamoDB Streams.

      Parameters:
      grantee - The principal (no-op if undefined). 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
    • grant

      @Stability(Stable) @NotNull public Grant grant(@NotNull IGrantable grantee, @NotNull @NotNull String... actions)
      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.

      Specified by:
      grant in interface ITable
      Parameters:
      grantee - The principal (no-op if undefined). This parameter is required.
      actions - The set of actions to allow (i.e. "dynamodb:PutItem", "dynamodb:GetItem", ...). This parameter is required.
    • grantFullAccess

      @Stability(Stable) @NotNull public Grant grantFullAccess(@NotNull IGrantable grantee)
      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.

      Specified by:
      grantFullAccess in interface ITable
      Parameters:
      grantee - The principal to grant access to. This parameter is required.
    • grantReadData

      @Stability(Stable) @NotNull public Grant grantReadData(@NotNull IGrantable grantee)
      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.

      Specified by:
      grantReadData in interface ITable
      Parameters:
      grantee - The principal to grant access to. This parameter is required.
    • grantReadWriteData

      @Stability(Stable) @NotNull public Grant grantReadWriteData(@NotNull IGrantable grantee)
      Permits an IAM principal to all data read/write operations to this table.

      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.

      Specified by:
      grantReadWriteData in interface ITable
      Parameters:
      grantee - The principal to grant access to. This parameter is required.
    • grantStream

      @Stability(Stable) @NotNull public Grant grantStream(@NotNull IGrantable grantee, @NotNull @NotNull String... actions)
      Adds an IAM policy statement associated with this table's stream 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.

      Specified by:
      grantStream in interface ITable
      Parameters:
      grantee - The principal (no-op if undefined). This parameter is required.
      actions - The set of actions to allow (i.e. "dynamodb:DescribeStream", "dynamodb:GetRecords", ...). This parameter is required.
    • grantStreamRead

      @Stability(Stable) @NotNull public Grant grantStreamRead(@NotNull IGrantable grantee)
      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.

      Specified by:
      grantStreamRead in interface ITable
      Parameters:
      grantee - The principal to grant access to. This parameter is required.
    • grantTableListStreams

      @Stability(Stable) @NotNull public Grant grantTableListStreams(@NotNull IGrantable grantee)
      Permits an IAM Principal to list streams attached to current dynamodb table.

      Specified by:
      grantTableListStreams in interface ITable
      Parameters:
      grantee - The principal (no-op if undefined). This parameter is required.
    • grantWriteData

      @Stability(Stable) @NotNull public Grant grantWriteData(@NotNull IGrantable grantee)
      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.

      Specified by:
      grantWriteData in interface ITable
      Parameters:
      grantee - The principal to grant access to. This parameter is required.
    • metric

      @Stability(Stable) @NotNull public Metric metric(@NotNull String metricName, @Nullable MetricOptions props)
      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.

      Specified by:
      metric in interface ITable
      Parameters:
      metricName - This parameter is required.
      props -
    • metric

      @Stability(Stable) @NotNull public Metric metric(@NotNull String metricName)
      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.

      Specified by:
      metric in interface ITable
      Parameters:
      metricName - This parameter is required.
    • metricConditionalCheckFailedRequests

      @Stability(Stable) @NotNull public Metric metricConditionalCheckFailedRequests(@Nullable MetricOptions props)
      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.

      Specified by:
      metricConditionalCheckFailedRequests in interface ITable
      Parameters:
      props -
    • metricConditionalCheckFailedRequests

      @Stability(Stable) @NotNull public Metric metricConditionalCheckFailedRequests()
      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.

      Specified by:
      metricConditionalCheckFailedRequests in interface ITable
    • metricConsumedReadCapacityUnits

      @Stability(Stable) @NotNull public Metric metricConsumedReadCapacityUnits(@Nullable MetricOptions props)
      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.

      Specified by:
      metricConsumedReadCapacityUnits in interface ITable
      Parameters:
      props -
    • metricConsumedReadCapacityUnits

      @Stability(Stable) @NotNull public Metric metricConsumedReadCapacityUnits()
      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.

      Specified by:
      metricConsumedReadCapacityUnits in interface ITable
    • metricConsumedWriteCapacityUnits

      @Stability(Stable) @NotNull public Metric metricConsumedWriteCapacityUnits(@Nullable MetricOptions props)
      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.

      Specified by:
      metricConsumedWriteCapacityUnits in interface ITable
      Parameters:
      props -
    • metricConsumedWriteCapacityUnits

      @Stability(Stable) @NotNull public Metric metricConsumedWriteCapacityUnits()
      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.

      Specified by:
      metricConsumedWriteCapacityUnits in interface ITable
    • metricSuccessfulRequestLatency

      @Stability(Stable) @NotNull public Metric metricSuccessfulRequestLatency(@Nullable MetricOptions props)
      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.

      Specified by:
      metricSuccessfulRequestLatency in interface ITable
      Parameters:
      props -
    • metricSuccessfulRequestLatency

      @Stability(Stable) @NotNull public Metric metricSuccessfulRequestLatency()
      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.

      Specified by:
      metricSuccessfulRequestLatency in interface ITable
    • metricSystemErrors

      @Stability(Deprecated) @Deprecated @NotNull public Metric metricSystemErrors(@Nullable MetricOptions props)
      Deprecated.
      use metricSystemErrorsForOperations.
      (deprecated) Metric for the system errors this table.

      Specified by:
      metricSystemErrors in interface ITable
      Parameters:
      props -
    • metricSystemErrors

      @Stability(Deprecated) @Deprecated @NotNull public Metric metricSystemErrors()
      Deprecated.
      use metricSystemErrorsForOperations.
      (deprecated) Metric for the system errors this table.

      Specified by:
      metricSystemErrors in interface ITable
    • metricSystemErrorsForOperations

      @Stability(Stable) @NotNull public IMetric metricSystemErrorsForOperations(@Nullable SystemErrorsForOperationsMetricOptions props)
      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.

      Specified by:
      metricSystemErrorsForOperations in interface ITable
      Parameters:
      props -
    • metricSystemErrorsForOperations

      @Stability(Stable) @NotNull public IMetric metricSystemErrorsForOperations()
      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.

      Specified by:
      metricSystemErrorsForOperations in interface ITable
    • metricThrottledRequests

      @Stability(Deprecated) @Deprecated @NotNull public Metric metricThrottledRequests(@Nullable MetricOptions props)
      Deprecated.
      Do not use this function. It returns an invalid metric. Use metricThrottledRequestsForOperation instead.
      (deprecated) How many requests are throttled on this table.

      Default: sum over 5 minutes

      Specified by:
      metricThrottledRequests in interface ITable
      Parameters:
      props -
    • metricThrottledRequests

      @Stability(Deprecated) @Deprecated @NotNull public Metric metricThrottledRequests()
      Deprecated.
      Do not use this function. It returns an invalid metric. Use metricThrottledRequestsForOperation instead.
      (deprecated) How many requests are throttled on this table.

      Default: sum over 5 minutes

      Specified by:
      metricThrottledRequests in interface ITable
    • metricThrottledRequestsForOperation

      @Stability(Stable) @NotNull public Metric metricThrottledRequestsForOperation(@NotNull String operation, @Nullable MetricOptions props)
      How many requests are throttled on this table, for the given operation.

      Default: sum over 5 minutes

      Parameters:
      operation - This parameter is required.
      props -
    • metricThrottledRequestsForOperation

      @Stability(Stable) @NotNull public Metric metricThrottledRequestsForOperation(@NotNull String operation)
      How many requests are throttled on this table, for the given operation.

      Default: sum over 5 minutes

      Parameters:
      operation - This parameter is required.
    • metricUserErrors

      @Stability(Stable) @NotNull public Metric metricUserErrors(@Nullable MetricOptions props)
      Metric for the user errors.

      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.

      Specified by:
      metricUserErrors in interface ITable
      Parameters:
      props -
    • metricUserErrors

      @Stability(Stable) @NotNull public Metric metricUserErrors()
      Metric for the user errors.

      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.

      Specified by:
      metricUserErrors in interface ITable
    • 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.
    • validate

      @Stability(Stable) @NotNull protected List<String> validate()
      Validate the table construct.

      Overrides:
      validate in class Construct
      Returns:
      an array of validation error message
    • getHasIndex

      @Stability(Stable) @NotNull protected Boolean getHasIndex()
      Whether this table has indexes.
    • getRegionalArns

      @Stability(Stable) @NotNull protected List<String> getRegionalArns()
    • getTableArn

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

      @Stability(Stable) @NotNull public String getTableName()
      Table name of the dynamodb table.
      Specified by:
      getTableName in interface ITable
    • 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
    • getTableStreamArn

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