aws-helper-scripts/s3-spin-up-a-bucket.sh
Nils Norman Haukås e1a2e34df0 initial commit
2018-04-27 15:44:37 +02:00

23 lines
795 B
Bash
Executable file

#!/bin/bash
# Takes a single parameter input
#
# 1. We create a user.
# 2. Then add user to group that is allowed to list buckets, nothing more.
# 3. Then we build the bucket.
# 4. Set bucket policy so it's changeable by the newly created user.
# 5. Finally we need to create an access token for the user.
BUCKETNAME=$1
./create-aws-user.sh $BUCKETNAME
# Create a bucket in Ireland, because Craft2 S3 functionality needs a little
# older authentication scheme only found in certain AWS data centers.
# Finally we add versioning because it's quite unpleasant to lose important data.
aws s3api create-bucket --bucket $BUCKETNAME \
--region eu-west-1 \
--versioning-configuration Status=Enabled
./give-user-access-to-bucket.sh $BUCKETNAME
aws iam create-access-key --user-name $BUCKETNAME