forked from aws-samples/aws-alien-attack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenvname.sh
More file actions
executable file
·30 lines (29 loc) · 1.35 KB
/
envname.sh
File metadata and controls
executable file
·30 lines (29 loc) · 1.35 KB
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
#!/bin/bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
#
##
# Automatically creates the environment name
##
setColor=$(tput setaf 3) # Green
resetColor=$(tput sgr0) # Text reset
echo "**************************************************************"
echo "DEFINING YOUR EXCLUSIVE ENVIRONMENT NAME"
echo ""
echo "When we define the exclusive environment name all resources"
echo "in your infrastructure will have their IDs prefixed by this"
echo "environment name."
echo "This is a workaround to guarantee that this workshop can run"
echo "with multiple users under a single AWS account"
echo "**************************************************************"
echo
read -p "What are your initials? (don't use anything starting with 'AWS', 'XN', 'sthree', or any AWS service name) " initials
initials=$(echo $initials | tr -cd "[a-zA-Z0-9]\n" | tr 'A-Z' 'a-z' )
### Generating a random 6 hexadecimal digit code, like a0b1c2
randomcode=$(openssl rand -hex 3)
### Defining envname - envname will be, by default, in uppercase
envname=$(echo $initials"aaa"$randomcode | tr 'a-z' 'A-Z')
envnameLowercase=$(echo $envname | tr 'A-Z' 'a-z' )
echo export envname=$envname >> ~/.bash_profile
echo export envnameLowercase=$envnameLowercase >> ~/.bash_profile
echo "Your environment name was defined as"$setColor $envname $resetColor