TableV2

class aws_cdk.aws_dynamodb.TableV2(scope, id, *, partition_key, billing=None, dynamo_stream=None, encryption=None, global_secondary_indexes=None, local_secondary_indexes=None, removal_policy=None, replicas=None, sort_key=None, table_name=None, time_to_live_attribute=None, contributor_insights=None, deletion_protection=None, kinesis_stream=None, point_in_time_recovery=None, resource_policy=None, table_class=None, tags=None)

Bases: TableBaseV2

A DynamoDB Table.

ExampleMetadata:

infused

Example:

import aws_cdk as cdk


app = cdk.App()
stack = cdk.Stack(app, "Stack", env=cdk.Environment(region="us-west-2"))

global_table = dynamodb.TableV2(stack, "GlobalTable",
    partition_key=dynamodb.Attribute(name="pk", type=dynamodb.AttributeType.STRING),
    # applys to all replicas, i.e., us-west-2, us-east-1, us-east-2
    removal_policy=cdk.RemovalPolicy.DESTROY,
    replicas=[dynamodb.ReplicaTableProps(region="us-east-1"), dynamodb.ReplicaTableProps(region="us-east-2")
    ]
)
Parameters:
  • scope (Construct) –

  • id (str) –

  • partition_key (Union[Attribute, Dict[str, Any]]) – Partition key attribute definition.

  • billing (Optional[Billing]) – The billing mode and capacity settings to apply to the table. Default: Billing.onDemand()

  • dynamo_stream (Optional[StreamViewType]) – When an item in the table is modified, StreamViewType determines what information is written to the stream. Default: - streams are disabled if replicas are not configured and this property is not specified. If this property is not specified when replicas are configured, then NEW_AND_OLD_IMAGES will be the StreamViewType for all replicas

  • encryption (Optional[TableEncryptionV2]) – The server-side encryption. Default: TableEncryptionV2.dynamoOwnedKey()

  • global_secondary_indexes (Optional[Sequence[Union[GlobalSecondaryIndexPropsV2, Dict[str, Any]]]]) – Global secondary indexes. Note: You can provide a maximum of 20 global secondary indexes. Default: - no global secondary indexes

  • local_secondary_indexes (Optional[Sequence[Union[LocalSecondaryIndexProps, Dict[str, Any]]]]) – Local secondary indexes. Note: You can only provide a maximum of 5 local secondary indexes. Default: - no local secondary indexes

  • removal_policy (Optional[RemovalPolicy]) – The removal policy applied to the table. Default: RemovalPolicy.RETAIN

  • replicas (Optional[Sequence[Union[ReplicaTableProps, Dict[str, Any]]]]) – Replica tables to deploy with the primary table. Note: Adding replica tables allows you to use your table as a global table. You cannot specify a replica table in the region that the primary table will be deployed to. Replica tables will only be supported if the stack deployment region is defined. Default: - no replica tables

  • sort_key (Union[Attribute, Dict[str, Any], None]) – Sort key attribute definition. Default: - no sort key

  • table_name (Optional[str]) – The name of the table. Default: - generated by CloudFormation

  • time_to_live_attribute (Optional[str]) – The name of the TTL attribute. Default: - TTL is disabled

  • contributor_insights (Optional[bool]) – Whether CloudWatch contributor insights is enabled. Default: false

  • deletion_protection (Optional[bool]) – Whether deletion protection is enabled. Default: false

  • kinesis_stream (Optional[IStream]) – Kinesis Data Stream to capture item level changes. Default: - no Kinesis Data Stream

  • point_in_time_recovery (Optional[bool]) – Whether point-in-time recovery is enabled. Default: false

  • resource_policy (Optional[PolicyDocument]) – Resource policy to assign to DynamoDB Table. Default: - No resource policy statements are added to the created table.

  • table_class (Optional[TableClass]) – The table class. Default: TableClass.STANDARD

  • tags (Optional[Sequence[Union[CfnTag, Dict[str, Any]]]]) – Tags to be applied to the table or replica table. Default: - no tags

