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