Class GlobalSecondaryIndexPropsV2
Properties used to configure a global secondary index.
Inherited Members
Namespace: Amazon.CDK.AWS.DynamoDB
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class GlobalSecondaryIndexPropsV2 : IGlobalSecondaryIndexPropsV2, ISecondaryIndexProps
Syntax (vb)
Public Class GlobalSecondaryIndexPropsV2 Implements IGlobalSecondaryIndexPropsV2, ISecondaryIndexProps
Remarks
ExampleMetadata: infused
Examples
var table = new TableV2(this, "Table", new TablePropsV2 {
PartitionKey = new Attribute { Name = "pk", Type = AttributeType.STRING },
GlobalSecondaryIndexes = new [] { new GlobalSecondaryIndexPropsV2 {
IndexName = "gsi1",
PartitionKey = new Attribute { Name = "pk", Type = AttributeType.STRING }
} }
});
table.AddGlobalSecondaryIndex(new GlobalSecondaryIndexPropsV2 {
IndexName = "gsi2",
PartitionKey = new Attribute { Name = "pk", Type = AttributeType.STRING }
});
// Add a GSI with multi-attribute keys
table.AddGlobalSecondaryIndex(new GlobalSecondaryIndexPropsV2 {
IndexName = "multi-attribute-gsi2",
PartitionKeys = new [] { new Attribute { Name = "multi-attribute_pk1", Type = AttributeType.STRING }, new Attribute { Name = "multi-attribute_pk2", Type = AttributeType.NUMBER } },
SortKey = new Attribute { Name = "sk", Type = AttributeType.STRING }
});
Synopsis
Constructors
| GlobalSecondaryIndexPropsV2() | Properties used to configure a global secondary index. |
Properties
| IndexName | The name of the secondary index. |
| MaxReadRequestUnits | The maximum read request units. |
| MaxWriteRequestUnits | The maximum write request units. |
| NonKeyAttributes | The non-key attributes that are projected into the secondary index. |
| PartitionKey | Partition key attribute definition. |
| PartitionKeys | Multi-attribute partition key. |
| ProjectionType | The set of attributes that are projected into the secondary index. |
| ReadCapacity | The read capacity. |
| SortKey | Sort key attribute definition. |
| SortKeys | Multi-attribute sort key. |
| WarmThroughput | The warm throughput configuration for the global secondary index. |
| WriteCapacity | The write capacity. |
Constructors
GlobalSecondaryIndexPropsV2()
Properties used to configure a global secondary index.
public GlobalSecondaryIndexPropsV2()
Remarks
ExampleMetadata: infused
Examples
var table = new TableV2(this, "Table", new TablePropsV2 {
PartitionKey = new Attribute { Name = "pk", Type = AttributeType.STRING },
GlobalSecondaryIndexes = new [] { new GlobalSecondaryIndexPropsV2 {
IndexName = "gsi1",
PartitionKey = new Attribute { Name = "pk", Type = AttributeType.STRING }
} }
});
table.AddGlobalSecondaryIndex(new GlobalSecondaryIndexPropsV2 {
IndexName = "gsi2",
PartitionKey = new Attribute { Name = "pk", Type = AttributeType.STRING }
});
// Add a GSI with multi-attribute keys
table.AddGlobalSecondaryIndex(new GlobalSecondaryIndexPropsV2 {
IndexName = "multi-attribute-gsi2",
PartitionKeys = new [] { new Attribute { Name = "multi-attribute_pk1", Type = AttributeType.STRING }, new Attribute { Name = "multi-attribute_pk2", Type = AttributeType.NUMBER } },
SortKey = new Attribute { Name = "sk", Type = AttributeType.STRING }
});
Properties
IndexName
The name of the secondary index.
public string IndexName { get; set; }
Property Value
Remarks
ExampleMetadata: infused
MaxReadRequestUnits
The maximum read request units.
public double? MaxReadRequestUnits { get; set; }
Property Value
Remarks
Note: This can only be configured if the primary table billing is PAY_PER_REQUEST.
Default: - inherited from the primary table.
MaxWriteRequestUnits
The maximum write request units.
public double? MaxWriteRequestUnits { get; set; }
Property Value
Remarks
Note: This can only be configured if the primary table billing is PAY_PER_REQUEST.
Default: - inherited from the primary table.
NonKeyAttributes
The non-key attributes that are projected into the secondary index.
public string[]? NonKeyAttributes { get; set; }
Property Value
string[]
Remarks
Default: - No additional attributes
PartitionKey
Partition key attribute definition.
public IAttribute? PartitionKey { get; set; }
Property Value
Remarks
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.
PartitionKeys
Multi-attribute partition key.
public IAttribute[]? PartitionKeys { get; set; }
Property Value
Remarks
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.
ProjectionType
The set of attributes that are projected into the secondary index.
public ProjectionType? ProjectionType { get; set; }
Property Value
Remarks
Default: ALL
ReadCapacity
The read capacity.
public Capacity? ReadCapacity { get; set; }
Property Value
Remarks
Note: This can only be configured if the primary table billing is provisioned.
Default: - inherited from the primary table.
SortKey
Sort key attribute definition.
public IAttribute? SortKey { get; set; }
Property Value
Remarks
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
SortKeys
Multi-attribute sort key.
public IAttribute[]? SortKeys { get; set; }
Property Value
Remarks
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
WarmThroughput
The warm throughput configuration for the global secondary index.
public IWarmThroughput? WarmThroughput { get; set; }
Property Value
Remarks
Default: - no warm throughput is configured
WriteCapacity
The write capacity.
public Capacity? WriteCapacity { get; set; }
Property Value
Remarks
Note: This can only be configured if the primary table billing is provisioned.
Default: - inherited from the primary table.