Skip to content

Instantly share code, notes, and snippets.

First we need to abstract using aws with sts AssumeRole. Put this file anywhere in your $PATH

~.local/bin/sts-aws

#!/usr/bin/env bash
set -euo pipefail

aws-sts() {
    local account=$1
@Szpadel
Szpadel / aws-sts-activate.bash
Last active November 13, 2025 13:39
aws-sts-activate.fish - virtualenv like command for switching to different aws account using assume role. AI converted verions (untested) for bash and zsh
# Source this file in bash: source /path/to/aws-sts.bash
# Provides:
# - aws-sts-activate (alias for aws_sts_activate)
# - aws-sts-deactivate (alias for aws_sts_deactivate)
# Behavior mirrors your Fish version:
# * Loads/writes a cache file with credentials
# * Assumes role when cache is missing/near expiry
# * Shows the active profile in your prompt (left side, bash has no RPROMPT)
# * Auto-refreshes creds when <=30m to expiry (pre-exec and pre-prompt)