# TableAttributesV2

Attributes of a DynamoDB table.

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

- 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#L533)
- Type last changed: v2.95.0 · 7 Sep 2023

## 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';
import { aws_kms as kms } from 'aws-cdk-lib';

declare const key: kms.Key;
const tableAttributesV2: dynamodb.TableAttributesV2 = {
  encryptionKey: key,
  globalIndexes: ['globalIndexes'],
  grantIndexPermissions: false,
  localIndexes: ['localIndexes'],
  tableArn: 'tableArn',
  tableId: 'tableId',
  tableName: 'tableName',
  tableStreamArn: 'tableStreamArn',
};
```

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
from aws_cdk import aws_kms as kms

# key: kms.Key

table_attributes_v2 = dynamodb.TableAttributesV2(
    encryption_key=key,
    global_indexes=["globalIndexes"],
    grant_index_permissions=False,
    local_indexes=["localIndexes"],
    table_arn="tableArn",
    table_id="tableId",
    table_name="tableName",
    table_stream_arn="tableStreamArn"
)
```

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.*;
import software.amazon.awscdk.services.kms.*;

Key key;

TableAttributesV2 tableAttributesV2 = TableAttributesV2.builder()
        .encryptionKey(key)
        .globalIndexes(List.of("globalIndexes"))
        .grantIndexPermissions(false)
        .localIndexes(List.of("localIndexes"))
        .tableArn("tableArn")
        .tableId("tableId")
        .tableName("tableName")
        .tableStreamArn("tableStreamArn")
        .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;
using Amazon.CDK.AWS.KMS;

Key key;

var tableAttributesV2 = new TableAttributesV2 {
    EncryptionKey = key,
    GlobalIndexes = new [] { "globalIndexes" },
    GrantIndexPermissions = false,
    LocalIndexes = new [] { "localIndexes" },
    TableArn = "tableArn",
    TableId = "tableId",
    TableName = "tableName",
    TableStreamArn = "tableStreamArn"
};
```

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"
import "github.com/aws/aws-cdk-go/awscdk"

var key Key

tableAttributesV2 := &TableAttributesV2{
	EncryptionKey: key,
	GlobalIndexes: []*string{
		jsii.String("globalIndexes"),
	},
	GrantIndexPermissions: jsii.Boolean(false),
	LocalIndexes: []*string{
		jsii.String("localIndexes"),
	},
	TableArn: jsii.String("tableArn"),
	TableId: jsii.String("tableId"),
	TableName: jsii.String("tableName"),
	TableStreamArn: jsii.String("tableStreamArn"),
}
```

## Properties

- `encryptionKey`: [IKey](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_kms.IKey.html) — KMS encryption key for the table.

  **Default:** no KMS encryption key

- `globalIndexes`: string[] — The name of the global indexes set for the table.

  **Default:** no global indexes

  Note: You must set either this property or `localIndexes` if you want permissions
  to be granted for indexes as well as the table itself.

- `grantIndexPermissions`: boolean = false — Whether or not to grant permissions for all indexes of the table.

  Note: If false, permissions will only be granted to indexes when `globalIndexes`
  or `localIndexes` is specified.

- `localIndexes`: string[] — The name of the local indexes set for the table.

  **Default:** no local indexes

  Note: You must set either this property or `globalIndexes` if you want permissions
  to be granted for indexes as well as the table itself.

- `tableArn`: string — The ARN of the table.

  **Default:** table arn generated using `tableName` and region of stack

  Note: You must specify this or the `tableName`.

- `tableId`: string — The ID of the table.

  **Default:** no table id

- `tableName`: string — The name of the table.

  **Default:** table name retrieved from provided `tableArn`

  Note: You must specify this or the `tableArn`.

- `tableStreamArn`: string — The stream ARN of the table.

  **Default:** no table stream ARN
