From 98726fa2d43cf45e3f2d8dec8b9be05714772951 Mon Sep 17 00:00:00 2001 From: husky Date: Thu, 2 Feb 2023 08:24:57 -0500 Subject: [PATCH] fixing get_password exception error --- aws-lab/get_password.sh | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) mode change 100644 => 100755 aws-lab/get_password.sh diff --git a/aws-lab/get_password.sh b/aws-lab/get_password.sh old mode 100644 new mode 100755 index 64c90b5..8babd84 --- a/aws-lab/get_password.sh +++ b/aws-lab/get_password.sh @@ -15,16 +15,23 @@ instanceid=$(jq -r '.instanceid') user=$(aws ec2 get-console-output --instance-id $instanceid --output text --no-paginate | grep "the default application username is" | awk -F "'" '{print $2}') password=$(aws ec2 get-console-output --instance-id $instanceid --output text --no-paginate | grep "Setting Bitnami application password to" | awk -F "'" '{print $2}') -# Check if username and password were successfully retrieved +# Check if username and password were successfully retrieved. Return a valid JSON object saying "unknown" if we can't retrieve the pass +# This is to allow TF to continue execution even in the event of a bash script error if [ -z "$user" ] || [ -z "$password" ]; then - >&2 echo "Error: Unable to retrieve username or password from instance output" - exit 1 + cat <