[installer] Fix #8 - limit prefix length to 5 chars

This commit is contained in:
Paul Schoenfelder 2018-04-30 14:28:59 -04:00
parent 5effd8bcdd
commit c87d08dab9
2 changed files with 4 additions and 4 deletions

View File

@ -14,7 +14,7 @@ For other platforms, or if you don't have Homebrew installed, please see the fol
You will also need the following information for the installer:
- A unique prefix to use for provisioned resources
- A unique prefix to use for provisioned resources (5 alphanumeric chars or less)
- A password to use for the RDS database
- The name of a IAM key pair to use for EC2 instances, if you provide a name which
already exists it will be used, otherwise it will be generated for you.

View File

@ -233,7 +233,7 @@ function destroy() {
function provision() {
# If INFRA_PREFIX has not been set yet, request it from user
if [ -z "$INFRA_PREFIX" ]; then
DEFAULT_INFRA_PREFIX=$(tr -dc 'a-z0-9' < /dev/urandom | fold -w 8 | head -n 1)
DEFAULT_INFRA_PREFIX=$(tr -dc 'a-z0-9' < /dev/urandom | fold -w 5 | head -n 1)
warnb << EOF
# Infrastructure Prefix
@ -254,12 +254,12 @@ EOF
fi
fi
if ! echo "$INFRA_PREFIX" | grep -E '^[a-z0-9]{3,24}$'; then
if ! echo "$INFRA_PREFIX" | grep -E '^[a-z0-9]{3,5}$'; then
errorb << EOF
The prefix '$INFRA_PREFIX' is invalid!
It must consist only of the lowercase characters a-z and digits 0-9,
and must be between 3 and 24 characters long.
and must be between 3 and 5 characters long.
EOF
fi