# SecondaryIndexProps

Struct · Stable

Properties for a secondary index.

- Source: [`aws-dynamodb/lib/shared.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-dynamodb/lib/shared.ts#L331)

## 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 secondaryIndexProps: dynamodb.SecondaryIndexProps = {
  indexName: 'indexName',

  // the properties below are optional
  nonKeyAttributes: ['nonKeyAttributes'],
  projectionType: dynamodb.ProjectionType.KEYS_ONLY,
};
```

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

secondary_index_props = dynamodb.SecondaryIndexProps(
    index_name="indexName",

    # the properties below are optional
    non_key_attributes=["nonKeyAttributes"],
    projection_type=dynamodb.ProjectionType.KEYS_ONLY
)
```

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.*;

SecondaryIndexProps secondaryIndexProps = SecondaryIndexProps.builder()
        .indexName("indexName")

        // the properties below are optional
        .nonKeyAttributes(List.of("nonKeyAttributes"))
        .projectionType(ProjectionType.KEYS_ONLY)
        .build();
```

C#:

```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 secondaryIndexProps = new SecondaryIndexProps {
    IndexName = "indexName",

    // the properties below are optional
    NonKeyAttributes = new [] { "nonKeyAttributes" },
    ProjectionType = ProjectionType.KEYS_ONLY
};
```

Go:

```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"

secondaryIndexProps := &SecondaryIndexProps{
	IndexName: jsii.String("indexName"),

	// the properties below are optional
	NonKeyAttributes: []*string{
		jsii.String("nonKeyAttributes"),
	},
	ProjectionType: awscdk.Aws_dynamodb.ProjectionType_KEYS_ONLY,
}
```

## Properties

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

- `nonKeyAttributes`: string[] — The non-key attributes that are projected into the secondary index.

  **Default:** No additional attributes

- `projectionType`: [ProjectionType](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_dynamodb.ProjectionType.html) = ALL — The set of attributes that are projected into the secondary index.
