Certopolis

AWS Certified CloudOps Engineer – Associate

S3 Versioning, delete markers and MFA delete explained

The Amazon S3 User Guide says that in a versioning-enabled bucket a delete without a version ID does not remove the object. S3 adds a delete marker, which becomes the current version, and the earlier versions stay. A bucket can be unversioned, versioning-enabled or versioning-suspended, and once enabled it can never return to unversioned.

What does a delete do in a versioned bucket?

A simple DELETE request, one that names no version ID, makes S3 insert a delete marker. The marker has a key and a version ID but no data. It becomes the current version, so S3 behaves as if the object is gone.

A GET without a version ID then returns 404 (Not Found) with the header x-amz-delete-marker: true. The earlier versions are still stored. A GET that names a version ID retrieves that specific version, so an older version can be read without touching the marker.

Overwriting an object creates a new version in the same way. Each version is a whole object and is billed as one. Delete markers and other versions are listed only by ListObjectVersions.

What changes when versioning is suspended?

Objects stored before versioning was enabled have a version ID of null. Enabling versioning does not change them; it changes how S3 handles later requests.

Suspending versioning stops the bucket from accruing new versions and leaves existing versions as they are. Every object stored after that gets the version ID null. If a null version of that key already exists, the new object overwrites its contents. Versions with real version IDs are not overwritten.

So in a suspended bucket, an object that only ever had a null version can be lost to an overwrite, while an object that gained versions during the enabled period keeps them.

Who can turn on MFA delete?

MFA delete adds a second factor to two operations: changing the versioning state of the bucket and permanently deleting an object version. The request must carry the security credentials plus the device serial number, a space and the six-digit code.

Only the bucket owner (the root account) can enable MFA delete. It cannot be enabled in the AWS Management Console; you must use the AWS CLI or the API. It is set through the same versioning configuration as the bucket's versioning status. MFA delete cannot be used with lifecycle configurations.

Where the exam catches people

  • Believing a delete in a versioned bucket removes the data: a delete without a version ID only adds a delete marker.
  • Believing suspending versioning removes old versions or makes the bucket unversioned: existing versions stay, and a bucket never returns to unversioned.
  • Believing a suspended bucket still protects every overwrite: new uploads get the null version ID and overwrite an existing null version.
  • Trying to enable MFA delete in the console as an IAM administrator: only the bucket owner's root user can enable it, through the CLI or API.
  • Reading a 404 on a versioned object as data loss: check for x-amz-delete-marker: true and list the versions.

Written from these sources

Try 3 questions on this

Pick an answer to see why each option is right or wrong.

  1. An S3 bucket was unversioned for years before S3 Versioning was enabled in May. In September, versioning was suspended. Last week a job overwrote rates.csv, which had not changed since before May. The original file cannot be found, yet files edited between May and September still have earlier versions. What is a reason for this issue?

    Right. In the game that’s Renown for your Reliability and Business Continuity building.

    Not that one: D is right. In the game your Reliability and Business Continuity building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    The files edited from May to September have real version IDs, which the suspension did not touch.

    Written from docs.aws.amazon.com/AmazonS3/latest/userguide/AddingObjectstoVersionSuspendedBuckets.html

  2. An auditor needs the contents of invoice-0417.pdf as they were before a user deleted it last week. The object is in an S3 bucket that has had versioning enabled since it was created, and nothing has been written to that key since. The bucket and its objects must not be changed. Which action should the SysOps administrator take to meet this requirement?

    Right. In the game that’s Renown for your Reliability and Business Continuity building.

    Not that one: B is right. In the game your Reliability and Business Continuity building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    A GET that names the earlier version's ID reads that version directly, without removing the marker or changing the bucket.

    Written from docs.aws.amazon.com/AmazonS3/latest/userguide/DeleteMarker.html

  3. An audit requires MFA delete on an S3 bucket that holds versioned payroll exports. An IAM administrator who signs in with MFA opened the bucket's versioning settings in the Amazon S3 console and found no way to turn it on. MFA is set up for the account's root user. Which action should the SysOps administrator take to meet this requirement?

    Right. In the game that’s Renown for your Reliability and Business Continuity building.

    Not that one: D is right. In the game your Reliability and Business Continuity building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    The root user's credentials together with the serial number and current code of its MFA device, passed to put-bucket-versioning, meet both.

    Written from docs.aws.amazon.com/AmazonS3/latest/userguide/MultiFactorAuthenticationDelete.html

Ask for something