Claim it, or fail
A ConditionExpression lets a write happen only if the data still allows it.
Why
A PutItem normally overwrites whatever shares its key. A ConditionExpression guards it: the write happens only if the condition holds at the instant it runs, atomically, with no read-first race for two callers to lose.
Claim a free callsign and attribute_not_exists(pk) passes. Claim one alice already holds and the engine rejects the write with a ConditionalCheckFailedException, leaving her record untouched. Read it back to confirm. This is how you register something exactly once.
A condition turns a blind write into a guarded one. attribute_not_exists is a first-writer-wins claim, enforced at write time.
Try it. Then change it.
Predict what each request will do. Run it, inspect the response, then change a value in the workbench and try again.
attribute_not_exists(pk) means 'only if nobody holds this'. The callsign is free, so the write lands.
The same condition against m0abc, which alice already holds. The engine rejects it: ConditionalCheckFailedException.
Read m0abc back: still alice. The rejected claim changed nothing.
Built on this
- Idempotency Keys - Have we handled this request already?
- Stock Counter - Can we fulfil this order?
- Fleet Registry - What’s happening across the fleet?
- Account Ledger - What moved through this account?
attribute_not_exists(pk) means 'only if nobody holds this'. The callsign is free, so the write lands.
Choose an access pattern above, or build your own request. See what comes back and what it costs.