To configure an S3 bucket with public access and enable public listing of all files, follow these steps:
Step-by-Step Guide
-
Open the S3 Console:
- Sign in to the AWS Management Console and open the Amazon S3 console.
-
Select Your Bucket:
- Click on the name of the bucket you want to make public.
-
Disable Block Public Access:
- Go to the “Permissions” tab.
- Click “Edit” under “Block public access (bucket settings)”.
- Uncheck all the boxes to disable block public access.
- Click “Save changes”.
-
Set Bucket Policy for Public Read Access:
- Scroll down to the “Bucket policy” section and click “Edit”.
- Add the following policy to allow public read access to all objects in the bucket:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": "*", "Action": [ "s3:GetObject", "s3:ListBucket" ], "Resource": [ "arn:aws:s3:::your-bucket-name", "arn:aws:s3:::your-bucket-name/*" ] } ] }
- Replace
your-bucket-name
with the name of your bucket. - Click “Save changes”.
-
Upload Files:
- Go to the “Objects” tab and upload your files if you haven’t already.
Example
If your bucket is named example-bucket
, the policy would look like this:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject",
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::example-bucket",
"arn:aws:s3:::example-bucket/*"
]
}
]
}
Verify Public Access
- After configuring the policy, you can verify public access by clicking on the object URL in the S3 console. The URL should be in the format:
http://example-bucket.s3.amazonaws.com/your-file-name
These steps will make all files in your S3 bucket publicly accessible and listable123.
Would you like help with anything else?
To access and list all files within a public S3 bucket, you can use several methods:
Using a Web Browser
-
Open the S3 Bucket URL: If the bucket is configured for public access, you can access it via a URL like
http://example-bucket.s3.amazonaws.com/
. -
Browse the Files: If directory listing is enabled, you’ll see a list of files and folders. Click on any file to download or view it.
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Name>example-bucket</Name>
<Prefix/>
<Marker/>
<MaxKeys>1000</MaxKeys>
<IsTruncated>false</IsTruncated>
<Contents>
<Key>05.png</Key>
<LastModified>2024-08-27T01:41:13.000Z</LastModified>
<ETag>"7c9370c975b23bb95e27768f752fc379"</ETag>
<Size>3880121</Size>
<Owner>
<ID>e6aa9f7e4f9bd5e82c337931a56157c6959f8405c7a3380b4e399b6c14da975d</ID>
<DisplayName>gis</DisplayName>
</Owner>
<StorageClass>STANDARD</StorageClass>
</Contents>
<Contents>
<Key>19.png</Key>
<LastModified>2024-08-22T04:06:37.000Z</LastModified>
<ETag>"6e94654212a0b0186e082448351c7b1f"</ETag>
<Size>3764950</Size>
<Owner>
<ID>e6aa9f7e4f9bd5e82c337931a56157c6959f8405c7a3380b4e399b6c14da975d</ID>
<DisplayName>gis</DisplayName>
</Owner>
<StorageClass>STANDARD</StorageClass>
</Contents>
<Contents>
<Key>error.html</Key>
<LastModified>2024-08-27T04:08:17.000Z</LastModified>
<ETag>"bc252341bb3343b66b0f9decf6d5495b"</ETag>
<Size>680</Size>
<Owner>
<ID>e6aa9f7e4f9bd5e82c337931a56157c6959f8405c7a3380b4e399b6c14da975d</ID>
<DisplayName>gis</DisplayName>
</Owner>
<StorageClass>STANDARD</StorageClass>
</Contents>
<Contents>
<Key>index.html</Key>
<LastModified>2024-08-27T04:13:00.000Z</LastModified>
<ETag>"cc0aad539c8757e4c22fe23d3283cb4f"</ETag>
<Size>811</Size>
<Owner>
<ID>e6aa9f7e4f9bd5e82c337931a56157c6959f8405c7a3380b4e399b6c14da975d</ID>
<DisplayName>gis</DisplayName>
</Owner>
<StorageClass>STANDARD</StorageClass>
</Contents>
<Contents>
<Key>test_geo_json.json</Key>
<LastModified>2024-08-27T04:36:05.000Z</LastModified>
<ETag>"4bcc06ea5e39e65469a34ef4cc7b49da"</ETag>
<Size>54156</Size>
<Owner>
<ID>e6aa9f7e4f9bd5e82c337931a56157c6959f8405c7a3380b4e399b6c14da975d</ID>
<DisplayName>gis</DisplayName>
</Owner>
<StorageClass>STANDARD</StorageClass>
</Contents>
<Contents>
<Key>time.json</Key>
<LastModified>2024-08-27T04:32:33.000Z</LastModified>
<ETag>"a90b0b59cbb2558ef2dfe1b3b8c46e89"</ETag>
<Size>36</Size>
<Owner>
<ID>e6aa9f7e4f9bd5e82c337931a56157c6959f8405c7a3380b4e399b6c14da975d</ID>
<DisplayName>gis</DisplayName>
</Owner>
<StorageClass>STANDARD</StorageClass>
</Contents>
</ListBucketResult>
标签:files,enable,s3,bucket,your,access,S3,public From: https://www.cnblogs.com/alex-bn-lee/p/18382595