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 Risposta
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
con risposta un anno fa
profile picture
ESPERTO
verificato 4 mesi fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande