interface GlobalSecondaryIndexPropsV2
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.DynamoDB.GlobalSecondaryIndexPropsV2 |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsdynamodb#GlobalSecondaryIndexPropsV2 |
Java | software.amazon.awscdk.services.dynamodb.GlobalSecondaryIndexPropsV2 |
Python | aws_cdk.aws_dynamodb.GlobalSecondaryIndexPropsV2 |
TypeScript (source) | aws-cdk-lib » aws_dynamodb » GlobalSecondaryIndexPropsV2 |
Properties used to configure a global secondary index.
Example
const table = new dynamodb.TableV2(this, 'Table', {
partitionKey: { name: 'pk', type: dynamodb.AttributeType.STRING },
globalSecondaryIndexes: [
{
indexName: 'gsi1',
partitionKey: { name: 'pk', type: dynamodb.AttributeType.STRING },
},
],
});
table.addGlobalSecondaryIndex({
indexName: 'gsi2',
partitionKey: { name: 'pk', type: dynamodb.AttributeType.STRING },
});
// Add a GSI with multi-attribute keys
table.addGlobalSecondaryIndex({
indexName: 'multi-attribute-gsi2',
partitionKeys: [
{ name: 'multi-attribute_pk1', type: dynamodb.AttributeType.STRING },
{ name: 'multi-attribute_pk2', type: dynamodb.AttributeType.NUMBER },
],
sortKey: { name: 'sk', type: dynamodb.AttributeType.STRING },
});
Properties
| Name | Type | Description |
|---|---|---|
| index | string | The name of the secondary index. |
| max | number | The maximum read request units. |
| max | number | The maximum write request units. |
| non | string[] | The non-key attributes that are projected into the secondary index. |
| partition | Attribute | Partition key attribute definition. |
| partition | Attribute[] | Multi-attribute partition key. |
| projection | Projection | The set of attributes that are projected into the secondary index. |
| read | Capacity | The read capacity. |
| sort | Attribute | Sort key attribute definition. |
| sort | Attribute[] | Multi-attribute sort key. |
| warm | Warm | The warm throughput configuration for the global secondary index. |
| write | Capacity | The write capacity. |
indexName
Type:
string
The name of the secondary index.
maxReadRequestUnits?
Type:
number
(optional, default: inherited from the primary table.)
The maximum read request units.
Note: This can only be configured if the primary table billing is PAY_PER_REQUEST.
maxWriteRequestUnits?
Type:
number
(optional, default: inherited from the primary table.)
The maximum write request units.
Note: This can only be configured if the primary table billing is PAY_PER_REQUEST.
nonKeyAttributes?
Type:
string[]
(optional, default: No additional attributes)
The non-key attributes that are projected into the secondary index.
partitionKey?
Type:
Attribute
(optional, default: exactly one of partitionKey and partitionKeys must be specified.)
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).
partitionKeys?
Type:
Attribute[]
(optional, default: exactly one of partitionKey and partitionKeys must be specified.)
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.
projectionType?
Type:
Projection
(optional, default: ALL)
The set of attributes that are projected into the secondary index.
readCapacity?
Type:
Capacity
(optional, default: inherited from the primary table.)
The read capacity.
Note: This can only be configured if the primary table billing is provisioned.
sortKey?
Type:
Attribute
(optional, default: no 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).
sortKeys?
Type:
Attribute[]
(optional, default: no sort key)
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!
warmThroughput?
Type:
Warm
(optional, default: no warm throughput is configured)
The warm throughput configuration for the global secondary index.
writeCapacity?
Type:
Capacity
(optional, default: inherited from the primary table.)
The write capacity.
Note: This can only be configured if the primary table billing is provisioned.

.NET
Go
Java
Python
TypeScript (