# ReplicaTableProps

Properties used to configure a replica table.

Extends: [TableOptionsV2](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_dynamodb.TableOptionsV2.html)
Used as argument in: [TableV2.addReplica](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_dynamodb.TableV2.html#addreplica)

- Source: [`aws-dynamodb/lib/table-v2.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-dynamodb/lib/table-v2.ts#L304)
- Type last changed: v2.154.0 · 22 Aug 2024

## Example

TypeScript:

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

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

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

globalTable.addReplica({ region: 'us-east-2', deletionProtection: true });
```

Python:

```python
import aws_cdk as cdk

app = cdk.App()
stack = cdk.Stack(app, "Stack", env=cdk.Environment(region="us-west-2"))

global_table = dynamodb.TableV2(stack, "GlobalTable",
    partition_key=dynamodb.Attribute(name="pk", type=dynamodb.AttributeType.STRING),
    replicas=[dynamodb.ReplicaTableProps(region="us-east-1")]
)

global_table.add_replica(region="us-east-2", deletion_protection=True)
```

Java:

```java
import software.amazon.awscdk.*;

App app = new App();
Stack stack = Stack.Builder.create(app, "Stack").env(Environment.builder().region("us-west-2").build()).build();

TableV2 globalTable = TableV2.Builder.create(stack, "GlobalTable")
        .partitionKey(Attribute.builder().name("pk").type(AttributeType.STRING).build())
        .replicas(List.of(ReplicaTableProps.builder().region("us-east-1").build()))
        .build();

globalTable.addReplica(ReplicaTableProps.builder().region("us-east-2").deletionProtection(true).build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK;

var app = new App();
var stack = new Stack(app, "Stack", new StackProps { Env = new Environment { Region = "us-west-2" } });

var globalTable = new TableV2(stack, "GlobalTable", new TablePropsV2 {
    PartitionKey = new Attribute { Name = "pk", Type = AttributeType.STRING },
    Replicas = new [] { new ReplicaTableProps { Region = "us-east-1" } }
});

globalTable.AddReplica(new ReplicaTableProps { Region = "us-east-2", DeletionProtection = true });
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import "github.com/aws/aws-cdk-go/awscdk"

app := cdk.NewApp()
stack := cdk.NewStack(app, jsii.String("Stack"), &StackProps{
	Env: &Environment{
		Region: jsii.String("us-west-2"),
	},
})

globalTable := dynamodb.NewTableV2(stack, jsii.String("GlobalTable"), &TablePropsV2{
	PartitionKey: &Attribute{
		Name: jsii.String("pk"),
		Type: dynamodb.AttributeType_STRING,
	},
	Replicas: []ReplicaTableProps{
		&ReplicaTableProps{
			Region: jsii.String("us-east-1"),
		},
	},
})

globalTable.AddReplica(&ReplicaTableProps{
	Region: jsii.String("us-east-2"),
	DeletionProtection: jsii.Boolean(true),
})
```

## Properties

- `contributorInsights`: boolean = false — use `contributorInsightsSpecification` instead

- `contributorInsightsSpecification`: [ContributorInsightsSpecification](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_dynamodb.ContributorInsightsSpecification.html) — Whether CloudWatch contributor insights is enabled and what mode is selected.

  **Default:** contributor insights is not enabled

- `deletionProtection`: boolean = false — Whether deletion protection is enabled.

- `globalSecondaryIndexOptions`: { [key: string]: [ReplicaGlobalSecondaryIndexOptions](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_dynamodb.ReplicaGlobalSecondaryIndexOptions.html) } — Options used to configure global secondary index properties.

  **Default:** inherited from the primary table

- `kinesisStream`: [IStream](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_kinesis.IStream.html) — Kinesis Data Stream to capture item level changes.

  **Default:** no Kinesis Data Stream

- `maxReadRequestUnits`: number — The maximum read request units.

  **Default:** inherited from the primary table

  Note: This can only be configured if the primary table billing is PAY_PER_REQUEST.

- `pointInTimeRecovery`: boolean — use `pointInTimeRecoverySpecification` instead

  **Default:** false - point in time recovery is not enabled.

- `pointInTimeRecoverySpecification`: [PointInTimeRecoverySpecification](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_dynamodb.PointInTimeRecoverySpecification.html) — Whether point-in-time recovery is enabled and recoveryPeriodInDays is set.

  **Default:** point in time recovery is not enabled.

- `readCapacity`: [Capacity](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_dynamodb.Capacity.html) — The read capacity.

  **Default:** inherited from the primary table

  Note: This can only be configured if the primary table billing is provisioned.

- `region`: string (required) — The region that the replica table will be created in.

- `resourcePolicy`: [PolicyDocument](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_iam.PolicyDocument.html) — Resource policy to assign to DynamoDB Table.

  **Default:** No resource policy statements are added to the created table.

- `streamResourcePolicy`: [PolicyDocument](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_iam.PolicyDocument.html) — Resource policy to assign to DynamoDB Stream.

  **Default:** No resource policy statements are added to the stream.

- `tableClass`: [TableClass](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_dynamodb.TableClass.html) = TableClass.STANDARD — The table class.

- `tags`: [CfnTag](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.CfnTag.html)[] — Tags to be applied to the primary table (default replica table).

  **Default:** no tags
