5
votes

An error occurred (AccessDenied) when calling the DeleteBucket operation: Access Denied

[ec2-user@ip-172-31-31-84 temp]$ aws s3 rb --force s3://elasticbeanstalk-us-east-2-719330736384/

remove_bucket failed: s3://elasticbeanstalk-us-east-2-719330736384/ An error occurred (AccessDenied) when calling the DeleteBucket operation: Access Denied

2
What is the question?Dusan Bajic
How do i remove bucket in s3 using awscli ?Naresh Etikala
The error message clearly says you do not have privileges to delete the bucket. Talk to your IAM administrator.helloV

2 Answers

18
votes

Elastic Beanstalk Bucket policies by default denies deletion.

Go to the bucket's policy (bucket --> properties --> permissions --> edit bucket policy)

Then find this statement

{
"Sid": xxxxxxxxx,
"Effect": "Deny",
"Principal": {
"AWS": "*"
},
"Action": "s3:DeleteBucket",
"Resource": xxxxxxxxxx
}

Change the Effect from Deny to Allow.

Save the change to the Bucket Policy.

Try deleting again.

0
votes

The solution of @J. Prashar didn't work for me. You just need to go to bucket --> properties --> permissions --> edit bucket policy and delete the policy. Then, you can delete the bucket without any problem.