-
Notifications
You must be signed in to change notification settings - Fork 0
/
bucket
executable file
·21 lines (15 loc) · 1.08 KB
/
bucket
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash
read -p "App name (lowercase, letters, numbers, hyphen only): " APP_NAME
read -p "Domain name: " DOMAIN_NAME
aws cloudformation create-stack --capabilities CAPABILITY_NAMED_IAM --stack-name ${APP_NAME}-bucket --template-body file://./bucket.json --parameters ParameterKey=ApplicationName,ParameterValue=$APP_NAME ParameterKey=DomainName,ParameterValue=$DOMAIN_NAME --output text
# wait for completion
aws cloudformation wait stack-create-complete --stack-name ${APP_NAME}-bucket --output text
# output the bucket name
echo "Bucket name:"
aws cloudformation describe-stacks --stack-name ${APP_NAME}-bucket --query 'Stacks[0].Outputs[?OutputKey==`BucketName`].OutputValue' --output text
# output the access key id
echo "Access Key ID:"
aws cloudformation describe-stacks --stack-name ${APP_NAME}-bucket --query 'Stacks[0].Outputs[?OutputKey==`BucketUserAccessKeyId`].OutputValue' --output text
# output the secret access key
echo "Secret Access Key:"
aws ssm get-parameter --name /iam/user/${APP_NAME}-bucket-user/secret-access-key --with-decryption --query Parameter.Value --output text