Methods

add_global_secondary_index(*, partition_key, read_capacity=None, sort_key=None, write_capacity=None, index_name, non_key_attributes=None, projection_type=None)

Add a global secondary index to the table.

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

Parameters:
  • partition_key (Union[Attribute, Dict[str, Any]]) – Partition key attribute definition.

  • read_capacity (Optional[Capacity]) – The read capacity. Note: This can only be configured if the primary table billing is provisioned. Default: - inherited from the primary table.

  • sort_key (Union[Attribute, Dict[str, Any], None]) – Sort key attribute definition. Default: - no sort key

  • write_capacity (Optional[Capacity]) – The write capacity. Note: This can only be configured if the primary table billing is provisioned. Default: - inherited from the primary table.

  • index_name (str) – The name of the secondary index.

  • non_key_attributes (Optional[Sequence[str]]) – The non-key attributes that are projected into the secondary index. Default: - No additional attributes

  • projection_type (Optional[ProjectionType]) – The set of attributes that are projected into the secondary index. Default: ALL

Return type:

None

add_local_secondary_index(*, sort_key, index_name, non_key_attributes=None, projection_type=None)

Add a local secondary index to the table.

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

Parameters:
  • sort_key (Union[Attribute, Dict[str, Any]]) – The attribute of a sort key for the local secondary index.

  • index_name (str) – The name of the secondary index.

  • non_key_attributes (Optional[Sequence[str]]) – The non-key attributes that are projected into the secondary index. Default: - No additional attributes

  • projection_type (Optional[ProjectionType]) – The set of attributes that are projected into the secondary index. Default: ALL

Return type:

None

add_replica(*, region, global_secondary_index_options=None, read_capacity=None, contributor_insights=None, deletion_protection=None, kinesis_stream=None, point_in_time_recovery=None, resource_policy=None, table_class=None, tags=None)

Add a replica table.

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

Parameters:
  • region (str) – The region that the replica table will be created in.

  • global_secondary_index_options (Optional[Mapping[str, Union[ReplicaGlobalSecondaryIndexOptions, Dict[str, Any]]]]) – Options used to configure global secondary index properties. Default: - inherited from the primary table

  • read_capacity (Optional[Capacity]) – The read capacity. Note: This can only be configured if the primary table billing is provisioned. Default: - inherited from the primary table

  • contributor_insights (Optional[bool]) – Whether CloudWatch contributor insights is enabled. Default: false

  • deletion_protection (Optional[bool]) – Whether deletion protection is enabled. Default: false

  • kinesis_stream (Optional[IStream]) – Kinesis Data Stream to capture item level changes. Default: - no Kinesis Data Stream

  • point_in_time_recovery (Optional[bool]) – Whether point-in-time recovery is enabled. Default: false

  • resource_policy (Optional[PolicyDocument]) – Resource policy to assign to DynamoDB Table. Default: - No resource policy statements are added to the created table.

  • table_class (Optional[TableClass]) – The table class. Default: TableClass.STANDARD

  • tags (Optional[Sequence[Union[CfnTag, Dict[str, Any]]]]) – Tags to be applied to the table or replica table. Default: - no tags

Return type:

None

add_to_resource_policy(statement)

Adds a statement to the resource policy associated with this file system.

A resource policy will be automatically created upon the first call to addToResourcePolicy.

Note that this does not work with imported file systems.

Parameters:

statement (PolicyStatement) – The policy statement to add.

Return type:

AddToResourcePolicyResult

apply_removal_policy(policy)

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you’ve removed it from the CDK application or because you’ve made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

Parameters:

policy (RemovalPolicy) –

Return type:

None

grant(grantee, *actions)

Adds an IAM policy statement associated with this table to an IAM principal’s policy.

