Attribute

class aws_cdk.aws_dynamodb.Attribute(*, name, type)

Bases: object

Represents an attribute for describing the key schema for the table and indexes.

Parameters:
  • name (str) – The name of an attribute.

  • type (AttributeType) – The data type of an attribute.

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")
    ]
)

Attributes

name

The name of an attribute.

type

The data type of an attribute.