I have 2 api calls I want to make to AWS:
- put item into s3
- write a row to DynamoDB
I'd like either both to happen, or if there's an error, neither to happen.
Is it possible to achieve that using boto3
?
CodePudding user response:
This isn't possible to do automatically. There is no facility to flag multiple actions in Boto3 as atomic. You will need to write code to check the response code, and also catch exceptions, from both of those actions, and then skip or roll-back the other action.
For example if you already successfully PUT an object to S3, but the DynamoDB insert fails, you would have to capture that failure, and then run an S3 delete operation.