assume-rolers is a tool to use a temporary AWS credentials. Currently, assume-rolers supports Linux and macOS only.
TBA
No pre-built binaries are available so far. Please build this tool from the source.
bash
$ cargo install assume-rolers
or
bash
$ git clone https://github.com/yoshihitoh/assume-rolers
$ cd assume-rolers
$ cargo build --release
If you're planning to use this tool frequently, please copy the binary to a directory included in PATH.
bash
$ cp ./target/release/assume-rolers ~/.local/bin/
You can select a profile on the terminal. If the role you selected requires MFA, you can also set a token code on the terminal.
bash
$ assume-rolers
You can pass a profile as a command line argument.
If the role you selected requires MFA, you can set a token code via -t
or --token
flag.
bash
$ assume-rolers <PROFILE_NAME> [-t <TOKEN>]
assume-rolers creates a new shell session, so you can deactivate it by exit
command.
assume-rolers will export the following parameters.
| name | op | comment |:-----------------------|:------|:------- | AWSPROFILE | unset | - | AWSREGION | set | - | AWSDEFAULTREGION | set | - | AWSACCESSKEYID | set | - | AWSSECRETACCESSKEY | set | - | AWSSESSIONTOKEN | set | - | AWSSESSIONEXPIRATION | set | expiration datetime in RFC 3339 format. e.g. "2022-11-20T12:01:36+00:00" | ASSUMEROLERSPROFILE | set | assumed profile name. you can use this variable for the shell prompt.
assume-rolers depends on rusoto's DefaultCredentialsProvider backed by ChainProvider. So assume-rolers will look credentials in this order.
- Environment variables: AWSACCESSKEYID and AWSSECRETACCESSKEY
- credential_process command in the AWS config file, usually located at ~/.aws/config.
- AWS credentials file. Usually located at ~/.aws/credentials.
- IAM instance profile. Will only work if running on an EC2 instance with an instance profile/role.
quoted from Rusoto's document.
Currently, assume-rolers supports fish shell only.
try the following command to enable shell completion.
bash
$ cp ./shell-completions/assume-rolers.fish ~/.config/fish/functions/