Skip to content

Instantly share code, notes, and snippets.

@mlconnor
Last active December 26, 2015 05:49
Show Gist options
  • Save mlconnor/7103477 to your computer and use it in GitHub Desktop.
Save mlconnor/7103477 to your computer and use it in GitHub Desktop.
Setting up a bucket for static hosting in S3.
1. Go into the Amazon Web Console and create a new bucket.
2. Go into the console and enable "static hosting" for the bucket.
3. Setup am index doc and an error doc for the bucket.
4. Set the config file for the bucket. This is an example and you would need to modify this stuff.
#here is an example config file for the bucket
<RoutingRules>
<RoutingRule>
<Condition>
<KeyPrefixEquals>docs/</KeyPrefixEquals>
</Condition>
<Redirect>
<ReplaceKeyPrefixWith>documents/</ReplaceKeyPrefixWith>
</Redirect>
</RoutingRule>
<RoutingRule>
<Condition>
<KeyPrefixEquals>images/</KeyPrefixEquals>
</Condition>
<Redirect>
<ReplaceKeyWith>folderdeleted.html</ReplaceKeyWith>
</Redirect>
</RoutingRule>
</RoutingRules>
5. Setup global read permissions for the bucket. You will need to change the bucket name below.
#here is the bucket policy to give people read permissions
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AddPerm",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::BUCKET_NAME/*"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment