# TableAttributes

Reference to a dynamodb table.

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

- Source: [`aws-dynamodb/lib/table.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-dynamodb/lib/table.ts#L626)
- Type last changed: v2.31.0 · 6 Jul 2022

## 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 tableAttributes: dynamodb.TableAttributes = {
  encryptionKey: key,
  globalIndexes: ['globalIndexes'],
  grantIndexPermissions: false,
  localIndexes: ['localIndexes'],
  tableArn: 'tableArn',
  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 = dynamodb.TableAttributes(
    encryption_key=key,
    global_indexes=["globalIndexes"],
    grant_index_permissions=False,
    local_indexes=["localIndexes"],
    table_arn="tableArn",
    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;

TableAttributes tableAttributes = TableAttributes.builder()
        .encryptionKey(key)
        .globalIndexes(List.of("globalIndexes"))
        .grantIndexPermissions(false)
        .localIndexes(List.of("localIndexes"))
        .tableArn("tableArn")
        .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 tableAttributes = new TableAttributes {
    EncryptionKey = key,
    GlobalIndexes = new [] { "globalIndexes" },
    GrantIndexPermissions = false,
    LocalIndexes = new [] { "localIndexes" },
    TableArn = "tableArn",
    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

tableAttributes := &TableAttributes{
	EncryptionKey: key,
	GlobalIndexes: []*string{
		jsii.String("globalIndexes"),
	},
	GrantIndexPermissions: jsii.Boolean(false),
	LocalIndexes: []*string{
		jsii.String("localIndexes"),
	},
	TableArn: jsii.String("tableArn"),
	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, if this table uses a customer-managed encryption key.

  **Default:** no key

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

  **Default:** no global indexes

  Note that you need to set either this property,
  or `localIndexes`,
  if you want methods like grantReadData()
  to grant permissions for indexes as well as the table itself.

- `grantIndexPermissions`: boolean = false — If set to true, grant methods always grant permissions for all indexes.

  If false is provided, grant methods grant the permissions
  only when `globalIndexes` or `localIndexes` is specified.

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

  **Default:** no local indexes

  Note that you need to set either this property,
  or `globalIndexes`,
  if you want methods like grantReadData()
  to grant permissions for indexes as well as the table itself.

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

  **Default:** no table arn

  One of this, or `tableName`, is required.

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

  **Default:** no table name

  One of this, or `tableArn`, is required.

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

  **Default:** no table stream
