Make an S3 bucket public

Marking an S3 bucket as public via the AWS cli
Updated 6 months ago Published 6 months ago
Flagging a bucket with public permissions is a pretty simple affair and there are several ways in which you can achieve this goal.
The easiest of the possible path ways is you apply a policy to your bucket with global read permissions
Here is an example of the policy, This can be applied via the AWS S3 web ui or preferably via the AWS cli.
{
  "Version": "2012-10-17",
  "Statement": {
    "Action": "s3:GetObject",
    "Effect": "Allow",
    "Resource": "arn:aws:s3:::devnotnull-ui-feat-feat-migrate-to-tailwind/*",
    "Principal": "*"
  }
}
And here is an example command to apply the aforementioned policy to a bucket via the AWS cli.
aws s3api put-bucket-policy --bucket BUCKET_NAME --policy '{ "Version": "2012-10-17", "Statement": { "Action": "s3:GetObject", "Effect": "Allow", "Resource": "arn:aws:s3:::BUCKET_NAME/*", "Principal": "*" }}'
And voila your bucket should now be flagged as public and all of the bucket items will be be publicly available.
You can check to confirm that the policy has been applied to your bucket by running the `get-bucket-policy` command, an example has been provided below
aws s3api get-bucket-policy --bucket
BUCKET_NAME