Last active
February 9, 2016 21:04
-
-
Save ssummer3/fe8df2f93a9547de8d1f to your computer and use it in GitHub Desktop.
S3 HTML5 Applications
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
| aws s3 mb s3://${BUCKET} | |
| aws s3 website s3://${BUCKET} --index-document index.html --error-document index.html | |
| aws s3 sync . s3://${BUCKET} --exclude '.*' --exclude '*.md' --exclude '*.json' --delete --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers | |
| #aws s3 rm --recursive s3://${BUCKET} |
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
| tee cors.json <<EOF >/dev/null | |
| { | |
| "CORSRules": [ | |
| { | |
| "AllowedOrigins": ["*"], | |
| "AllowedHeaders": ["*"], | |
| "AllowedMethods": ["GET", "PUT", "POST", "DELETE"] | |
| } | |
| ] | |
| } | |
| EOF | |
| aws s3api put-bucket-cors --bucket ${BUCKET} --cors-configuration file://cors.json |
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
| tee policy.json <<EOF >/dev/null | |
| { | |
| "Statement": [ | |
| { | |
| "Effect": "Allow", | |
| "Principal": "*", | |
| "Action": [ | |
| "s3:GetObject" | |
| ], | |
| "Resource": "arn:aws:s3:::${BUCKET}/*" | |
| }, | |
| { | |
| "Effect": "Allow", | |
| "Principal": "*", | |
| "Action": [ | |
| "s3:ListBucket" | |
| ], | |
| "Resource": "arn:aws:s3:::${BUCKET}" | |
| } | |
| ] | |
| } | |
| EOF | |
| aws s3api put-bucket-policy --bucket ${BUCKET} --policy file://policy.json |
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
| tee website.json <<EOF >/dev/null | |
| { | |
| "IndexDocument": { | |
| "Suffix": "index.html" | |
| }, | |
| "ErrorDocument": { | |
| "Key": "index.html" | |
| }, | |
| "RoutingRules": [ | |
| { | |
| "Condition": { | |
| "HttpErrorCodeReturnedEquals": "404" | |
| }, | |
| "Redirect": { | |
| "HostName": "${BUCKET}", | |
| "ReplaceKeyPrefixWith": "#/" | |
| } | |
| } | |
| ] | |
| } | |
| EOF | |
| aws s3api put-bucket-website --bucket ${BUCKET} --website-configuration file://website.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment