switch to awsume
This commit is contained in:
@@ -16,11 +16,20 @@ alias d='dirs -v'
|
||||
for index ({1..9}) alias "c$index"="cd +${index}"; unset index
|
||||
# shfmt:ignore:end
|
||||
|
||||
alias kpget="keepassxc-cli show -a Password ${KEEPASS_DB}"
|
||||
|
||||
function load_gemini() {
|
||||
export GEMINI_API_KEY=$(kpget "Gemini API Key")
|
||||
echo "Gemini API Key loaded into environment!"
|
||||
}
|
||||
|
||||
_get_aws_config_path() {
|
||||
local config_path="${AWS_CONFIG_FILE:-$HOME/.aws/config}"
|
||||
echo "$config_path"
|
||||
}
|
||||
|
||||
alias awsume="source awsume"
|
||||
|
||||
# This label will be set in a comment in the ~/.aws/config file right before
|
||||
# the definition of the profile we want to use as the default.
|
||||
# The format will be `#[<label value>]`
|
||||
@@ -54,53 +63,24 @@ _get_default_aws_profile() {
|
||||
echo $profile
|
||||
}
|
||||
|
||||
_terra_cmd() {
|
||||
local aws_vault_profile="$(_get_default_aws_profile)"
|
||||
local cmd_args=()
|
||||
_awsume_cmd() {
|
||||
local profile="$(_get_default_aws_profile)"
|
||||
|
||||
if [[ -z "$1" ]]; then
|
||||
echo "Error: Missing required first argument"
|
||||
echo "Usage: _terra_cmd [terraform|terragrunt] [additional args]"
|
||||
return 1
|
||||
if [[ -n "$1" ]]; then
|
||||
profile="$1"
|
||||
fi
|
||||
|
||||
if [[ "$1" != "terraform" && "$1" != "terragrunt" ]]; then
|
||||
echo "Error: First argument must be either 'terraform' or 'terragrunt'"
|
||||
echo "Usage: _terra_cmd [terraform|terragrunt] [additional args]"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# If we get here, the first argument is valid
|
||||
local -r cmd="$1"
|
||||
shift
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-p | --profile)
|
||||
if [[ $# -gt 1 ]]; then
|
||||
aws_vault_profile="$2"
|
||||
shift 2
|
||||
else
|
||||
echo "Error: -p|--profile requires a profile name"
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
cmd_args+=("$1")
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
aws-vault exec "$aws_vault_profile" -d 8h -- "$cmd" ${cmd_args[@]}
|
||||
awsume "$profile"
|
||||
}
|
||||
|
||||
alias tf="_terra_cmd terraform"
|
||||
alias asm="_awsume_cmd"
|
||||
|
||||
alias tf="terraform"
|
||||
alias tfi="tf init"
|
||||
alias tfp="tf plan -lock=false"
|
||||
alias tfa="tf apply"
|
||||
alias tfu="tf get -update"
|
||||
alias tg="_terra_cmd terragrunt"
|
||||
alias tg="terragrunt"
|
||||
alias tgi="tg init"
|
||||
alias tgp="tg plan -lock=false"
|
||||
alias tga="tg apply"
|
||||
|
||||
Reference in New Issue
Block a user