Skip to content

Instantly share code, notes, and snippets.

@dessibelle
Last active March 30, 2023 09:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dessibelle/7944a58ee17c7c4945f8aea2acefca85 to your computer and use it in GitHub Desktop.
Save dessibelle/7944a58ee17c7c4945f8aea2acefca85 to your computer and use it in GitHub Desktop.
Open an AWS console using separate Chrome profiles
#!/bin/bash
SCRIPT_NAME=$(basename $0)
function print_usage() {
echo "Usage:"
echo -e "\t${SCRIPT_NAME} [-p | --prompt <aws-vault prompt>] <aws_profile>"
echo -e "\nHint: set AWS_VAULT_PROMPT to e.g. 'ykman' to have aws-console default to ykman."
}
while [ "$1" != "" ]; do
PARAM=`echo $1 | awk -F= '{print $1}'`
VALUE=`echo $1 | awk -F= '{print $2}'`
case $PARAM in
-h | --help)
print_usage
exit
;;
-p | --prompt)
shift
VALUE=$1
PROMPT="--prompt ${VALUE}"
;;
*)
PROFILE_NAME=$PARAM
;;
esac
shift
done
# Google Chrome
LOGIN_URL=$(aws-vault $PROMPT login $PROFILE_NAME --stdout)
echo "${LOGIN_URL}" | nohup xargs -t open -b com.google.Chrome -n --args --profile-directory="${PROFILE_NAME}" > /dev/null 2>&1 &
# TODO: Browser support
# Firefox
# aws-vault --debug login $PROFILE_NAME --stdout 2>/dev/null | nohup xargs -t firefox -p $PROFILE_NAME --no-remote > /dev/null 2>&1 &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment