Delete S3 Bucket.

There are four method which AWS mentioned in their Doc.
  1. Delete From Console.
  2. Use third party tool or AWS CLI.
  3. Use lifecycle policy.
          i)  Delete From Console:- Deleting from console only work when bucket contain less than 100,000 objects but our bucket contain more than 100,000 object.

          ii)   Use third party tool or AWS CLI:- 
Can use s3cmd for deleting bucket which is a third party tool. We use AWS CLI provided by AWS. 
                      Run  this command 
e.g:- 
                          AWS s3 rb s3://<bucket-name>  --force  
                          AWS s3 rm s3://<bucket-name>  --recursive
                The first command is used for delete object and as well as bucket also.  It create delete marker object if we have versioning enable for bucket. So only use this command when bucket doesn't have versioning enable because it delete only current version, not previous version and create delete marker file/object.

       iii). Use life cycle policy:
                        You can configure lifecycle on you bucket to expire objects, Amazon S3 then delete expired objects. You can add lifecycle configuration rules to expire all or a subset of objects with a specific key name prefix. For example, to remove all objects in a bucket, you can set lifecycle rule to expire objects one day after creation.
If your bucket has versioning enabled, you can also configure the rule to expire non-current objects.

 below i attached a snapshot of lifecycle policy which we used to delete object.


      iv). Delete using the AWS SDKs:- 

For Deleting you should have AWS_ACCESS_KEY/AWS_SECRET_KEY and these key have permission for deleting object and if you are deleting version object then check that these key have action included in IAM user policy.
  "s3:DeleteObjectVersion" 


Comments

Popular posts from this blog

Enable logging in Haproxy.

Take AWS ec2 volume instance snapshot

Edit Distance Problem