or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

backup-restore.mddata-operations.mdglobal-tables.mdimport-export.mdindex.mdpartiql.mdtable-management.mdtransactions.md

table-management.mddocs/

0

# Table Management

1

2

Complete table lifecycle management including creation, modification, deletion, and monitoring. This covers all aspects of managing DynamoDB tables from initial setup through ongoing maintenance and optimization.

3

4

## Capabilities

5

6

### Create Table

7

8

Creates a new DynamoDB table with specified attributes, key schema, and configuration.

9

10

```java { .api }

11

/**

12

* Creates a new table for your account

13

* @param request - The request containing table definition and configuration

14

* @return Response containing table description and creation status

15

*/

16

CreateTableResponse createTable(CreateTableRequest request);

17

18

class CreateTableRequest {

19

static Builder builder();

20

21

/** An array of attributes that describe the key schema for the table and indexes */

22

List<AttributeDefinition> attributeDefinitions();

23

Builder attributeDefinitions(Collection<AttributeDefinition> attributeDefinitions);

24

25

/** The name of the table to create */

26

String tableName();

27

Builder tableName(String tableName);

28

29

/** Specifies the attributes that make up the primary key for a table or an index */

30

List<KeySchemaElement> keySchema();

31

Builder keySchema(Collection<KeySchemaElement> keySchema);

32

33

/** One or more local secondary indexes (the maximum is 5) to be created on the table */

34

List<LocalSecondaryIndex> localSecondaryIndexes();

35

Builder localSecondaryIndexes(Collection<LocalSecondaryIndex> localSecondaryIndexes);

36

37

/** One or more global secondary indexes (the maximum is 20) to be created on the table */

38

List<GlobalSecondaryIndex> globalSecondaryIndexes();

39

Builder globalSecondaryIndexes(Collection<GlobalSecondaryIndex> globalSecondaryIndexes);

40

41

/** Controls how you are charged for read and write throughput */

42

BillingMode billingMode();

43

Builder billingMode(BillingMode billingMode);

44

45

/** Represents the provisioned throughput settings for a specified table or index */

46

ProvisionedThroughput provisionedThroughput();

47

Builder provisionedThroughput(ProvisionedThroughput provisionedThroughput);

48

49

/** The settings for DynamoDB Streams on the table */

50

StreamSpecification streamSpecification();

51

Builder streamSpecification(StreamSpecification streamSpecification);

52

53

/** Represents the settings used to enable server-side encryption */

54

SSESpecification sseSpecification();

55

Builder sseSpecification(SSESpecification sseSpecification);

56

57

/** A list of key-value pairs to label the table */

58

List<Tag> tags();

59

Builder tags(Collection<Tag> tags);

60

61

/** The table class of the new table */

62

TableClass tableClass();

63

Builder tableClass(TableClass tableClass);

64

65

/** Indicates whether deletion protection is to be enabled (true) or disabled (false) on the table */

66

Boolean deletionProtectionEnabled();

67

Builder deletionProtectionEnabled(Boolean deletionProtectionEnabled);

68

69

/** The resource policy document to attach to the specified table */

70

String resourcePolicy();

71

Builder resourcePolicy(String resourcePolicy);

72

}

73

74

class AttributeDefinition {

75

static Builder builder();

76

77

/** A name for the attribute */

78

String attributeName();

79

Builder attributeName(String attributeName);

80

81

/** The data type for the attribute */

82

ScalarAttributeType attributeType();

83

Builder attributeType(ScalarAttributeType attributeType);

84

}

85

86

class KeySchemaElement {

87

static Builder builder();

88

89

/** The name of a key attribute */

90

String attributeName();

91

Builder attributeName(String attributeName);

92

93

/** The role that this key attribute will assume */

94

KeyType keyType();

95

Builder keyType(KeyType keyType);

96

}

97

98

class ProvisionedThroughput {

99

static Builder builder();

100

101

/** The maximum number of strongly consistent reads consumed per second */

102

Long readCapacityUnits();

103

Builder readCapacityUnits(Long readCapacityUnits);

104

105

/** The maximum number of writes consumed per second */

106

Long writeCapacityUnits();

107

Builder writeCapacityUnits(Long writeCapacityUnits);

108

}

109

110

class GlobalSecondaryIndex {

111

static Builder builder();

112

113

/** The name of the global secondary index */

114

String indexName();

115

Builder indexName(String indexName);

116

117

/** The complete key schema for a global secondary index */

118

List<KeySchemaElement> keySchema();

119

Builder keySchema(Collection<KeySchemaElement> keySchema);

120

121

/** Represents attributes that are copied (projected) from the table into the index */

122

Projection projection();

123

Builder projection(Projection projection);

124

125

/** Represents the provisioned throughput settings for the specified global secondary index */

126

ProvisionedThroughput provisionedThroughput();

127

Builder provisionedThroughput(ProvisionedThroughput provisionedThroughput);

128

129

/** Represents the settings for on-demand scaling */

130

OnDemandThroughput onDemandThroughput();

131

Builder onDemandThroughput(OnDemandThroughput onDemandThroughput);

132

}

133

134

class CreateTableResponse {

135

/** Represents the properties of the table */

136

TableDescription tableDescription();

137

}

138

```

139

140

**Usage Example:**

141

142

