söndag 5 maj 2013

Create policy for S3 bucket to prevent accidental deletion.


Create policy to not delete bucket for everyone(prevent accidental deletion):
{
  "Version": "2008-10-17",
  "Id": "a unique policy id",
  "Statement": [
   {
    "Sid": "a stmnt ID",
    "Effect": "Deny",
    "Principal": {"AWS": "*"},
    "Action": ["s3:DeleteBucket","s3:DeleteBucketWebsite"],
    "Resource": "arn:aws:s3:::<bucket-name>"
   }]
}
}

Rationale: 
In order to prevent accidental deletion of a bucket in dev, test or prod environments when
developing scripts etc - all buckets could have this policy set by default, so a deletion requires two actions, change policy, then delete lowering the risk of accidental error.