Note: If encryptionKey is present, appropriate grants to the key needs to be added separately using the table.encryptionKey.grant* methods.

Parameters:
  • grantee (IGrantable) – the principal (no-op if undefined).

  • actions (str) – the set of actions to allow (i.e., ‘dynamodb:PutItem’, ‘dynamodb:GetItem’, etc.).

Return type:

Grant

grant_full_access(grantee)

Permits an IAM principal to all DynamoDB operations (‘dynamodb:*’) on this table.

Note: Appropriate grants will also be added to the customer-managed KMS keys associated with this table if one was configured.

Parameters:

grantee (IGrantable) – the principal to grant access to.

Return type:

Grant

grant_read_data(grantee)

Permits an IAM principal all data read operations on this table.

Actions: BatchGetItem, GetRecords, GetShardIterator, Query, GetItem, Scan, DescribeTable.

Note: Appropriate grants will also be added to the customer-managed KMS keys associated with this table if one was configured.

Parameters:

grantee (IGrantable) – the principal to grant access to.

Return type:

Grant

grant_read_write_data(grantee)

Permits an IAM principal to all data read/write operations on this table.

Actions: BatchGetItem, GetRecords, GetShardIterator, Query, GetItem, Scan, BatchWriteItem, PutItem, UpdateItem, DeleteItem, DescribeTable.

Note: Appropriate grants will also be added to the customer-managed KMS keys associated with this table if one was configured.

Parameters:

grantee (IGrantable) – the principal to grant access to.

Return type:

Grant

grant_stream(grantee, *actions)

Adds an IAM policy statement associated with this table to an IAM principal’s policy.

Note: If encryptionKey is present, appropriate grants to the key needs to be added separately using the table.encryptionKey.grant* methods.

Parameters:
  • grantee (IGrantable) – the principal (no-op if undefined).

  • actions (str) – the set of actions to allow (i.e., ‘dynamodb:DescribeStream’, ‘dynamodb:GetRecords’, etc.).

Return type:

Grant

grant_stream_read(grantee)

Adds an IAM policy statement associated with this table to an IAM principal’s policy.

Actions: DescribeStream, GetRecords, GetShardIterator, ListStreams.

Note: Appropriate grants will also be added to the customer-managed KMS keys associated with this table if one was configured.

Parameters:

grantee (IGrantable) – the principal to grant access to.

Return type:

Grant

grant_table_list_streams(grantee)

Permits an IAM principal to list streams attached to this table.

Parameters:

grantee (IGrantable) – the principal to grant access to.

Return type:

Grant

grant_write_data(grantee)

Permits an IAM principal all data write operations on this table.

Actions: BatchWriteItem, PutItem, UpdateItem, DeleteItem, DescribeTable.

Note: Appropriate grants will also be added to the customer-managed KMS keys associated with this table if one was configured.

Parameters:

grantee (IGrantable) – the principal to grant access to.

Return type:

Grant

metric(metric_name, *, account=None, color=None, dimensions_map=None, label=None, period=None, region=None, statistic=None, unit=None)

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.

