Skip to content
Quickly switch between AWS roles with fzf
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE
README.md
fastsar

README.md

fzf AWS sts AssumeRole

A bash script to switch between AWS Roles quickly using fzf

Features

  • Assume AWS role with minimum keystrokes
  • All AWS roles accessible in one place
  • Pre-selects last used account/role
  • Only requires user input if there are more than one accounts/roles

Usage

Most shells do not allow to set environments from sub-shells, so this script returns a string that can be evaluated in the current shell.

In bash this can be done with eval $(fastsar), in fish this can be done with eval (fastsar).

You can also bind the evaluation to some hotkey, like 'Alt+s'

  • bash: bind -x '"\es": eval $(fastsar)'
  • fish: bind \es 'eval (fastsar)'

If the script has problems detecting your shell, you can pass the shell's name as first parameter (e.g. fastsar fish).

Config

Create a json file with all your accounts and roles in the following format in $HOME/.aws/sts.json (configurable as $CONF)

[
    {
        "name": "Production",
        "id": "1234",
        "roles": [
            "abc",
            "def"
        ]
    },
    {
        "name": "Testing",
        "id": "14253",
        "roles": [ "abc" ]
    }
]
  • name: Some name for your account
  • id: The AWS account ID
  • roles: List of AWS role names you want to assume

Requirements

You can’t perform that action at this time.