Skip to content

Instantly share code, notes, and snippets.

@ssummer3
Last active February 9, 2016 21:04
Show Gist options
  • Select an option

  • Save ssummer3/fe8df2f93a9547de8d1f to your computer and use it in GitHub Desktop.

Select an option

Save ssummer3/fe8df2f93a9547de8d1f to your computer and use it in GitHub Desktop.
S3 HTML5 Applications
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}
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
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
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