Capacity

class aws_cdk.aws_dynamodb.Capacity(*args: Any, **kwargs)

Bases: object

Represents the amount of read and write operations supported by 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),
    billing=dynamodb.Billing.provisioned(
        read_capacity=dynamodb.Capacity.fixed(10),
        write_capacity=dynamodb.Capacity.autoscaled(max_capacity=15)
    ),
    replicas=[dynamodb.ReplicaTableProps(
        region="us-east-1"
    ), dynamodb.ReplicaTableProps(
        region="us-east-2",
        read_capacity=dynamodb.Capacity.autoscaled(max_capacity=20, target_utilization_percent=50)
    )
    ]
)

Attributes

mode

Static Methods

classmethod autoscaled(*, max_capacity, min_capacity=None, seed_capacity=None, target_utilization_percent=None)

Dynamically adjusts provisioned throughput capacity on your behalf in response to actual traffic patterns.

Parameters:
  • max_capacity (Union[int, float]) – The maximum allowable capacity.

  • min_capacity (Union[int, float, None]) – The minimum allowable capacity. Default: 1

  • seed_capacity (Union[int, float, None]) – If you want to switch a table’s billing mode from on-demand to provisioned or from provisioned to on-demand, you must specify a value for this property for each autoscaled resource. Default: no seed capacity

  • target_utilization_percent (Union[int, float, None]) – The ratio of consumed capacity units to provisioned capacity units. Note: Target utilization percent cannot be less than 20 and cannot be greater than 90. Default: 70

Return type:

Capacity

classmethod fixed(iops)

Provisioned throughput capacity is configured with fixed capacity units.

Note: You cannot configure write capacity using fixed capacity mode.

Parameters:

iops (Union[int, float]) – the number of I/O operations per second.

Return type:

Capacity