Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable "delete" option for S3 objects in AWS

I am moving files from EC2 instances to AWS S3. I want to to disable the "delete" option in the AWS S3 (when an object is selected), so that the files which are copied to AWS S3 are safe and are not deleted by mistake. I want to preserve the files for at least 6 months.

like image 756
Mohit Agrawal Avatar asked Apr 06 '18 13:04

Mohit Agrawal


People also ask

How do I prevent deletion of S3 Buckets?

To prevent or mitigate future accidental deletions, consider the following features: Enable versioning to keep historical versions of an object. Enable Cross-Region Replication of objects. Enable MFA delete to require multi-factor authentication (MFA) when deleting an object version.

What S3 feature allows objects storage classes to be changed and objects deleted automatically?

Storage class for automatically optimizing data with changing or unknown access patterns. S3 Intelligent-Tiering is an Amazon S3 storage class designed to optimize storage costs by automatically moving data to the most cost-effective access tier, without performance impact or operational overhead.

Which feature of S3 can automatically delete objects?

You can set up a lifecycle rule to automatically delete objects such as log files. For more information, see Setting lifecycle configuration on a bucket.

Who can delete object S3?

Description. Removes the null version (if there is one) of an object and inserts a delete marker, which becomes the latest version of the object. If there isn't a null version, Amazon S3 does not remove any objects. To remove a specific version, you must be the bucket owner and you must use the version Id subresource.


1 Answers

It's not possible to hide that button.

But you have 2 options to block delete of objects at bucket:

  1. Attach policy to your IAM user(s) that Deny s3:DeleteObject action

or (better in my opinion):

  1. Configure bucket policy (Permissions -> Bucket Policy) that will Deny s3:DeleteObject action

For example, bucket policy can look like this:

{
    "Version": "2012-10-17",
    "Id": "<...>",
    "Statement": [
        {
            "Effect": "Deny",
            "Principal": "*",
            "Action": "s3:DeleteObject",
            "Resource": "arn:aws:s3:::<YOUR BUCKET NAME>/*"
        },
        <...>
    ]
}

I checked that, if I selected object and clicked Delete button it look like this:

enter image description here

like image 177
Michał Z. Avatar answered Nov 01 '22 15:11

Michał Z.