```java

143

import software.amazon.awssdk.services.dynamodb.DynamoDbClient;

144

import software.amazon.awssdk.services.dynamodb.model.*;

145

import java.util.List;

146

147

DynamoDbClient client = DynamoDbClient.builder().build();

148

149

// Create a table with both hash and range key

150

CreateTableResponse response = client.createTable(CreateTableRequest.builder()

151

.tableName("Orders")

152

.attributeDefinitions(List.of(

153

AttributeDefinition.builder()

154

.attributeName("customerId")

155

.attributeType(ScalarAttributeType.S)

156

.build(),

157

AttributeDefinition.builder()

158

.attributeName("orderDate")

159

.attributeType(ScalarAttributeType.S)

160

.build(),

161

AttributeDefinition.builder()

162

.attributeName("orderId")

163

.attributeType(ScalarAttributeType.S)

164

.build()

165

))

166

.keySchema(List.of(

167

KeySchemaElement.builder()

168

.attributeName("customerId")

169

.keyType(KeyType.HASH)

170

.build(),

171

KeySchemaElement.builder()

172

.attributeName("orderDate")

173

.keyType(KeyType.RANGE)

174

.build()

175

))

176

.globalSecondaryIndexes(List.of(

177

GlobalSecondaryIndex.builder()

178

.indexName("OrderIdIndex")

179

.keySchema(List.of(

180

KeySchemaElement.builder()

181

.attributeName("orderId")

182

.keyType(KeyType.HASH)

183

.build()

184

))

185

.projection(Projection.builder()

186

.projectionType(ProjectionType.ALL)

187

.build())

188

.build()

189

))

190

.billingMode(BillingMode.PAY_PER_REQUEST) // On-demand billing

191

.streamSpecification(StreamSpecification.builder()

192

.streamEnabled(true)

193

.streamViewType(StreamViewType.NEW_AND_OLD_IMAGES)

194

.build())

195

.sseSpecification(SSESpecification.builder()

196

.enabled(true)

197

.sseType(SSEType.KMS)

198

.build())

199

.deletionProtectionEnabled(true) // Enable deletion protection

200

.tags(List.of(

201

Tag.builder().key("Environment").value("Production").build(),

202

Tag.builder().key("Application").value("OrderSystem").build()

203

))

204

.build());

205

206

TableDescription table = response.tableDescription();

207

System.out.println("Table created: " + table.tableName());

208

System.out.println("Status: " + table.tableStatus());

209

System.out.println("ARN: " + table.tableArn());

210

```

211

212

### Describe Table

213

214

Retrieves information about a table including its current status, configuration, and metadata.

215

216

```java { .api }

217

/**

218

* Returns information about the table, including the current status, creation date and time, and table size

219

* @param request - The request containing table name

220

* @return Response containing complete table description

221

*/

222

DescribeTableResponse describeTable(DescribeTableRequest request);

223

224

class DescribeTableRequest {

225

static Builder builder();

226

227

/** The name of the table to describe */

228

String tableName();

229

Builder tableName(String tableName);

230

}

231

232

class DescribeTableResponse {

233

/** Represents the properties of the table */

234

TableDescription table();

235

}

236

237

class TableDescription {

238

/** An array of AttributeDefinition objects */

239

List<AttributeDefinition> attributeDefinitions();

240

241

/** The name of the table */

242

String tableName();

243

244

/** The primary key structure for the table */

245

List<KeySchemaElement> keySchema();

246

247

/** The current state of the table */

248

TableStatus tableStatus();

249

250

/** The date and time when the table was created */

251

Instant creationDateTime();

252

253

/** Represents the provisioned throughput settings for the table */

254

ProvisionedThroughputDescription provisionedThroughput();

255

256

/** The total size of the specified table, in bytes */

257

Long tableSizeBytes();

258

259

/** The number of items in the specified table */

260

Long itemCount();

261

262

/** The Amazon Resource Name (ARN) that uniquely identifies the table */

263

String tableArn();

264

265

/** Unique identifier for the table that stays constant across restores */

266

String tableId();

267

268

/** Contains information about the table's Local Secondary Indexes */

269

List<LocalSecondaryIndexDescription> localSecondaryIndexes();

270

271

/** Contains the details for the table's Global Secondary Indexes */

272

List<GlobalSecondaryIndexDescription> globalSecondaryIndexes();

273

274

/** The current DynamoDB Streams configuration for the table */

275

StreamSpecification streamSpecification();

276

277

/** A timestamp when the point-in-time recovery status was last set */

278

String latestStreamLabel();

279

280

/** The Amazon Resource Name (ARN) that uniquely identifies the latest stream for this table */

281

String latestStreamArn();

282

283

/** Represents the version of global tables in use */

284

String globalTableVersion();

285

286

/** Represents replicas of the table */

287

List<ReplicaDescription> replicas();

288

289

/** Contains details for the restore */

290

RestoreSummary restoreSummary();

291

292

/** The description of the server-side encryption status on the specified table */

293

SSEDescription sseDescription();

294

295

/** Represents the properties of the table when the backup was created */

296

ArchivalSummary archivalSummary();

297

298

/** Contains information about the table class */

299

TableClassSummary tableClassSummary();

300

301

/** Indicates whether deletion protection is enabled (true) or disabled (false) on the table */

302

Boolean deletionProtectionEnabled();

303

}

304

```

305

306

**Usage Example:**

307

308

```java

309

// Get detailed table information

310

DescribeTableResponse response = client.describeTable(DescribeTableRequest.builder()

311

.tableName("Orders")

312

.build());

313

314

TableDescription table = response.table();

315

316

System.out.println("Table: " + table.tableName());

317

System.out.println("Status: " + table.tableStatus());

318

System.out.println("Item count: " + table.itemCount());

319

System.out.println("Table size: " + table.tableSizeBytes() + " bytes");

320

System.out.println("Created: " + table.creationDateTime());

321

322

// Check provisioned throughput

323

if (table.provisionedThroughput() != null) {

324

ProvisionedThroughputDescription throughput = table.provisionedThroughput();

325

System.out.println("Read capacity: " + throughput.readCapacityUnits());

326

System.out.println("Write capacity: " + throughput.writeCapacityUnits());

327

}

328

329

// List GSIs

330

if (table.hasGlobalSecondaryIndexes()) {

331

System.out.println("Global Secondary Indexes:");

332

for (GlobalSecondaryIndexDescription gsi : table.globalSecondaryIndexes()) {

333

System.out.println(" - " + gsi.indexName() + " (" + gsi.indexStatus() + ")");

334

}

335

}

336

337

// Check if streams are enabled

338

if (table.streamSpecification() != null && table.streamSpecification().streamEnabled()) {

339

System.out.println("Streams enabled: " + table.streamSpecification().streamViewType());

340

System.out.println("Stream ARN: " + table.latestStreamArn());

341

}

342

```

343

344

### Update Table

345

346

Modifies the provisioned throughput settings, global secondary indexes, or DynamoDB Streams settings for a table.

347

348

```java { .api }

349

/**

350

* Modifies the provisioned throughput settings, global secondary indexes, or DynamoDB Streams settings for a given table

351

* @param request - The request containing table modifications

352

* @return Response containing updated table description

353

*/

354

UpdateTableResponse updateTable(UpdateTableRequest request);

355

356

class UpdateTableRequest {

357

static Builder builder();

358

359

/** An array of attributes that describe the key schema for the table and indexes */

360

List<AttributeDefinition> attributeDefinitions();

361

Builder attributeDefinitions(Collection<AttributeDefinition> attributeDefinitions);

362

363

/** The name of the table to be updated */

364

String tableName();

365

Builder tableName(String tableName);

366

367

/** Controls how you are charged for read and write throughput */

368

BillingMode billingMode();

369

Builder billingMode(BillingMode billingMode);

370

371

/** The new provisioned throughput settings for the specified table */

372

ProvisionedThroughput provisionedThroughput();

373

Builder provisionedThroughput(ProvisionedThroughput provisionedThroughput);

374

375

/** An array of one or more global secondary indexes for the table */

376

List<GlobalSecondaryIndexUpdate> globalSecondaryIndexUpdates();

377

Builder globalSecondaryIndexUpdates(Collection<GlobalSecondaryIndexUpdate> globalSecondaryIndexUpdates);

378

379

/** Represents the DynamoDB Streams configuration for the table */

380

StreamSpecification streamSpecification();

381

Builder streamSpecification(StreamSpecification streamSpecification);

382

383

/** The new server-side encryption settings for the specified table */

384

SSESpecification sseSpecification();

385

Builder sseSpecification(SSESpecification sseSpecification);

386

387

/** A list of replica update actions (create, delete, or update) for the table */

388

List<ReplicationGroupUpdate> replicaUpdates();

389

Builder replicaUpdates(Collection<ReplicationGroupUpdate> replicaUpdates);

390

391

/** The table class of the table to be updated */

392

TableClass tableClass();

393

Builder tableClass(TableClass tableClass);

394

395

/** Indicates whether deletion protection is to be enabled (true) or disabled (false) on the table */

396

Boolean deletionProtectionEnabled();

397

Builder deletionProtectionEnabled(Boolean deletionProtectionEnabled);

398

399

/** An Amazon EventBridge event source to assign to the table */

400

OnDemandThroughput onDemandThroughput();

401

Builder onDemandThroughput(OnDemandThroughput onDemandThroughput);

402

}

403

404

class GlobalSecondaryIndexUpdate {

405

static Builder builder();

406

407

/** The parameters required for updating a global secondary index */

408

UpdateGlobalSecondaryIndexAction update();

409

Builder update(UpdateGlobalSecondaryIndexAction update);

410

411

/** The parameters required for creating a global secondary index */

412

CreateGlobalSecondaryIndexAction create();

413

Builder create(CreateGlobalSecondaryIndexAction create);

414

415

/** The parameters required for deleting a global secondary index */

416

DeleteGlobalSecondaryIndexAction delete();

417

Builder delete(DeleteGlobalSecondaryIndexAction delete);

418

}

419

420

class UpdateTableResponse {

421

/** Represents the properties of the table */

422

TableDescription tableDescription();

423

}

424

```

425

426

**Usage Example:**

427

428

```java

429

// Update table throughput and add a new GSI

430

UpdateTableResponse response = client.updateTable(UpdateTableRequest.builder()

431

.tableName("Orders")

432

.attributeDefinitions(List.of(

433

AttributeDefinition.builder()

434

.attributeName("status")

435

.attributeType(ScalarAttributeType.S)

436

.build()

437

))

438

.globalSecondaryIndexUpdates(List.of(

439

// Add new GSI

440

GlobalSecondaryIndexUpdate.builder()

441

.create(CreateGlobalSecondaryIndexAction.builder()

442

.indexName("StatusIndex")

443

.keySchema(List.of(

444

KeySchemaElement.builder()

445

.attributeName("status")

446

.keyType(KeyType.HASH)

447

.build()

448

))

449

.projection(Projection.builder()

450

.projectionType(ProjectionType.KEYS_ONLY)

451

.build())

452

.build())

453

.build(),

454

455

// Update existing GSI throughput

456

GlobalSecondaryIndexUpdate.builder()

457

.update(UpdateGlobalSecondaryIndexAction.builder()

458

.indexName("OrderIdIndex")

459

.provisionedThroughput(ProvisionedThroughput.builder()

460

.readCapacityUnits(10L)

461

.writeCapacityUnits(5L)

462

.build())

463

.build())

464

.build()

465

))

466

.streamSpecification(StreamSpecification.builder()

467

.streamEnabled(true)

468

.streamViewType(StreamViewType.NEW_AND_OLD_IMAGES)

469

.build())

470

.build());

471

472

System.out.println("Table update initiated: " + response.tableDescription().tableName());

473

System.out.println("Status: " + response.tableDescription().tableStatus());

474

```

475

476

### Delete Table

477

478

Deletes a table and all of its items.

479

480

```java { .api }

481

/**

482

* Deletes a table and all of its items

483

* @param request - The request containing table name to delete

484

* @return Response containing final table description

485

*/

486

DeleteTableResponse deleteTable(DeleteTableRequest request);

487

488

class DeleteTableRequest {

489

static Builder builder();

490

491

/** The name of the table to delete */

492

String tableName();

493

Builder tableName(String tableName);

494

}

495

496

class DeleteTableResponse {

497

/** Represents the properties of the deleted table */

498

TableDescription tableDescription();

499

}

500

```

501

502

**Usage Example:**

503

504

```java

505

// Delete a table (ensure deletion protection is disabled first)

506

try {

507

DeleteTableResponse response = client.deleteTable(DeleteTableRequest.builder()

508

.tableName("TempTable")

509

.build());

510

511

System.out.println("Table deletion initiated: " + response.tableDescription().tableName());

512

System.out.println("Status: " + response.tableDescription().tableStatus());

513

514

} catch (ResourceInUseException e) {

515

System.err.println("Cannot delete table: " + e.getMessage());

516

// Table may have deletion protection enabled

517

} catch (ResourceNotFoundException e) {

518

System.err.println("Table not found: " + e.getMessage());

519

}

520

```

521

522

### List Tables

523

524

Returns an array of table names associated with the current account and endpoint.

525

526

```java { .api }

527

/**

528

* Returns an array of table names associated with the current account and endpoint

529

* @param request - The request containing listing options

530

* @return Response containing table names and pagination info

531

*/

532

ListTablesResponse listTables(ListTablesRequest request);

533

534

class ListTablesRequest {

535

static Builder builder();

536

537

/** The first table name that this operation will evaluate */

538

String exclusiveStartTableName();

539

Builder exclusiveStartTableName(String exclusiveStartTableName);

540

541

/** A maximum number of table names to return */

542

Integer limit();

543

Builder limit(Integer limit);

544

}

545

546

class ListTablesResponse {

547

/** The names of the tables associated with the current account at the current endpoint */

548

List<String> tableNames();

549

550

/** The name of the last table in the current page of results */

551

String lastEvaluatedTableName();

552

}

553

```

554

555

**Usage Example:**

556

557

```java

558

// List all tables with pagination

559

String lastTableName = null;

560

List<String> allTables = new ArrayList<>();

561

562

do {

563

ListTablesRequest.Builder requestBuilder = ListTablesRequest.builder()

564

.limit(10); // Limit per page

565

566

if (lastTableName != null) {

567

requestBuilder.exclusiveStartTableName(lastTableName);

568

}

569

570

ListTablesResponse response = client.listTables(requestBuilder.build());

571

allTables.addAll(response.tableNames());

572

lastTableName = response.lastEvaluatedTableName();

573

574

System.out.println("Found " + response.tableNames().size() + " tables in this page");

575

576

} while (lastTableName != null);

577

578

System.out.println("Total tables: " + allTables.size());

579

for (String tableName : allTables) {

580

System.out.println(" - " + tableName);

581

}

582

```

583

584

## Advanced Table Features

585

586

### Time to Live (TTL)

587

588

Configure automatic item expiration based on a timestamp attribute.

589

590

```java { .api }

591

/**

592

* Describes the Time to Live (TTL) status on the specified table

593

* @param request - The request containing table name

594

* @return Response containing TTL description

595

*/

596

DescribeTimeToLiveResponse describeTimeToLive(DescribeTimeToLiveRequest request);

597

598

/**

599

* Enables or disables Time to Live (TTL) for the specified table

600

* @param request - The request containing TTL specification

601

* @return Response containing TTL description

602

*/

603

UpdateTimeToLiveResponse updateTimeToLive(UpdateTimeToLiveRequest request);

604

605

class DescribeTimeToLiveRequest {

606

static Builder builder();

607

608

/** The name of the table to be described */

609

String tableName();

610

Builder tableName(String tableName);

611

}

612

613

class UpdateTimeToLiveRequest {

614

static Builder builder();

615

616

/** The name of the table to be configured */

617

String tableName();

618

Builder tableName(String tableName);

619

620

/** Represents the settings used to enable or disable Time to Live for the specified table */

621

TimeToLiveSpecification timeToLiveSpecification();

622

Builder timeToLiveSpecification(TimeToLiveSpecification timeToLiveSpecification);

623

}

624

625

class TimeToLiveSpecification {

626

static Builder builder();

627

628

/** Indicates whether TTL is to be enabled (true) or disabled (false) on the table */

629

Boolean enabled();

630

Builder enabled(Boolean enabled);

631

632

/** The name of the TTL attribute used to store the expiration time for items in the table */

633

String attributeName();

634

Builder attributeName(String attributeName);

635

}

636

```

637

638

### Continuous Backups and Point-in-Time Recovery

639

640

Configure automated backup and point-in-time recovery for tables.

641

642

```java { .api }

643

/**

644

* Checks the status of continuous backups and point in time recovery on the specified table

645

* @param request - The request containing table name

646

* @return Response containing backup status

647

*/

648

DescribeContinuousBackupsResponse describeContinuousBackups(DescribeContinuousBackupsRequest request);

649

650

/**

651

* Updates the continuous backups and point in time recovery configuration of the specified table

652

* @param request - The request containing backup configuration

653

* @return Response containing updated backup description

654

*/

655

UpdateContinuousBackupsResponse updateContinuousBackups(UpdateContinuousBackupsRequest request);

656

657

class UpdateContinuousBackupsRequest {

658

static Builder builder();

659

660

/** The name of the table */

661

String tableName();

662

Builder tableName(String tableName);

663

664

/** Represents the settings used to enable point in time recovery */

665

PointInTimeRecoverySpecification pointInTimeRecoverySpecification();

666

Builder pointInTimeRecoverySpecification(PointInTimeRecoverySpecification pointInTimeRecoverySpecification);

667

}

668

```

669

670

## Table Monitoring and Limits

671

672

### Service Limits

673

674

Check account-level service limits for DynamoDB.

675

676

```java { .api }

677

/**

678

* Returns the current provisioned-capacity limits for your AWS account in a Region

679

* @param request - The request for limits information

680

* @return Response containing current limits

681

*/

682

DescribeLimitsResponse describeLimits(DescribeLimitsRequest request);

683

684

class DescribeLimitsResponse {

685

/** The maximum total read capacity units that your account allows you to provision across all of your tables */

686

Long accountMaxReadCapacityUnits();

687

688

/** The maximum total write capacity units that your account allows you to provision across all of your tables */

689

Long accountMaxWriteCapacityUnits();

690

691

/** The maximum read capacity units that your account allows you to provision for a new table */

692

Long tableMaxReadCapacityUnits();

693

694

/** The maximum write capacity units that your account allows you to provision for a new table */

695

Long tableMaxWriteCapacityUnits();

696

}

697

```

698

699

**Usage Example:**

700

701

```java

702

// Check service limits

703

DescribeLimitsResponse limits = client.describeLimits(DescribeLimitsRequest.builder().build());

704

705

System.out.println("Account limits:");

706

System.out.println(" Max read capacity: " + limits.accountMaxReadCapacityUnits());

707

System.out.println(" Max write capacity: " + limits.accountMaxWriteCapacityUnits());

708

System.out.println("Per-table limits:");

709

System.out.println(" Max read capacity: " + limits.tableMaxReadCapacityUnits());

710

System.out.println(" Max write capacity: " + limits.tableMaxWriteCapacityUnits());

711

```

712

713

## Table Management Best Practices

714

715

### Naming Conventions

716

717

- Use descriptive, consistent names

718

- Follow your organization's naming standards

719

- Consider prefixes for environment separation (e.g., `prod-orders`, `dev-orders`)

720

721

### Schema Design

722

723

```java

724

// Good practice: Define all attributes used in key schemas

725

.attributeDefinitions(List.of(

726

AttributeDefinition.builder().attributeName("pk").attributeType(ScalarAttributeType.S).build(),

727

AttributeDefinition.builder().attributeName("sk").attributeType(ScalarAttributeType.S).build(),

728

AttributeDefinition.builder().attributeName("gsi1pk").attributeType(ScalarAttributeType.S).build()

729

))

730

```

731

732

### Security and Monitoring

733

734

```java

735

// Enable encryption and deletion protection for production tables

736

.sseSpecification(SSESpecification.builder()

737

.enabled(true)

738

.sseType(SSEType.KMS)

739

.kmsMasterKeyId("alias/my-dynamodb-key")

740

.build())

741

.deletionProtectionEnabled(true)

742

.tags(List.of(

743

Tag.builder().key("Environment").value("Production").build(),

744

Tag.builder().key("DataClassification").value("Sensitive").build()

745

))

746

```

747

748

### Cost Optimization

749

750

```java

751

// Use on-demand billing for unpredictable workloads

752

.billingMode(BillingMode.PAY_PER_REQUEST)

753

754

// Use provisioned billing with auto-scaling for predictable workloads

755

.billingMode(BillingMode.PROVISIONED)

756

.provisionedThroughput(ProvisionedThroughput.builder()

757

.readCapacityUnits(5L)

758

.writeCapacityUnits(5L)

759

.build())

760

```

761

762

## Resource Management

763

764

### Resource Policies

765

766

Manage resource-based access control policies for DynamoDB tables.

767

768

```java { .api }

769

/**

770

* Returns the resource-based policy document attached to the specified DynamoDB resource

771

* @param request - The request containing resource ARN

772

* @return Response containing resource policy

773

*/

774

GetResourcePolicyResponse getResourcePolicy(GetResourcePolicyRequest request);

775

776

class GetResourcePolicyRequest {

777

static Builder builder();

778

779

/** The Amazon Resource Name (ARN) of the DynamoDB resource to which the policy is attached */

780

String resourceArn();

781

Builder resourceArn(String resourceArn);

782

}

783

784

class GetResourcePolicyResponse {

785

/** The resource-based policy document attached to the resource */

786

String policy();

787

788

/** A unique string that represents the revision ID of the policy */

789

String revisionId();

790

}

791

792

/**

793

* Attaches a resource-based policy document to a DynamoDB resource

794

* @param request - The request containing resource ARN and policy document

795

* @return Response containing revision ID

796

*/

797

PutResourcePolicyResponse putResourcePolicy(PutResourcePolicyRequest request);

798

799

class PutResourcePolicyRequest {

800

static Builder builder();

801

802

/** The Amazon Resource Name (ARN) of the DynamoDB resource to which the policy will be attached */

803

String resourceArn();

804

Builder resourceArn(String resourceArn);

805

806

/** An Amazon Web Services resource-based policy document in JSON format */

807

String policy();

808

Builder policy(String policy);

809

810

/** A string value that you can use to conditionally update your policy */

811

String expectedRevisionId();

812

Builder expectedRevisionId(String expectedRevisionId);

813

814

/** Set this parameter to true to confirm that you want to remove your permissions to change the policy of this resource in the future */

815

Boolean confirmRemoveSelfResourceAccess();

816

Builder confirmRemoveSelfResourceAccess(Boolean confirmRemoveSelfResourceAccess);

817

}

818

819

class PutResourcePolicyResponse {

820

/** A unique string that represents the revision ID of the policy */

821

String revisionId();

822

}

823

824

/**

825

* Deletes the resource-based policy attached to the specified DynamoDB resource

826

* @param request - The request containing resource ARN

827

* @return Response containing revision ID

828

*/

829

DeleteResourcePolicyResponse deleteResourcePolicy(DeleteResourcePolicyRequest request);

830

831

class DeleteResourcePolicyRequest {

832

static Builder builder();

833

834

/** The Amazon Resource Name (ARN) of the DynamoDB resource from which the policy will be removed */

835

String resourceArn();

836

Builder resourceArn(String resourceArn);

837

838

/** A string value that you can use to conditionally delete your policy */

839

String expectedRevisionId();

840

Builder expectedRevisionId(String expectedRevisionId);

841

}

842

843

class DeleteResourcePolicyResponse {

844

/** A unique string that represents the revision ID of the policy */

845

String revisionId();

846

}

847

```

848

849

### Resource Tagging

850

851

Manage tags for DynamoDB resources for organization and cost allocation.

852

853

