2

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 versions need to be fetched.
  • Call "deleteObject" for that version with the "VersionId".

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.

  • Is there a way where i can specify a place holder for latest version in "VersionId" paramater of the request so that aws will resolve it to the latest version?
  • Is there any other way which would require one API call?
Akhilesh
  • 83
  • 10

1 Answers1

1

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

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470