Skip to content

php create createBucket and to Allow Public Read Object

0

in PHP I create a Bucket with createBucket. and uploud a file putObject all workin well. I want to be able to view the file in a browser or website. but it give an Access Denied error I use the af-south-1 region. I try to use putBucketPolicy but it give an "is not authorized to perform: s3:PutBucketPolicy on resource" in the AIM I have Allow s3:PutBucketPolicy { "Sid": "BucketActions", "Effect": "Allow", "Action": [ "s3:CreateBucket", "s3:PutBucketPolicy", "s3:GetBucketPolicy", "s3:ListBucket" ], "Resource": "arn:aws:s3:::*" },

asked 9 months ago65 views
1 Answer
1
Accepted Answer

Hello.

Where are you running PHP?
If you're using a local PC, it's possible that the IAM user access key is not set correctly or that you're using the wrong user.
Also, it is possible that a bucket policy has already been set in S3 and that the "PutBucketPolicy" action is being denied by the bucket policy, so please check the S3 settings as well.

By the way, have you disabled all of the block public access settings described in the following document?
If these are not disabled, you will not be able to configure public access.
https://docs.aws.amazon.com/AmazonS3/latest/userguide/configuring-block-public-access-bucket.html

There is also a way to use CloudFront to make objects in S3 public, so I recommend you check out the following documentation:
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-restricting-access-to-s3.html

EXPERT
answered 9 months ago
AWS
SUPPORT ENGINEER
reviewed 8 months ago
  • I have to disabled all of the block public access settings (putPublicAccessBlock) and then do the putBucketPolicy Thanks

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.