Last active
December 26, 2015 05:49
-
-
Save mlconnor/7103477 to your computer and use it in GitHub Desktop.
Setting up a bucket for static hosting in S3.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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