Skip to content

Commit

Permalink
[v15] use Update rather than ConditionCheck in dynamodbbk AtomicWrite (
Browse files Browse the repository at this point in the history
  • Loading branch information
espadolini authored May 2, 2024
1 parent de54361 commit 9cd1caf
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/backend/dynamo/atomicwrite.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,20 @@ func (b *Backend) AtomicWrite(ctx context.Context, condacts []backend.Conditiona
return "", trace.Wrap(err)
}

txnItem.ConditionCheck = &dynamodb.ConditionCheck{
// morally this should be a dynamodb.ConditionCheck transaction
// item, but condition checks use the dynamodb:ConditionCheckItem
// permission, which wasn't documented in v15 and earlier; an update
// operation in a TransactWrite costs the same in terms of write
// capacity as a condition check, so we update the potentially
// non-existent item by removing a top-level field that we know
// doesn't exist anyway
txnItem.Update = &dynamodb.Update{
ConditionExpression: condExpr,
ExpressionAttributeValues: exprAttrValues,
Key: av,
TableName: tableName,

UpdateExpression: aws.String("REMOVE NotAField"),
}

case backend.KindPut:
Expand Down

0 comments on commit 9cd1caf

Please sign in to comment.