```java { .api }

854

/**

855

* List all tags on an Amazon DynamoDB resource

856

* @param request - The request containing resource ARN

857

* @return Response containing list of tags

858

*/

859

ListTagsOfResourceResponse listTagsOfResource(ListTagsOfResourceRequest request);

860

861

class ListTagsOfResourceRequest {

862

static Builder builder();

863

864

/** The Amazon DynamoDB resource with tags to be listed */

865

String resourceArn();

866

Builder resourceArn(String resourceArn);

867

868

/** An optional string that, if supplied, must be the name of a key */

869

String nextToken();

870

Builder nextToken(String nextToken);

871

}

872

873

class ListTagsOfResourceResponse {

874

/** The tags currently associated with the Amazon DynamoDB resource */

875

List<Tag> tags();

876

877

/** If this value is returned, there are additional results to be displayed */

878

String nextToken();

879

}

880

881

/**

882

* Associate a set of tags with an Amazon DynamoDB resource

883

* @param request - The request containing resource ARN and tags

884

* @return Response indicating success

885

*/

886

TagResourceResponse tagResource(TagResourceRequest request);

887

888

class TagResourceRequest {

889

static Builder builder();

890

891

/** Identifies the Amazon DynamoDB resource to which tags should be added */

892

String resourceArn();

893

Builder resourceArn(String resourceArn);

894

895

/** The tags to be assigned to the Amazon DynamoDB resource */

896

List<Tag> tags();

897

Builder tags(Collection<Tag> tags);

898

}

899

900

class TagResourceResponse {

901

// Empty response indicating success

902

}

903

904

/**

905

* Removes the association of tags from an Amazon DynamoDB resource

906

* @param request - The request containing resource ARN and tag keys

907

* @return Response indicating success

908

*/

909

UntagResourceResponse untagResource(UntagResourceRequest request);

910

911

class UntagResourceRequest {

912

static Builder builder();

913

914

/** The DynamoDB resource that the tags will be removed from */

915

String resourceArn();

916

Builder resourceArn(String resourceArn);

917

918

/** A list of tag keys */

919

List<String> tagKeys();

920

Builder tagKeys(Collection<String> tagKeys);

921

}

922

923

class UntagResourceResponse {

924

// Empty response indicating success

925

}

926

927

class Tag {

928

static Builder builder();

929

930

/** The key of the tag */

931

String key();

932

Builder key(String key);

933

934

/** The value of the tag */

935

String value();

936

Builder value(String value);

937

}

938

```

939

940

### Performance Monitoring

941

942

Monitor and analyze DynamoDB table performance with Contributor Insights.

943

944

```java { .api }

945

/**

946

* Returns information about contributor insights for a given table or global secondary index

947

* @param request - The request containing table name and optional index name

948

* @return Response containing contributor insights description

949

*/

950

DescribeContributorInsightsResponse describeContributorInsights(DescribeContributorInsightsRequest request);

951

952

class DescribeContributorInsightsRequest {

953

static Builder builder();

954

955

/** The name of the table to describe */

956

String tableName();

957

Builder tableName(String tableName);

958

959

/** The name of the global secondary index to describe, if applicable */

960

String indexName();

961

Builder indexName(String indexName);

962

}

963

964

class DescribeContributorInsightsResponse {

965

/** The name of the table being described */

966

String tableName();

967

968

/** The name of the global secondary index being described */

969

String indexName();

970

971

/** List of contributor insights rules associated with this table */

972

List<ContributorInsightsRule> contributorInsightsRuleList();

973

974

/** Current status of contributor insights */

975

ContributorInsightsStatus contributorInsightsStatus();

976

977

/** Timestamp of the last time the status was changed */

978

Instant lastUpdateDateTime();

979

980

/** Details about the last failure */

981

FailureException failureException();

982

}

983

984

/**

985

* Returns a list of contributor insights summaries for a table and all its global secondary indexes

986

* @param request - The request containing optional table name filter

987

* @return Response containing list of contributor insights summaries

988

*/

989

ListContributorInsightsResponse listContributorInsights(ListContributorInsightsRequest request);

990

991

class ListContributorInsightsRequest {

992

static Builder builder();

993

994

/** The name of the table for which you want to list contributor insights */

995

String tableName();

996

Builder tableName(String tableName);

997

998

/** A token to for the desired page, if there is one */

999

String nextToken();

1000

Builder nextToken(String nextToken);

1001

1002

/** Maximum number of results to return per page */

1003

Integer maxResults();

1004

Builder maxResults(Integer maxResults);

1005

}

1006

1007

class ListContributorInsightsResponse {

1008

/** A list of ContributorInsightsSummary objects */

1009

List<ContributorInsightsSummary> contributorInsightsSummaries();

1010

1011

/** A token to go to the next page if there is one */

1012

String nextToken();

1013

}

1014

1015

/**

1016

* Enables or disables contributor insights for a table or global secondary index

1017

* @param request - The request containing table configuration

1018

* @return Response containing updated contributor insights status

1019

*/

1020

UpdateContributorInsightsResponse updateContributorInsights(UpdateContributorInsightsRequest request);

1021

1022

class UpdateContributorInsightsRequest {

1023

static Builder builder();

1024

1025

/** The name of the table */

1026

String tableName();

1027

Builder tableName(String tableName);

1028

1029

/** The global secondary index name, if applicable */

1030

String indexName();

1031

Builder indexName(String indexName);

1032

1033

/** Represents the contributor insights action */

1034

ContributorInsightsAction contributorInsightsAction();

1035

Builder contributorInsightsAction(ContributorInsightsAction contributorInsightsAction);

1036

}

1037

1038

class UpdateContributorInsightsResponse {

1039

/** The name of the table */

1040

String tableName();

1041

1042

/** The name of the global secondary index, if applicable */

1043

String indexName();

1044

1045

/** The status of contributor insights */

1046

ContributorInsightsStatus contributorInsightsStatus();

1047

}

1048

```

1049

1050

### Auto Scaling Management

1051

1052

Monitor and configure auto scaling for table replicas.

1053

1054

