Mohit Agrawal
Mohit Agrawal

Reputation: 323

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.

Upvotes: 8

Views: 10848

Answers (2)

Saradindu Sengupta
Saradindu Sengupta

Reputation: 11

This is quite a late entry but it might help someone in future. Another option can be to use S3 object lock but the downside is it only works with versioning enabled and to enable version lock on already created buckets you have to reach out to AWS technical support. This effectively applies WORM policy on every object in the whole bucket and prevent anyone to make modification including the owner. The policy period can be set up later after the creation of the bucket. S3 object lock

Upvotes: 0

Michał Z.
Michał Z.

Reputation: 1392

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

Upvotes: 20

Related Questions