S3 Configuration - RyanShahidi/Django-Nuxt-Docker-AWS-Cookiecutter GitHub Wiki
- Click Create Bucket
- Set appropriate region and bucket name
- Allow all public access since this will be for public files. Note that this is insecure and a security vulnerability
- Open the newly created bucket, click permissions. For bucket policy add the following. Be sure to replace BUCKETNAME with the appropriate bucket name.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::BUCKETNAME/*"
}
]
}
- Now click CORS configuration and add the following:
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>Authorization</AllowedHeader>
</CORSRule>
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>HEAD</AllowedMethod>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>DELETE</AllowedMethod>
<ExposeHeader>ETag</ExposeHeader>
<ExposeHeader>x-amz-meta-custom-header</ExposeHeader>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
- To create an endpoint that is easy to access, we need to turn on static website hosting. To do this go to the properties tab and click the Static Website Hosting card. Then select Use this bucket to host a website and just enter the suggested details.