LocalSecondaryIndexProps

class aws_cdk.aws_dynamodb.LocalSecondaryIndexProps(*, index_name, non_key_attributes=None, projection_type=None, sort_key)

Bases: SecondaryIndexProps

Properties for a local secondary index.

Parameters:
  • 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

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

ExampleMetadata:

infused

Example:

table = dynamodb.TableV2(self, "Table",
    partition_key=dynamodb.Attribute(name="pk", type=dynamodb.AttributeType.STRING),
    sort_key=dynamodb.Attribute(name="sk", type=dynamodb.AttributeType.NUMBER),
    local_secondary_indexes=[dynamodb.LocalSecondaryIndexProps(
        index_name="lsi1",
        sort_key=dynamodb.Attribute(name="sk", type=dynamodb.AttributeType.NUMBER)
    )
    ]
)

table.add_local_secondary_index(
    index_name="lsi2",
    sort_key=dynamodb.Attribute(name="sk", type=dynamodb.AttributeType.NUMBER)
)

Attributes

index_name

The name of the secondary index.

non_key_attributes

The non-key attributes that are projected into the secondary index.

Default:
  • No additional attributes

projection_type

The set of attributes that are projected into the secondary index.

Default:

ALL

sort_key

The attribute of a sort key for the local secondary index.