Reputation: 31
I have created an S3 bucket for my organization, where I am hosting a static webpage. I want to give read-only public access to it, but deny public access overall.
I tried adding bucket policy which provides read access and blocking the public access feature under Permissions -> Block Public access section. But it is giving me Access Denied in all the scenarios.
Disable the public access but set the s3 bucket 'allow' permission with read only action to the objects from the outside:
"Action":["s3:GetObject"]
{
"Version": "2008-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "eact resource information"
}
]
}
This is what my S3 Url is taking me to:
<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>7B5968B84E5DB018</RequestId><HostId>ehRR5C0zoZU0QO0e9SdetVsa/6TrO/kIRwynpSl+L4zFiP1I6yFwtHsembeQjnP/ozdeOgRBrdg=</HostId></Error>
Upvotes: 0
Views: 2624
Reputation: 270154
To grant public access to all objects in the bucket, use this Bucket Policy:
{
"Version":"2012-10-17",
"Statement":[
{
"Sid":"PublicPermission",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::my-bucket/*"]
}
]
}
(Replace my-bucket
with the name of your bucket)
You will also need to turn off Block Public Access to allow the Bucket Policy to operate.
Upvotes: 1