Skip to content
v2.278.0

KeySchema Struct ​

A description of a key schema of an LSI, GSI or Table.

Example ​

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 keySchema: dynamodb.KeySchema = {
  partitionKeys: [{
    name: 'name',
    type: dynamodb.AttributeType.BINARY,
  }],
  sortKeys: [{
    name: 'name',
    type: dynamodb.AttributeType.BINARY,
  }],
};
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

key_schema = dynamodb.KeySchema(
    partition_keys=[dynamodb.Attribute(
        name="name",
        type=dynamodb.AttributeType.BINARY
    )],
    sort_keys=[dynamodb.Attribute(
        name="name",
        type=dynamodb.AttributeType.BINARY
    )]
)
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.*;

KeySchema keySchema = KeySchema.builder()
        .partitionKeys(List.of(Attribute.builder()
                .name("name")
                .type(AttributeType.BINARY)
                .build()))
        .sortKeys(List.of(Attribute.builder()
                .name("name")
                .type(AttributeType.BINARY)
                .build()))
        .build();
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 keySchema = new KeySchema {
    PartitionKeys = new [] { new Attribute {
        Name = "name",
        Type = AttributeType.BINARY
    } },
    SortKeys = new [] { new Attribute {
        Name = "name",
        Type = AttributeType.BINARY
    } }
};
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"

keySchema := &KeySchema{
	PartitionKeys: []Attribute{
		&Attribute{
			Name: jsii.String("name"),
			Type: awscdk.Aws_dynamodb.AttributeType_BINARY,
		},
	},
	SortKeys: []Attribute{
		&Attribute{
			Name: jsii.String("name"),
			Type: awscdk.*Aws_dynamodb.AttributeType_BINARY,
		},
	},
}

Properties ​

partitionKeysAttribute[]partition_keystyping.List[Attribute]partitionKeysList<Attribute>PartitionKeysAttribute[]PartitionKeys*[]Attribute required #
Partition key definition.

This array has at least one, but potentially multiple entries. Together, they form the partition key.

sortKeysAttribute[]sort_keystyping.List[Attribute]sortKeysList<Attribute>SortKeysAttribute[]SortKeys*[]Attribute required #
Sort key definition.

This array has zero or more entries. Together, they form the sort key.