Akhilesh
Akhilesh

Reputation: 93

How to permanently delete latest version of S3 Object using Nodejs

I have an S3 bucket with versioning enabled. Whenever i make a deleteObject call using the aws sdk for javascript it will mark the object with a delete marker. As specified in the documentation, for deleting s3 object permanently, the "VersionId" should be specified.
From S3 documentation for making the delete call:

var params = {
     Bucket: 'STRING_VALUE', /* required */
     Key: 'STRING_VALUE', /* required */
     BypassGovernanceRetention: true || false,
     MFA: 'STRING_VALUE',
     RequestPayer: requester,
     VersionId: 'STRING_VALUE'
};
s3.deleteObject(params, function(err, data) {
     i.f (err) console.log(err, err.stack); // an error occurred
     else     console.log(data);           // successful response
});

I want to (permanently)delete the latest version of the object. I know that, in order to do so:

The above approach requires 2 API calls (first for fetching the versions and second for deleting the object version) I have gone through several solutions and they had the same approach as specified above.
I'm trying to reduce the API calls to one.

Upvotes: 2

Views: 1901

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 269101

Nope. You'll need to make the two calls.

Upvotes: 1

Related Questions