Parameters:
  • metric_name (str) –

  • account (Optional[str]) – Account which this metric comes from. Default: - Deployment account.

  • color (Optional[str]) – The hex color code, prefixed with ‘#’ (e.g. ‘#00ff00’), to use when this metric is rendered on a graph. The Color class has a set of standard colors that can be used here. Default: - Automatic color

  • dimensions_map (Optional[Mapping[str, str]]) – Dimensions of the metric. Default: - No dimensions.

  • label (Optional[str]) – Label for this metric when added to a Graph in a Dashboard. You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:: [max: ${MAX}] MyMetric As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph’s legend. Default: - No label

  • period (Optional[Duration]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)

  • region (Optional[str]) – Region which this metric comes from. Default: - Deployment region.

  • statistic (Optional[str]) – What function to use for aggregating. Use the aws_cloudwatch.Stats helper class to construct valid input strings. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” - “tmNN.NN” | “tm(NN.NN%:NN.NN%)” - “iqm” - “wmNN.NN” | “wm(NN.NN%:NN.NN%)” - “tcNN.NN” | “tc(NN.NN%:NN.NN%)” - “tsNN.NN” | “ts(NN.NN%:NN.NN%)” Default: Average

  • unit (Optional[Unit]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: - All metric datums in the given metric stream

Return type:

Metric

metric_conditional_check_failed_requests(*, account=None, color=None, dimensions_map=None, label=None, period=None, region=None, statistic=None, unit=None)

Metric for the conditional check failed requests 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.

Parameters:
  • account (Optional[str]) – Account which this metric comes from. Default: - Deployment account.

  • color (Optional[str]) – The hex color code, prefixed with ‘#’ (e.g. ‘#00ff00’), to use when this metric is rendered on a graph. The Color class has a set of standard colors that can be used here. Default: - Automatic color

  • dimensions_map (Optional[Mapping[str, str]]) – Dimensions of the metric. Default: - No dimensions.

  • label (Optional[str]) –

    Label for this metric when added to a Graph in a Dashboard. You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:: [max: ${MAX}] MyMetric As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph’s legend. Default: - No label

  • period (Optional[Duration]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)

  • region (Optional[str]) – Region which this metric comes from. Default: - Deployment region.

  • statistic (Optional[str]) – What function to use for aggregating. Use the aws_cloudwatch.Stats helper class to construct valid input strings. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” - “tmNN.NN” | “tm(NN.NN%:NN.NN%)” - “iqm” - “wmNN.NN” | “wm(NN.NN%:NN.NN%)” - “tcNN.NN” | “tc(NN.NN%:NN.NN%)” - “tsNN.NN” | “ts(NN.NN%:NN.NN%)” Default: Average

  • unit (Optional[Unit]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: - All metric datums in the given metric stream

Return type:

Metric

metric_consumed_read_capacity_units(*, account=None, color=None, dimensions_map=None, label=None, period=None, region=None, statistic=None, unit=None)

Metric for the consumed read capacity units 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.

Parameters:
  • account (Optional[str]) – Account which this metric comes from. Default: - Deployment account.

  • color (Optional[str]) – The hex color code, prefixed with ‘#’ (e.g. ‘#00ff00’), to use when this metric is rendered on a graph. The Color class has a set of standard colors that can be used here. Default: - Automatic color

  • dimensions_map (Optional[Mapping[str, str]]) – Dimensions of the metric. Default: - No dimensions.

  • label (Optional[str]) –

    Label for this metric when added to a Graph in a Dashboard. You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:: [max: ${MAX}] MyMetric As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph’s legend. Default: - No label

  • period (Optional[Duration]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)

  • region (Optional[str]) – Region which this metric comes from. Default: - Deployment region.

  • statistic (Optional[str]) – What function to use for aggregating. Use the aws_cloudwatch.Stats helper class to construct valid input strings. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” - “tmNN.NN” | “tm(NN.NN%:NN.NN%)” - “iqm” - “wmNN.NN” | “wm(NN.NN%:NN.NN%)” - “tcNN.NN” | “tc(NN.NN%:NN.NN%)” - “tsNN.NN” | “ts(NN.NN%:NN.NN%)” Default: Average

  • unit (Optional[Unit]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: - All metric datums in the given metric stream

Return type:

Metric

metric_consumed_write_capacity_units(*, account=None, color=None, dimensions_map=None, label=None, period=None, region=None, statistic=None, unit=None)

Metric for the consumed write capacity units 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.

Parameters:
  • account (Optional[str]) – Account which this metric comes from. Default: - Deployment account.

  • color (Optional[str]) – The hex color code, prefixed with ‘#’ (e.g. ‘#00ff00’), to use when this metric is rendered on a graph. The Color class has a set of standard colors that can be used here. Default: - Automatic color

  • dimensions_map (Optional[Mapping[str, str]]) – Dimensions of the metric. Default: - No dimensions.

  • label (Optional[str]) –

    Label for this metric when added to a Graph in a Dashboard. You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:: [max: ${MAX}] MyMetric As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph’s legend. Default: - No label

  • period (Optional[Duration]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)

  • region (Optional[str]) – Region which this metric comes from. Default: - Deployment region.

  • statistic (Optional[str]) – What function to use for aggregating. Use the aws_cloudwatch.Stats helper class to construct valid input strings. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” - “tmNN.NN” | “tm(NN.NN%:NN.NN%)” - “iqm” - “wmNN.NN” | “wm(NN.NN%:NN.NN%)” - “tcNN.NN” | “tc(NN.NN%:NN.NN%)” - “tsNN.NN” | “ts(NN.NN%:NN.NN%)” Default: Average

  • unit (Optional[Unit]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: - All metric datums in the given metric stream

Return type:

Metric

metric_successful_request_latency(*, account=None, color=None, dimensions_map=None, label=None, period=None, region=None, statistic=None, unit=None)

Metric for the successful request latency for 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.

Parameters:
  • account (Optional[str]) – Account which this metric comes from. Default: - Deployment account.

  • color (Optional[str]) – The hex color code, prefixed with ‘#’ (e.g. ‘#00ff00’), to use when this metric is rendered on a graph. The Color class has a set of standard colors that can be used here. Default: - Automatic color

  • dimensions_map (Optional[Mapping[str, str]]) – Dimensions of the metric. Default: - No dimensions.

  • label (Optional[str]) –

    Label for this metric when added to a Graph in a Dashboard. You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:: [max: ${MAX}] MyMetric As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph’s legend. Default: - No label

  • period (Optional[Duration]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)

  • region (Optional[str]) – Region which this metric comes from. Default: - Deployment region.

  • statistic (Optional[str]) – What function to use for aggregating. Use the aws_cloudwatch.Stats helper class to construct valid input strings. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” - “tmNN.NN” | “tm(NN.NN%:NN.NN%)” - “iqm” - “wmNN.NN” | “wm(NN.NN%:NN.NN%)” - “tcNN.NN” | “tc(NN.NN%:NN.NN%)” - “tsNN.NN” | “ts(NN.NN%:NN.NN%)” Default: Average

  • unit (Optional[Unit]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: - All metric datums in the given metric stream

Return type:

Metric

metric_system_errors(*, account=None, color=None, dimensions_map=None, label=None, period=None, region=None, statistic=None, unit=None)

(deprecated) Metric for the system errors this table.

Parameters:
  • account (Optional[str]) – Account which this metric comes from. Default: - Deployment account.

  • color (Optional[str]) – The hex color code, prefixed with ‘#’ (e.g. ‘#00ff00’), to use when this metric is rendered on a graph. The Color class has a set of standard colors that can be used here. Default: - Automatic color

  • dimensions_map (Optional[Mapping[str, str]]) – Dimensions of the metric. Default: - No dimensions.

  • label (Optional[str]) –

    Label for this metric when added to a Graph in a Dashboard. You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:: [max: ${MAX}] MyMetric As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph’s legend. Default: - No label

  • period (Optional[Duration]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)

  • region (Optional[str]) – Region which this metric comes from. Default: - Deployment region.

  • statistic (Optional[str]) – What function to use for aggregating. Use the aws_cloudwatch.Stats helper class to construct valid input strings. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” - “tmNN.NN” | “tm(NN.NN%:NN.NN%)” - “iqm” - “wmNN.NN” | “wm(NN.NN%:NN.NN%)” - “tcNN.NN” | “tc(NN.NN%:NN.NN%)” - “tsNN.NN” | “ts(NN.NN%:NN.NN%)” Default: Average

  • unit (Optional[Unit]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: - All metric datums in the given metric stream

Deprecated:

use metricSystemErrorsForOperations.

Stability:

deprecated

Return type:

Metric

metric_system_errors_for_operations(*, operations=None, account=None, color=None, dimensions_map=None, label=None, period=None, region=None, statistic=None, unit=None)

Metric for the system errors for this table. This will sum errors across all possible operations.

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.

Parameters:
  • operations (Optional[Sequence[Operation]]) – The operations to apply the metric to. Default: - All operations available by DynamoDB tables will be considered.

  • account (Optional[str]) – Account which this metric comes from. Default: - Deployment account.

  • color (Optional[str]) – The hex color code, prefixed with ‘#’ (e.g. ‘#00ff00’), to use when this metric is rendered on a graph. The Color class has a set of standard colors that can be used here. Default: - Automatic color

  • dimensions_map (Optional[Mapping[str, str]]) – Dimensions of the metric. Default: - No dimensions.

  • label (Optional[str]) –

    Label for this metric when added to a Graph in a Dashboard. You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:: [max: ${MAX}] MyMetric As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph’s legend. Default: - No label

  • period (Optional[Duration]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)

  • region (Optional[str]) – Region which this metric comes from. Default: - Deployment region.

  • statistic (Optional[str]) – What function to use for aggregating. Use the aws_cloudwatch.Stats helper class to construct valid input strings. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” - “tmNN.NN” | “tm(NN.NN%:NN.NN%)” - “iqm” - “wmNN.NN” | “wm(NN.NN%:NN.NN%)” - “tcNN.NN” | “tc(NN.NN%:NN.NN%)” - “tsNN.NN” | “ts(NN.NN%:NN.NN%)” Default: Average

  • unit (Optional[Unit]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: - All metric datums in the given metric stream

Return type:

IMetric

metric_throttled_requests(*, account=None, color=None, dimensions_map=None, label=None, period=None, region=None, statistic=None, unit=None)

(deprecated) How many requests are throttled on this table.

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.

Parameters:
  • account (Optional[str]) – Account which this metric comes from. Default: - Deployment account.

  • color (Optional[str]) – The hex color code, prefixed with ‘#’ (e.g. ‘#00ff00’), to use when this metric is rendered on a graph. The Color class has a set of standard colors that can be used here. Default: - Automatic color

  • dimensions_map (Optional[Mapping[str, str]]) – Dimensions of the metric. Default: - No dimensions.

  • label (Optional[str]) –

    Label for this metric when added to a Graph in a Dashboard. You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:: [max: ${MAX}] MyMetric As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph’s legend. Default: - No label

  • period (Optional[Duration]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)

  • region (Optional[str]) – Region which this metric comes from. Default: - Deployment region.

  • statistic (Optional[str]) – What function to use for aggregating. Use the aws_cloudwatch.Stats helper class to construct valid input strings. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” - “tmNN.NN” | “tm(NN.NN%:NN.NN%)” - “iqm” - “wmNN.NN” | “wm(NN.NN%:NN.NN%)” - “tcNN.NN” | “tc(NN.NN%:NN.NN%)” - “tsNN.NN” | “ts(NN.NN%:NN.NN%)” Default: Average

  • unit (Optional[Unit]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: - All metric datums in the given metric stream

Deprecated:

Do not use this function. It returns an invalid metric. Use metricThrottledRequestsForOperation instead.

Stability:

deprecated

Return type:

Metric

metric_throttled_requests_for_operation(operation, *, operations=None, account=None, color=None, dimensions_map=None, label=None, period=None, region=None, statistic=None, unit=None)

How many requests are throttled on this table for the given operation.

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.

Parameters:
  • operation (str) –

  • operations (Optional[Sequence[Operation]]) – The operations to apply the metric to. Default: - All operations available by DynamoDB tables will be considered.

  • account (Optional[str]) – Account which this metric comes from. Default: - Deployment account.

  • color (Optional[str]) – The hex color code, prefixed with ‘#’ (e.g. ‘#00ff00’), to use when this metric is rendered on a graph. The Color class has a set of standard colors that can be used here. Default: - Automatic color

  • dimensions_map (Optional[Mapping[str, str]]) – Dimensions of the metric. Default: - No dimensions.

  • label (Optional[str]) –

    Label for this metric when added to a Graph in a Dashboard. You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:: [max: ${MAX}] MyMetric As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph’s legend. Default: - No label

  • period (Optional[Duration]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)

  • region (Optional[str]) – Region which this metric comes from. Default: - Deployment region.

  • statistic (Optional[str]) – What function to use for aggregating. Use the aws_cloudwatch.Stats helper class to construct valid input strings. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” - “tmNN.NN” | “tm(NN.NN%:NN.NN%)” - “iqm” - “wmNN.NN” | “wm(NN.NN%:NN.NN%)” - “tcNN.NN” | “tc(NN.NN%:NN.NN%)” - “tsNN.NN” | “ts(NN.NN%:NN.NN%)” Default: Average

  • unit (Optional[Unit]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: - All metric datums in the given metric stream

Return type:

IMetric

metric_throttled_requests_for_operations(*, operations=None, account=None, color=None, dimensions_map=None, label=None, period=None, region=None, statistic=None, unit=None)

How many requests are throttled on this table. This will sum errors across all possible operations.

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.

Parameters:
  • operations (Optional[Sequence[Operation]]) – The operations to apply the metric to. Default: - All operations available by DynamoDB tables will be considered.

  • account (Optional[str]) – Account which this metric comes from. Default: - Deployment account.

  • color (Optional[str]) – The hex color code, prefixed with ‘#’ (e.g. ‘#00ff00’), to use when this metric is rendered on a graph. The Color class has a set of standard colors that can be used here. Default: - Automatic color

  • dimensions_map (Optional[Mapping[str, str]]) – Dimensions of the metric. Default: - No dimensions.

  • label (Optional[str]) –

    Label for this metric when added to a Graph in a Dashboard. You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:: [max: ${MAX}] MyMetric As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph’s legend. Default: - No label

  • period (Optional[Duration]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)

  • region (Optional[str]) – Region which this metric comes from. Default: - Deployment region.

  • statistic (Optional[str]) – What function to use for aggregating. Use the aws_cloudwatch.Stats helper class to construct valid input strings. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” - “tmNN.NN” | “tm(NN.NN%:NN.NN%)” - “iqm” - “wmNN.NN” | “wm(NN.NN%:NN.NN%)” - “tcNN.NN” | “tc(NN.NN%:NN.NN%)” - “tsNN.NN” | “ts(NN.NN%:NN.NN%)” Default: Average

  • unit (Optional[Unit]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: - All metric datums in the given metric stream

Return type:

IMetric

metric_user_errors(*, account=None, color=None, dimensions_map=None, label=None, period=None, region=None, statistic=None, unit=None)

Metric for the user errors for this table.

Note: 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.

Parameters:
  • account (Optional[str]) – Account which this metric comes from. Default: - Deployment account.

  • color (Optional[str]) – The hex color code, prefixed with ‘#’ (e.g. ‘#00ff00’), to use when this metric is rendered on a graph. The Color class has a set of standard colors that can be used here. Default: - Automatic color

  • dimensions_map (Optional[Mapping[str, str]]) – Dimensions of the metric. Default: - No dimensions.

  • label (Optional[str]) –

    Label for this metric when added to a Graph in a Dashboard. You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:: [max: ${MAX}] MyMetric As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph’s legend. Default: - No label

  • period (Optional[Duration]) – The period over which the specified statistic is applied. Default: Duration.minutes(5)

  • region (Optional[str]) – Region which this metric comes from. Default: - Deployment region.

  • statistic (Optional[str]) – What function to use for aggregating. Use the aws_cloudwatch.Stats helper class to construct valid input strings. Can be one of the following: - “Minimum” | “min” - “Maximum” | “max” - “Average” | “avg” - “Sum” | “sum” - “SampleCount | “n” - “pNN.NN” - “tmNN.NN” | “tm(NN.NN%:NN.NN%)” - “iqm” - “wmNN.NN” | “wm(NN.NN%:NN.NN%)” - “tcNN.NN” | “tc(NN.NN%:NN.NN%)” - “tsNN.NN” | “ts(NN.NN%:NN.NN%)” Default: Average

  • unit (Optional[Unit]) – Unit used to filter the metric stream. Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units. The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases. CloudWatch does not honor this property for graphs. Default: - All metric datums in the given metric stream

Return type:

Metric

replica(region)

Retrieve a replica table.

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

Parameters:

region (str) – the region of the replica table.

Return type:

ITableV2

to_string()

Returns a string representation of this construct.

Return type:

str

Attributes

encryption_key

The KMS encryption key for the table.

env

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.

node

The tree node.

resource_policy

The resource policy for the table.

Attribute:

true

stack

The stack in which this resource is defined.

table_arn

The ARN of the table.

Attribute:

true

table_id

The ID of the table.

Attribute:

true

table_name

The name of the table.

Attribute:

true

table_stream_arn

The stream ARN of the table.

Attribute:

true

Static Methods

classmethod from_table_arn(scope, id, table_arn)

Creates a Table construct that represents an external table via table ARN.

Parameters:
  • scope (Construct) – the parent creating construct (usually this).

  • id (str) – the construct’s name.

  • table_arn (str) – the table’s ARN.

Return type:

ITableV2

classmethod from_table_attributes(scope, id, *, encryption_key=None, global_indexes=None, grant_index_permissions=None, local_indexes=None, table_arn=None, table_id=None, table_name=None, table_stream_arn=None)

Creates a Table construct that represents an external table.

Parameters:
  • scope (Construct) – the parent creating construct (usually this).

  • id (str) – the construct’s name.

  • encryption_key (Optional[IKey]) – KMS encryption key for the table. Default: - no KMS encryption key

  • global_indexes (Optional[Sequence[str]]) – The name of the global indexes set for the table. Note: You must set either this property or localIndexes if you want permissions to be granted for indexes as well as the table itself. Default: - no global indexes

  • grant_index_permissions (Optional[bool]) – Whether or not to grant permissions for all indexes of the table. Note: If false, permissions will only be granted to indexes when globalIndexes or localIndexes is specified. Default: false

  • local_indexes (Optional[Sequence[str]]) – The name of the local indexes set for the table. Note: You must set either this property or globalIndexes if you want permissions to be granted for indexes as well as the table itself. Default: - no local indexes

  • table_arn (Optional[str]) – The ARN of the table. Note: You must specify this or the tableName. Default: - table arn generated using tableName and region of stack

  • table_id (Optional[str]) – The ID of the table. Default: - no table id

  • table_name (Optional[str]) – The name of the table. Note: You must specify this or the tableArn. Default: - table name retrieved from provided tableArn

  • table_stream_arn (Optional[str]) – The stream ARN of the table. Default: - no table stream ARN

Return type:

ITableV2

classmethod from_table_name(scope, id, table_name)

Creates a Table construct that represents an external table via table name.

Parameters:
  • scope (Construct) – the parent creating construct (usually this).

  • id (str) – the construct’s name.

  • table_name (str) – the table’s name.

Return type:

ITableV2

classmethod is_construct(x)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters:

x (Any) – Any object.

Return type:

bool

Returns:

true if x is an object created from a class which extends Construct.

classmethod is_owned_resource(construct)

Returns true if the construct was created by CDK, and false otherwise.

Parameters:

construct (IConstruct) –

Return type:

bool

classmethod is_resource(construct)

Check whether the given construct is a Resource.

Parameters:

construct (IConstruct) –

Return type:

bool