Enabling S3 Object Versioning and Using It
Enabling Versioning:
- Log in to the AWS Management Console and navigate to the S3 service.
- Click on “Create Bucket” to create a new S3 bucket.
- Enter a globally unique name for the bucket and select a region for it.
- Leave the default settings for the remaining options and click on “Create Bucket”.
- Once the bucket is created, click on its name to open its details page.
- Click on the “Properties” tab and then click on “Versioning”.
- Click on “Enable Versioning” to enable versioning for the bucket.
- Now, if you upload a file with same name multiple times then multiple versions of that file would be maintained
Preventing Accidental Delete
- Click on the “Properties” tab and then click on “Versioning”.
- Scroll down to the “MFA Delete” section and select “Require MFA Delete” to enable MFA (multi-factor authentication) for object deletions.
- Save the changes and close the “Properties” tab.
- Delete the object using the AWS CLI:
aws s3 rm s3://your-bucket-name/file.txt
- You should receive an error message saying that the object cannot be deleted without MFA.