Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adds dynamodb:ConditionCheckItem permission to dynamodb construct #340

Merged

Conversation

cmcnicholas
Copy link
Contributor

Closes #339

Without this IAM permission, transacted writes in dynamodb using the ConditionCheck feature are disallowed.

See:

https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ConditionCheck.html

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/transaction-apis-iam.html

Example usage:

After this change you would be able to make use of ConditionCheck in transacted writes e.g.

client.send(
  new TransactWriteCommand({
    TransactItems: [
      // checks an item condition is successful
      {
        ConditionCheck: {
          TableName: environment.tableName,
          Key: {
            PK: 'somepk',
            SK: 'somesk',
          },
          ConditionExpression: 'attribute_exists(PK)',
        },
      },
      // and writes a record in 1 transaction ensuring consistency
      {
        Put: {
          TableName: environment.tableName,
          Item: someItem,
        },
      }
    ]
  }));

@mnapoli
Copy link
Member

mnapoli commented Jun 16, 2023

Thanks!

@mnapoli mnapoli merged commit 72c175f into getlift:master Jun 16, 2023
@cmcnicholas cmcnicholas deleted the fix/dynamo-db-condition-check-item-iam branch June 16, 2023 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DynamoDB IAM policy doesn't include dynamodb:ConditionCheck
2 participants