Skip to content

Instantly share code, notes, and snippets.

@tekwiz
Last active December 11, 2015 00:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tekwiz/4515403 to your computer and use it in GitHub Desktop.
Save tekwiz/4515403 to your computer and use it in GitHub Desktop.
S3 Website Bucket Policy

AWS S3 Snippets

Changelog

December 31, 2013

  • Reformatted gist organization.
  • Moved default index & error files from Gist 501095ad25beb6f9300a.

October 14, 2013

  • Removed DenyPrivateUploads statement from bucket policy. This is now causing problems uploading files to my S3 website buckets. The PublicWebsite statement appears to be taking care of defaulting permissions properly.
  • Added this Changelog.
  • Changed terminology to be consistent with S3: CORS bucket "policy" is "configuration".
  • Changed file names to be prefixed by a number to arrange them logically in the GitHub Gist frontend.

February 8, 2013

  • Added CORS bucket policy.

January 11, 2013

  • Created bucket policy.
{
"Version": "2008-10-17",
"Id": "Policy{{ bucketName }}",
"Statement": [
{
"Sid": "PublicWebsite",
"Effect": "Allow",
"Principal": { "AWS": "*" },
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::{{ bucketName }}/*"
}
]
}
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Not Found</title>
<style type="text/css">
body {
margin: 2em 1em 1em 1em;
font-family: Arial, Helvetica, sans-serif;
text-align: center;
}
</style>
</head>
<body>
<header>
<h1>
Not Found
</h1>
</header>
</body>
</html>
doctype html
html
head
meta charset="utf-8"
title Not Found
css:
body {
margin: 2em 1em 1em 1em;
font-family: Arial, Helvetica, sans-serif;
text-align: center;
}
body
header
h1 Not Found
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>{{ title }}</title>
<style type="text/css">
body {
margin: 2em 1em 1em 1em;
font-family: Arial, Helvetica, sans-serif;
text-align: center;
}
</style>
</head>
<body>
<header>
<h1>
{{ title }}
</h1>
</header>
</body>
</html>
doctype html
html
head
meta charset="utf-8"
title = "{{ title }}"
css:
body {
margin: 2em 1em 1em 1em;
font-family: Arial, Helvetica, sans-serif;
text-align: center;
}
body
header
h1 = "{{ title }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment