Skip to content

Commit

Permalink
add at least auth feedback for gcp case
Browse files Browse the repository at this point in the history
  • Loading branch information
eschultink committed Feb 10, 2025
1 parent 663bbcb commit 4ffc7b6
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions infra/examples-dev/gcp/auth
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@

../../../tools/az-auth.sh

if [ -f terraform.tfvars ]; then
AWS_ROLE_ARN=$(grep -E "^aws_assume_role_arn" terraform.tfvars | awk -F'=' '{print $2}' | tr -d '"' | xargs)
if [ -z "$AWS_ROLE_ARN" ]; then
echo "No AWS_ROLE_ARN found in terraform.tfvars"
else
../../../tools/aws/preflight.sh -r "$AWS_ROLE_ARN"
fi
RED='\033[0;31m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color

# ensure gcloud installed
if ! command -v gcloud &> /dev/null
then
printf "${RED}gcloud is not installed.${NC}\n"
exit 1
fi

GCLOUD_ACCOUNT=$(gcloud config get-value account)

if [[ -z "$GCLOUD_ACCOUNT" ]]
then
printf "${RED}gcloud is not authenticated.${NC}\n"
exit 1
fi

printf "gcloud is authenticated with ${BLUE}${GCLOUD_ACCOUNT}${NC}.\n"

0 comments on commit 4ffc7b6

Please sign in to comment.