```java { .api }

1055

/**

1056

* Describes auto scaling settings across replicas of the specified global table or global secondary index

1057

* @param request - The request containing table name

1058

* @return Response containing replica auto scaling descriptions

1059

*/

1060

DescribeTableReplicaAutoScalingResponse describeTableReplicaAutoScaling(DescribeTableReplicaAutoScalingRequest request);

1061

1062

class DescribeTableReplicaAutoScalingRequest {

1063

static Builder builder();

1064

1065

/** The name of the table */

1066

String tableName();

1067

Builder tableName(String tableName);

1068

}

1069

1070

class DescribeTableReplicaAutoScalingResponse {

1071

/** Represents the auto scaling configuration for the table */

1072

TableAutoScalingDescription tableAutoScalingDescription();

1073

}

1074

1075

class TableAutoScalingDescription {

1076

/** The name of the table */

1077

String tableName();

1078

1079

/** The current state of the table */

1080

TableStatus tableStatus();

1081

1082

/** Represents replicas of the global table */

1083

List<ReplicaAutoScalingDescription> replicas();

1084

}

1085

1086

/**

1087

* Updates auto scaling settings on your global tables at once

1088

* @param request - The request containing auto scaling updates

1089

* @return Response containing updated table auto scaling description

1090

*/

1091

UpdateTableReplicaAutoScalingResponse updateTableReplicaAutoScaling(UpdateTableReplicaAutoScalingRequest request);

1092

1093

class UpdateTableReplicaAutoScalingRequest {

1094

static Builder builder();

1095

1096

/** The name of the global table to be updated */

1097

String tableName();

1098

Builder tableName(String tableName);

1099

1100

/** The new provisioned write capacity settings for the specified table or index */

1101

AutoScalingSettingsUpdate provisionedWriteCapacityAutoScalingUpdate();

1102

Builder provisionedWriteCapacityAutoScalingUpdate(AutoScalingSettingsUpdate provisionedWriteCapacityAutoScalingUpdate);

1103

1104

/** Represents the auto scaling settings of the global secondary indexes of the replica to be updated */

1105

List<GlobalSecondaryIndexAutoScalingUpdate> globalSecondaryIndexUpdates();

1106

Builder globalSecondaryIndexUpdates(Collection<GlobalSecondaryIndexAutoScalingUpdate> globalSecondaryIndexUpdates);

1107

1108

/** Represents the auto scaling settings of replicas of the table that will be modified */

1109

List<ReplicaAutoScalingUpdate> replicaUpdates();

1110

Builder replicaUpdates(Collection<ReplicaAutoScalingUpdate> replicaUpdates);

1111

}

1112

1113

class UpdateTableReplicaAutoScalingResponse {

1114

/** Returns information about the auto scaling configuration of a table */

1115

TableAutoScalingDescription tableAutoScalingDescription();

1116

}

1117

```

1118

1119

### Kinesis Streaming Integration

1120

1121

Configure Kinesis Data Streams integration for DynamoDB tables.

1122

1123

```java { .api }

1124

/**

1125

* Returns information about the status of Kinesis streaming

1126

* @param request - The request containing table name

1127

* @return Response containing Kinesis streaming description

1128

*/

1129

DescribeKinesisStreamingDestinationResponse describeKinesisStreamingDestination(DescribeKinesisStreamingDestinationRequest request);

1130

1131

class DescribeKinesisStreamingDestinationRequest {

1132

static Builder builder();

1133

1134

/** The name of the table being described */

1135

String tableName();

1136

Builder tableName(String tableName);

1137

}

1138

1139

class DescribeKinesisStreamingDestinationResponse {

1140

/** The name of the table being described */

1141

String tableName();

1142

1143

/** The list of replica structures for the table being described */

1144

List<KinesisDataStreamDestination> kinesisDataStreamDestinations();

1145

}

1146

1147

/**

1148

* Starts table data replication to the specified Kinesis data stream at a timestamp chosen during the enable workflow

1149

* @param request - The request containing table name and stream ARN

1150

* @return Response containing streaming destination description

1151

*/

1152

EnableKinesisStreamingDestinationResponse enableKinesisStreamingDestination(EnableKinesisStreamingDestinationRequest request);

1153

1154

class EnableKinesisStreamingDestinationRequest {

1155

static Builder builder();

1156

1157

/** The name of the DynamoDB table */

1158

String tableName();

1159

Builder tableName(String tableName);

1160

1161

/** The ARN for a Kinesis data stream */

1162

String streamArn();

1163

Builder streamArn(String streamArn);

1164

1165

/** The format for the records stream */

1166

DestinationStatus destinationStatus();

1167

Builder destinationStatus(DestinationStatus destinationStatus);

1168

}

1169

1170

class EnableKinesisStreamingDestinationResponse {

1171

/** The name of the table being modified */

1172

String tableName();

1173

1174

/** The ARN for the specific Kinesis data stream */

1175

String streamArn();

1176

1177

/** The current status of replication */

1178

DestinationStatus destinationStatus();

1179

}

1180

1181

/**

1182

* Stops replication from the DynamoDB table to the Kinesis data stream

1183

* @param request - The request containing table name and stream ARN

1184

* @return Response containing streaming destination description

1185

*/

1186

DisableKinesisStreamingDestinationResponse disableKinesisStreamingDestination(DisableKinesisStreamingDestinationRequest request);

1187

1188

class DisableKinesisStreamingDestinationRequest {

1189

static Builder builder();

1190

1191

/** The name of the DynamoDB table */

1192

String tableName();

1193

Builder tableName(String tableName);

1194

1195

/** The ARN for a Kinesis data stream */

1196

String streamArn();

1197

Builder streamArn(String streamArn);

1198

}

1199

1200

class DisableKinesisStreamingDestinationResponse {

1201

/** The name of the table being modified */

1202

String tableName();

1203

1204

/** The ARN for the specific Kinesis data stream */

1205

String streamArn();

1206

1207

/** The current status of replication */

1208

DestinationStatus destinationStatus();

1209

}

1210

1211

/**

1212

* Updates the status for the specified Kinesis streaming destination

1213

* @param request - The request containing table name and stream configuration

1214

* @return Response containing updated streaming destination description

1215

*/

1216

UpdateKinesisStreamingDestinationResponse updateKinesisStreamingDestination(UpdateKinesisStreamingDestinationRequest request);

1217

1218

class UpdateKinesisStreamingDestinationRequest {

1219

static Builder builder();

1220

1221

/** The table name for the Kinesis streaming destination to be updated */

1222

String tableName();

1223

Builder tableName(String tableName);

1224

1225

/** The ARN for the Kinesis stream */

1226

String streamArn();

1227

Builder streamArn(String streamArn);

1228

1229

/** The command to update the Kinesis streaming destination configuration */

1230

UpdateKinesisStreamingConfiguration updateKinesisStreamingConfiguration();

1231

Builder updateKinesisStreamingConfiguration(UpdateKinesisStreamingConfiguration updateKinesisStreamingConfiguration);

1232

}

1233

1234

class UpdateKinesisStreamingDestinationResponse {

1235

/** The table name for the Kinesis streaming destination to be updated */

1236

String tableName();

1237

1238

/** The ARN for the Kinesis stream */

1239

String streamArn();

1240

1241

/** The status of the attempt to update the Kinesis streaming destination */

1242

DestinationStatus destinationStatus();

1243

1244

/** The command to update the Kinesis streaming destination configuration */

1245

UpdateKinesisStreamingConfiguration updateKinesisStreamingConfiguration();

1246

}

1247

```

