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

0

Hello,

aws CLI : aws s3api put-bucket-policy --bucket compty08052023 --policy file://public-access-policy.json

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

AmazonS3FullAccess AWS managed Directly i also tried AdministratorAccess and even to create policy like : { "Version": "2012-10-17", "Statement": [ { "Sid": "S3BucketManagement", "Effect": "Allow", "Action": [ "s3:CreateBucket", "s3:DeleteBucket", "s3:ListAllMyBuckets" ], "Resource": "" }, { "Sid": "S3BucketPolicyManagement", "Effect": "Allow", "Action": [ "s3:PutBucketPolicy", "s3:GetBucketPolicy", "s3:DeleteBucketPolicy" ], "Resource": "arn:aws:s3:::" } ] } but nothing worked. Don t know what to do.

1 個回答
0

Hello,

When I have seen Access Denied like this, it's the credentials that you are using to perform the operation and not what the policy looks like. Based on the example above you are using the default user credentials for your CLI on the host that you are using. I say that because there is no --profile option to the CLI statement above. So what access does the account that you are using have? In the documentation https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketPolicy.html. it states.

If you don't have PutBucketPolicy permissions, Amazon S3 returns a 403 Access Denied error.

Which is what you are receiving when making the call. If that's the issue, you only need to grant the account that you are using PutBucketPolicy right, or something more general like PowerUser

profile pictureAWS
已回答 1 年前
profile picture
專家
已審閱 4 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南