| « PreviousNext » | |
![]() ![]() ![]() | Did this page help you? Yes | No | Tell us about it... |
When you configure a bucket as a website, you must make the objects that you want to serve
publicly readable. To do so, you write a bucket policy that grants everyone
s3:GetObject permission. On the website endpoint, if a user
requests an object that does not exist, Amazon S3 returns HTTP response code
404 (Not Found). If the object exists but you have not granted read
permission on the object, the website endpoint returns HTTP response code 403
(Access Denied). The user can use the response code to infer if a
specific object existsor not. If you do not want this behavior, you should not
enable website support for your bucket.
The following sample bucket policy grants everyone access to the objects in the specified folder. For more information on bucket policies, see Using Bucket Policies.
{
"Version":"2008-10-17",
"Statement":[{
"Sid":"PublicReadGetObject",
"Effect":"Allow",
"Principal": {
"AWS": "*"
},
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::example-bucket/*"
]
}
]
}
Note
The bucket policy applies only to objects owned by the bucket owner. If your bucket contains objects not owned by the bucket owner, then public READ permission on those objects should be granted using the object ACL.
You can grant public read permission to your objects by using either a bucket policy or an object ACL. To make an object publicly readable using an ACL, you grant READ permission to the AllUsers group as shown in the following grant element. You add this grant element to the object ACL. For information on managing ACLs, see Using ACLs .
<Grant>
<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="Group">
<URI>http://acs.amazonaws.com/groups/global/AllUsers</URI>
</Grantee>
<Permission>READ</Permission>
</Grant>