GlobalSecondaryIndexPropsV2

class aws_cdk.aws_dynamodb.GlobalSecondaryIndexPropsV2(*, index_name, non_key_attributes=None, projection_type=None, max_read_request_units=None, max_write_request_units=None, partition_key=None, partition_keys=None, read_capacity=None, sort_key=None, sort_keys=None, warm_throughput=None, write_capacity=None)

Bases: SecondaryIndexProps

Properties used to configure a global 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

  • max_read_request_units (Union[int, float, None]) – The maximum read request units. Note: This can only be configured if the primary table billing is PAY_PER_REQUEST. Default: - inherited from the primary table.

  • max_write_request_units (Union[int, float, None]) – The maximum write request units. Note: This can only be configured if the primary table billing is PAY_PER_REQUEST. Default: - inherited from the primary table.

  • partition_key (Union[Attribute, Dict[str, Any], None]) – Partition key attribute definition. If a single field forms the partition key, you can use this field. Use the partitionKeys field if the partition key is a multi-attribute key (consists of multiple fields). Default: - exactly one of partitionKey and partitionKeys must be specified.

  • partition_keys (Optional[Sequence[Union[Attribute, Dict[str, Any]]]]) – Multi-attribute partition key. If a single field forms the partition key, you can use either partitionKey or partitionKeys to specify the partition key. Exactly one of these must be specified. You must use partitionKeys field if the partition key is a multi-attribute key (consists of multiple fields). NOTE: although the name of this field makes it sound like it creates multiple keys, it does not. It defines a single key that consists of of multiple fields. The order of fields is not important. Default: - exactly one of partitionKey and partitionKeys must be specified.

  • 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. If a single field forms the sort key, you can use this field. Use the sortKeys field if the sort key is a multi-attribute key (consists of multiple fields). Default: - no sort key

  • sort_keys (Optional[Sequence[Union[Attribute, Dict[str, Any]]]]) – Multi-attribute sort key. If a single field forms the sort key, you can use either sortKey or sortKeys to specify the sort key. At most one of these may be specified. You must use sortKeys field if the sort key is a multi-attribute key (consists of multiple fields). NOTE: although the name of this field makes it sound like it creates multiple keys, it does not. It defines a single key that consists of of multiple fields at the same time. NOTE: The order of fields is important! Default: - no sort key

  • warm_throughput (Union[WarmThroughput, Dict[str, Any], None]) – The warm throughput configuration for the global secondary index. Default: - no warm throughput is configured

  • 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.

ExampleMetadata:

infused

Example:

table = dynamodb.TableV2(self, "Table",
    partition_key=dynamodb.Attribute(name="pk", type=dynamodb.AttributeType.STRING),
    global_secondary_indexes=[dynamodb.GlobalSecondaryIndexPropsV2(
        index_name="gsi1",
        partition_key=dynamodb.Attribute(name="pk", type=dynamodb.AttributeType.STRING)
    )
    ]
)

table.add_global_secondary_index(
    index_name="gsi2",
    partition_key=dynamodb.Attribute(name="pk", type=dynamodb.AttributeType.STRING)
)

# Add a GSI with multi-attribute keys
table.add_global_secondary_index(
    index_name="multi-attribute-gsi2",
    partition_keys=[dynamodb.Attribute(name="multi-attribute_pk1", type=dynamodb.AttributeType.STRING), dynamodb.Attribute(name="multi-attribute_pk2", type=dynamodb.AttributeType.NUMBER)
    ],
    sort_key=dynamodb.Attribute(name="sk", type=dynamodb.AttributeType.STRING)
)

Attributes

index_name

The name of the secondary index.

max_read_request_units

The maximum read request units.

Note: This can only be configured if the primary table billing is PAY_PER_REQUEST.

Default:
  • inherited from the primary table.

max_write_request_units

The maximum write request units.

Note: This can only be configured if the primary table billing is PAY_PER_REQUEST.

Default:
  • inherited from the primary table.

non_key_attributes

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

Default:
  • No additional attributes

partition_key

Partition key attribute definition.

If a single field forms the partition key, you can use this field. Use the partitionKeys field if the partition key is a multi-attribute key (consists of multiple fields).

Default:
  • exactly one of partitionKey and partitionKeys must be specified.

partition_keys

Multi-attribute partition key.

If a single field forms the partition key, you can use either partitionKey or partitionKeys to specify the partition key. Exactly one of these must be specified.

You must use partitionKeys field if the partition key is a multi-attribute key (consists of multiple fields).

NOTE: although the name of this field makes it sound like it creates multiple keys, it does not. It defines a single key that consists of of multiple fields.

The order of fields is not important.

Default:
  • exactly one of partitionKey and partitionKeys must be specified.

projection_type

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

Default:

ALL

read_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

Sort key attribute definition.

If a single field forms the sort key, you can use this field. Use the sortKeys field if the sort key is a multi-attribute key (consists of multiple fields).

Default:
  • no sort key

sort_keys

Multi-attribute sort key.

If a single field forms the sort key, you can use either sortKey or sortKeys to specify the sort key. At most one of these may be specified.

You must use sortKeys field if the sort key is a multi-attribute key (consists of multiple fields).

NOTE: although the name of this field makes it sound like it creates multiple keys, it does not. It defines a single key that consists of of multiple fields at the same time.

NOTE: The order of fields is important!

Default:
  • no sort key

warm_throughput

The warm throughput configuration for the global secondary index.

Default:
  • no warm throughput is configured

write_capacity

The write capacity.

Note: This can only be configured if the primary table billing is provisioned.

Default:
  • inherited from the primary table.