From c87d08dab94a31c6dce7eb17bc54dbf15b3fe0bb Mon Sep 17 00:00:00 2001 From: Paul Schoenfelder Date: Mon, 30 Apr 2018 14:28:59 -0400 Subject: [PATCH] [installer] Fix #8 - limit prefix length to 5 chars --- README.md | 2 +- bin/infra | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8c81da3..23c6ede 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/bin/infra b/bin/infra index 361e701..4a2388e 100755 --- a/bin/infra +++ b/bin/infra @@ -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