aws Verified current stable Not installed? Cloud Infrastructure

Aws / Update Item Aws Dynamodb

Update Item Aws Dynamodb

Updates an item in an AWS DynamoDB table based on key and expression provided.

$
Terminal
aws dynamodb update-item --table-name <table_name> --key '{{{"ID": {"N": "1"}}}}' --update-expression "{SET Name = :n}" --expression-attribute-values '{{{":n": {"S": "Jane"}}}}'

When To Use

When modifying items in a production DynamoDB table during a data correction process.

Pro Tip

Use batch operations for bulk updates to avoid throttling when working with high write loads.

Anatomy of Output

Understanding the result

UpdateItem succeeded: Item updated for ID 1 Success Message

Confirming successful update of the item.

Transaction failed: ProvisionedThroughputExceededException Error Message

Occurs if write capacity is exceeded.

Request limit exceeded: Please retry Warning Message

AWS recommends retries due to limits.

Troubleshooting

Common pitfalls

An error occurred (ValidationException) when calling the UpdateItem operation: The provided key element does not match the schema

Solution: Check that the key schema matches the primary key configuration.

An error occurred (ConditionalCheckFailedException) when calling the UpdateItem operation

Solution: Verify that the update expression’s conditions are met.

An error occurred (ProvisionedThroughputExceededException) when calling the UpdateItem operation

Solution: Increase provisioned throughput or enable auto-scaling.

Command Breakdown

What each part is doing

aws
Base Command
The executable that performs this operation. Here it runs Aws before the shell applies any redirect operators.
<table_name>
table name
The value supplied for table name.
{SET Name = :n}
SET Name = :n
The value supplied for SET Name = :n.
--table-name
Command Option
Tool-specific option used by this command invocation.
--key
Command Option
Tool-specific option used by this command invocation.
--update-expression
Command Option
Tool-specific option used by this command invocation.
--expression-attribute-values
Command Option
Tool-specific option used by this command invocation.

Alternative Approaches

Comparable commands in other tools

Alternative cloud infrastructure tools for the same job.