# GlobalSecondaryIndexProperty

Represents the properties of a global secondary index.

- Source: Generated at build time
- Type last changed: v2.168.0 · 20 Nov 2024

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_dynamodb as dynamodb } from 'aws-cdk-lib';
const globalSecondaryIndexProperty: dynamodb.CfnTable.GlobalSecondaryIndexProperty = {
  indexName: 'indexName',
  keySchema: [{
    attributeName: 'attributeName',
    keyType: 'keyType',
  }],
  projection: {
    nonKeyAttributes: ['nonKeyAttributes'],
    projectionType: 'projectionType',
  },

  // the properties below are optional
  contributorInsightsSpecification: {
    enabled: false,

    // the properties below are optional
    mode: 'mode',
  },
  onDemandThroughput: {
    maxReadRequestUnits: 123,
    maxWriteRequestUnits: 123,
  },
  provisionedThroughput: {
    readCapacityUnits: 123,
    writeCapacityUnits: 123,
  },
  warmThroughput: {
    readUnitsPerSecond: 123,
    writeUnitsPerSecond: 123,
  },
};
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_dynamodb as dynamodb

global_secondary_index_property = dynamodb.CfnTable.GlobalSecondaryIndexProperty(
    index_name="indexName",
    key_schema=[dynamodb.CfnTable.KeySchemaProperty(
        attribute_name="attributeName",
        key_type="keyType"
    )],
    projection=dynamodb.CfnTable.ProjectionProperty(
        non_key_attributes=["nonKeyAttributes"],
        projection_type="projectionType"
    ),

    # the properties below are optional
    contributor_insights_specification=dynamodb.CfnTable.ContributorInsightsSpecificationProperty(
        enabled=False,

        # the properties below are optional
        mode="mode"
    ),
    on_demand_throughput=dynamodb.CfnTable.OnDemandThroughputProperty(
        max_read_request_units=123,
        max_write_request_units=123
    ),
    provisioned_throughput=dynamodb.CfnTable.ProvisionedThroughputProperty(
        read_capacity_units=123,
        write_capacity_units=123
    ),
    warm_throughput=dynamodb.CfnTable.WarmThroughputProperty(
        read_units_per_second=123,
        write_units_per_second=123
    )
)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.dynamodb.*;

GlobalSecondaryIndexProperty globalSecondaryIndexProperty = GlobalSecondaryIndexProperty.builder()
        .indexName("indexName")
        .keySchema(List.of(KeySchemaProperty.builder()
                .attributeName("attributeName")
                .keyType("keyType")
                .build()))
        .projection(ProjectionProperty.builder()
                .nonKeyAttributes(List.of("nonKeyAttributes"))
                .projectionType("projectionType")
                .build())

        // the properties below are optional
        .contributorInsightsSpecification(ContributorInsightsSpecificationProperty.builder()
                .enabled(false)

                // the properties below are optional
                .mode("mode")
                .build())
        .onDemandThroughput(OnDemandThroughputProperty.builder()
                .maxReadRequestUnits(123)
                .maxWriteRequestUnits(123)
                .build())
        .provisionedThroughput(ProvisionedThroughputProperty.builder()
                .readCapacityUnits(123)
                .writeCapacityUnits(123)
                .build())
        .warmThroughput(WarmThroughputProperty.builder()
                .readUnitsPerSecond(123)
                .writeUnitsPerSecond(123)
                .build())
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.DynamoDB;

var globalSecondaryIndexProperty = new GlobalSecondaryIndexProperty {
    IndexName = "indexName",
    KeySchema = new [] { new KeySchemaProperty {
        AttributeName = "attributeName",
        KeyType = "keyType"
    } },
    Projection = new ProjectionProperty {
        NonKeyAttributes = new [] { "nonKeyAttributes" },
        ProjectionType = "projectionType"
    },

    // the properties below are optional
    ContributorInsightsSpecification = new ContributorInsightsSpecificationProperty {
        Enabled = false,

        // the properties below are optional
        Mode = "mode"
    },
    OnDemandThroughput = new OnDemandThroughputProperty {
        MaxReadRequestUnits = 123,
        MaxWriteRequestUnits = 123
    },
    ProvisionedThroughput = new ProvisionedThroughputProperty {
        ReadCapacityUnits = 123,
        WriteCapacityUnits = 123
    },
    WarmThroughput = new WarmThroughputProperty {
        ReadUnitsPerSecond = 123,
        WriteUnitsPerSecond = 123
    }
};
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

globalSecondaryIndexProperty := &GlobalSecondaryIndexProperty{
	IndexName: jsii.String("indexName"),
	KeySchema: []interface{}{
		&KeySchemaProperty{
			AttributeName: jsii.String("attributeName"),
			KeyType: jsii.String("keyType"),
		},
	},
	Projection: &ProjectionProperty{
		NonKeyAttributes: []*string{
			jsii.String("nonKeyAttributes"),
		},
		ProjectionType: jsii.String("projectionType"),
	},

	// the properties below are optional
	ContributorInsightsSpecification: &ContributorInsightsSpecificationProperty{
		Enabled: jsii.Boolean(false),

		// the properties below are optional
		Mode: jsii.String("mode"),
	},
	OnDemandThroughput: &OnDemandThroughputProperty{
		MaxReadRequestUnits: jsii.Number(123),
		MaxWriteRequestUnits: jsii.Number(123),
	},
	ProvisionedThroughput: &ProvisionedThroughputProperty{
		ReadCapacityUnits: jsii.Number(123),
		WriteCapacityUnits: jsii.Number(123),
	},
	WarmThroughput: &WarmThroughputProperty{
		ReadUnitsPerSecond: jsii.Number(123),
		WriteUnitsPerSecond: jsii.Number(123),
	},
}
```

## Properties

- `contributorInsightsSpecification`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnTable.ContributorInsightsSpecificationProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_dynamodb.CfnTable.ContributorInsightsSpecificationProperty.html) — The settings used to specify whether to enable CloudWatch Contributor Insights for the global table and define which events to monitor.

- `indexName`: string (required) — The name of the global secondary index.

  The name must be unique among all other indexes on this table.

- `keySchema`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnTable.KeySchemaProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_dynamodb.CfnTable.KeySchemaProperty.html)[] (required) — The complete key schema for a global secondary index, which consists of one or more pairs of attribute names and key types: - `HASH` - partition key - `RANGE` - sort key > The partition key of an item is also known as its *hash attribute* .

  The term "hash attribute" derives from DynamoDB's usage of an internal hash function to evenly distribute data items across partitions, based on their partition key values.
  >
  > The sort key of an item is also known as its *range attribute* . The term "range attribute" derives from the way DynamoDB stores items with the same partition key physically close together, in sorted order by the sort key value.

- `onDemandThroughput`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnTable.OnDemandThroughputProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_dynamodb.CfnTable.OnDemandThroughputProperty.html) — The maximum number of read and write units for the specified global secondary index.

  If you use this parameter, you must specify `MaxReadRequestUnits` , `MaxWriteRequestUnits` , or both. You must use either `OnDemandThroughput` or `ProvisionedThroughput` based on your table's capacity mode.

- `projection`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnTable.ProjectionProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_dynamodb.CfnTable.ProjectionProperty.html) (required) — Represents attributes that are copied (projected) from the table into the global secondary index.

  These are in addition to the primary key attributes and index key attributes, which are automatically projected.

- `provisionedThroughput`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnTable.ProvisionedThroughputProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_dynamodb.CfnTable.ProvisionedThroughputProperty.html) — Represents the provisioned throughput settings for the specified global secondary index.

  You must use either `OnDemandThroughput` or `ProvisionedThroughput` based on your table's capacity mode.

  For current minimum and maximum provisioned throughput values, see [Service, Account, and Table Quotas](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Limits.html) in the *Amazon DynamoDB Developer Guide* .

- `warmThroughput`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnTable.WarmThroughputProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_dynamodb.CfnTable.WarmThroughputProperty.html) — Represents the warm throughput value (in read units per second and write units per second) for the specified secondary index.

  If you use this parameter, you must specify `ReadUnitsPerSecond` , `WriteUnitsPerSecond` , or both.
