# TableEncryptionV2

Represents server-side encryption for a DynamoDB table.

- Source: [`aws-dynamodb/lib/encryption.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-dynamodb/lib/encryption.ts#L11)
- Type last changed: v2.95.0 · 7 Sep 2023

## Example

```ts
import * as cdk from 'aws-cdk-lib';
import * as kms from 'aws-cdk-lib/aws-kms';

const app = new cdk.App();
const stack = new cdk.Stack(app, 'Stack', { env: { region: 'us-west-2' } });

const tableKey = new kms.Key(stack, 'Key');
const replicaKeyArns = {
  'us-east-1': 'arn:aws:kms:us-east-1:123456789012:key/g24efbna-az9b-42ro-m3bp-cq249l94fca6',
  'us-east-2': 'arn:aws:kms:us-east-2:123456789012:key/h90bkasj-bs1j-92wp-s2ka-bh857d60bkj8',
};

const globalTable = new dynamodb.TableV2(stack, 'GlobalTable', {
  partitionKey: { name: 'pk', type: dynamodb.AttributeType.STRING },
  encryption: dynamodb.TableEncryptionV2.customerManagedKey(tableKey, replicaKeyArns),
  replicas: [
    { region: 'us-east-1' },
    { region: 'us-east-2' },
  ],
});
```

## Properties

- `replicaKeyArns`: { [key: string]: string }

- `tableKey`: [IKey](/cdk/api/v2/docs/aws-cdk-lib.aws_kms.IKey.html)

- `type`: [TableEncryption](/cdk/api/v2/docs/aws-cdk-lib.aws_dynamodb.TableEncryption.html)

## Methods

- `awsManagedKey(): TableEncryptionV2 // chainable` (static) — Configure server-side encryption using an AWS managed key.

- `customerManagedKey(tableKey: IKey, replicaKeyArns?: { [key: string]: string }): TableEncryptionV2 // chainable` (static) — Configure server-side encryption using customer managed keys.

  **Parameters**

  - `tableKey` — the KMS key for the primary table.
  - `replicaKeyArns` — an object containing the ARN of the KMS key to use for each replica table.

- `dynamoOwnedKey(): TableEncryptionV2 // chainable` (static) — Configure server-side encryption using a DynamoDB owned key.
