From 5c7860cc81c4405b161b1d945dd3c23c5445d894 Mon Sep 17 00:00:00 2001 From: Chris Wright Date: Fri, 17 Nov 2023 14:40:06 +0000 Subject: [PATCH] Add `aws-sso run-command` command * Allows running an aws-cli command against a given profile --- bin/aws-sso/run-command | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 bin/aws-sso/run-command diff --git a/bin/aws-sso/run-command b/bin/aws-sso/run-command new file mode 100755 index 0000000..817df6b --- /dev/null +++ b/bin/aws-sso/run-command @@ -0,0 +1,35 @@ +#!/bin/bash + +# exit on failures +set -e +set -o pipefail + +usage() { + echo "Usage: $(basename "$0") [OPTIONS]" 1>&2 + echo " -h - help" + echo " -p - AWS SSO Profile" + exit 1 +} + +while getopts "p:h" opt; do + case $opt in + p) + AWS_SSO_PROFILE=$OPTARG + ;; + h) + usage + ;; + *) + usage + ;; + esac +done + +if [ -z "$AWS_SSO_PROFILE" ] +then + usage +fi +shift $((OPTIND-1)) + +export AWS_PROFILE="$AWS_SSO_PROFILE" +aws "$@"