1248

1249

### Service Discovery

1250

1251

Retrieve regional endpoint information for DynamoDB service discovery. This operation returns endpoint details that can be used for optimized regional access and endpoint caching.

1252

1253

```java { .api }

1254

/**

1255

* Returns the regional endpoint information for DynamoDB service discovery

1256

* @param request - The request for endpoint information (no parameters required)

1257

* @return Response containing list of available endpoints with caching information

1258

*/

1259

DescribeEndpointsResponse describeEndpoints(DescribeEndpointsRequest request);

1260

1261

class DescribeEndpointsRequest {

1262

static Builder builder();

1263

// Empty request - no parameters required for endpoint discovery

1264

}

1265

1266

class DescribeEndpointsResponse {

1267

/** List of available DynamoDB endpoints in the region */

1268

List<Endpoint> endpoints();

1269

}

1270

1271

class Endpoint {

1272

/** IP address or hostname of the endpoint */

1273

String address();

1274

1275

/** Endpoint cache time to live (TTL) value in minutes */

1276

Long cachePeriodInMinutes();

1277

}

1278

```

1279

1280

**Usage Example:**

1281

1282

```java

1283

import software.amazon.awssdk.services.dynamodb.DynamoDbClient;

1284

import software.amazon.awssdk.services.dynamodb.model.*;

1285

1286

DynamoDbClient client = DynamoDbClient.builder().build();

1287

1288

// Discover available DynamoDB endpoints

1289

DescribeEndpointsResponse response = client.describeEndpoints(

1290

DescribeEndpointsRequest.builder().build()

1291

);

1292

1293

// Process endpoint information

1294

response.endpoints().forEach(endpoint -> {

1295

System.out.println("Endpoint address: " + endpoint.address());

1296

System.out.println("Cache period: " + endpoint.cachePeriodInMinutes() + " minutes");

1297

});

1298

1299

// Use first endpoint for optimized regional access

1300

if (!response.endpoints().isEmpty()) {

1301

Endpoint firstEndpoint = response.endpoints().get(0);

1302

// Configure client with discovered endpoint if needed

1303

}

1304

```

1305

1306

## Additional Type Definitions

1307

1308

### Contributor Insights and Auto Scaling Enums

1309

1310

```java { .api }

1311

enum ContributorInsightsStatus {

1312

ENABLING("ENABLING"),

1313

ENABLED("ENABLED"),

1314

DISABLING("DISABLING"),

1315

DISABLED("DISABLED"),

1316

FAILED("FAILED");

1317

}

1318

1319

enum ContributorInsightsAction {

1320

ENABLE("ENABLE"),

1321

DISABLE("DISABLE");

1322

}

1323

1324

enum DestinationStatus {

1325

ENABLING("ENABLING"),

1326

ACTIVE("ACTIVE"),

1327

DISABLING("DISABLING"),

1328

DISABLED("DISABLED"),

1329

ENABLE_FAILED("ENABLE_FAILED"),

1330

DISABLE_FAILED("DISABLE_FAILED");

1331

}

1332

1333

enum GlobalTableStatus {

1334

CREATING("CREATING"),

1335

ACTIVE("ACTIVE"),

1336

DELETING("DELETING"),

1337

UPDATING("UPDATING");

1338

}

1339

1340

enum BillingMode {

1341

PROVISIONED("PROVISIONED"),

1342

PAY_PER_REQUEST("PAY_PER_REQUEST");

1343

}

1344

1345

enum ScalarAttributeType {

1346

S("S"), // String

1347

N("N"), // Number

1348

B("B"); // Binary

1349

}

1350

1351

enum KeyType {

1352

HASH("HASH"),

1353

RANGE("RANGE");

1354

}

1355

1356

enum ProjectionType {

1357

ALL("ALL"),

1358

KEYS_ONLY("KEYS_ONLY"),

1359

INCLUDE("INCLUDE");

1360

}

1361

1362

enum IndexStatus {

1363

CREATING("CREATING"),

1364

UPDATING("UPDATING"),

1365

DELETING("DELETING"),

1366

ACTIVE("ACTIVE");

1367

}

1368

1369

enum SSEType {

1370

AES256("AES256"),

1371

KMS("KMS");

1372

}

1373

1374

enum TableClass {

1375

STANDARD("STANDARD"),

1376

STANDARD_INFREQUENT_ACCESS("STANDARD_INFREQUENT_ACCESS");

1377

}

1378

```