Skip to content

Commit 8c333a8

Browse files
committed
adds setup script for aws s3, #2
1 parent 34af08e commit 8c333a8

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

index.html

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<h1>360 Image Uploader</h1>
2+
<form>
3+
<input type="file" />
4+
</form>

s3-bucket.sh

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
while getopts ":b:" opt; do
4+
case $opt in
5+
b)
6+
aws s3api create-bucket --bucket $OPTARG --region eu-west-1 --create-bucket-configuration LocationConstraint=eu-west-1 --profile default
7+
aws s3 cp index.html s3://$OPTARG/index.html --profile default
8+
aws s3api put-bucket-policy --bucket $OPTARG --policy "{
9+
\"Version\": \"2012-10-17\",
10+
\"Statement\": [
11+
{
12+
\"Effect\": \"Allow\",
13+
\"Principal\": \"*\",
14+
\"Action\": \"s3:GetObject\",
15+
\"Resource\": \"arn:aws:s3:::${OPTARG}/*\"
16+
}
17+
]
18+
}" --profile default
19+
aws s3 website s3://$OPTARG --index-document index.html --profile default
20+
exit 0
21+
;;
22+
\?)
23+
echo "Invalid option: -$OPTARG" >&2
24+
exit 1
25+
;;
26+
:)
27+
echo "Option -$OPTARG requires an argument." >&2
28+
exit 1
29+
;;
30+
esac
31+
done
32+
33+
echo "Must provide bucket name with -b"
34+
exit 1

0 commit comments

Comments
 (0)