-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbucket
More file actions
executable file
·22 lines (16 loc) · 1.21 KB
/
bucket
File metadata and controls
executable file
·22 lines (16 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/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
SECRET_ARN=`aws cloudformation describe-stacks --stack-name ${APP_NAME}-bucket --query 'Stacks[0].Outputs[?OutputKey==\`BucketUserSecretAccessKeyARN\`].OutputValue' --output text`
echo "Secret Access Key:"
aws secretsmanager get-secret-value --query 'SecretString' --output text --secret-id $SECRET_ARN