Skip to content

Instantly share code, notes, and snippets.

@hisamafahri
Last active November 29, 2021 07:24
Show Gist options
  • Save hisamafahri/4a1647a331c85090dc2fba354165b2dd to your computer and use it in GitHub Desktop.
Save hisamafahri/4a1647a331c85090dc2fba354165b2dd to your computer and use it in GitHub Desktop.

Setup Public S3 Bucket

Configure S3 Bucket

Create two buckets with name as you want *note: you can choose whatever name

Set the bucket policy

Make sure to turn off the "Block all public access" section: image

After bucket created, go to permission setting and paste this in the:

Bucket Policy

Change the <your-bucket-name> section below:

{
    "Version": "2008-10-17",
    "Statement": [
        {
            "Sid": "AllowPublicRead",
            "Effect": "Allow",
            "Principal": {
                "AWS": "*"
            },
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::<your-bucket-name>/*"
        }
    ]
}

example: "Resource": "arn:aws:s3:::my-beautiful-bucket-name/*"

CORS

[
    {
        "AllowedHeaders": [
            "*"
        ],
        "AllowedMethods": [
            "GET",
            "HEAD",
            "PUT",
            "POST",
            "DELETE"
        ],
        "AllowedOrigins": [
            "*"
        ],
        "ExposeHeaders": [
            "x-amz-server-side-encryption",
            "x-amz-request-id",
            "x-amz-id-2",
            "ETag"
        ]
    }
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment