AKM is a simple AWS access Keys Manager.
It helps you to switch multiple AWS credentials easily. And it is useful when could not specify profile of AWS credentials. e.g. Terraform, Packer, Bash scripts, PowerShell scirpts and so on.
Download it from releases page and extract it to /usr/bin or your PATH directory.
$ go get -u github.com/ohsawa0515/akm
$HOME/.aws/credentials
# For example
[default]
aws_access_key_id = AKIAIOSFODNN7EXAMPLE
aws_secret_access_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
[account1]
aws_access_key_id = AKIAI44QH8DHBEXAMPLE
aws_secret_access_key = je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEY
region = us-east-1 # optional
[account2]
aws_access_key_id = AKIAI44QH7DHBEXAMPLE
aws_secret_access_key = je7MtGbClwBF/3Zp9Utk/h4yCo8nvbEXAMPLEKEY
region = us-east-2 # optional
$HOME/.aws/config
(Optional)
[default]
region=us-west-2
output=json
[profile acountA]
region=us-east-1
output=text
[profile acountB]
region=us-east-2
output=text
$ akm -help
Name:
akm - A simple AWS access keys manager
Usage:
akm COMMAND
Version:
0.0.1
Author:
Shuichi Ohsawa <[email protected]>
Commands:
clear Delete the environment variable of AWS credentials.
configure Configure AWS credentials
current Show current profile name.
delete Delete profile from AWS credentials file.
echo Show the AWS key or region with the specified profile name.
help Help about any command
init Initialize for akm command
list List all AWS credentials profile.
use Use specific AWS credential key
Flags:
-h, --help Print help
-v, --version Print the version
$ akm init --help
Name:
akm init - Initialize for akm command
Usage:
akm init
Aliases:
init, i
Description:
Initialize akm command for the first time usage.
After execution, "$HOME/.akm.toml" is created.
Global Flags:
-h, --help Print help
For example:
$ akm init
.akm.toml is created in ~/.akm.toml
$ akm ls --help
Name:
akm list - List all AWS credentials profile.
Usage:
akm list
Aliases:
list, ls, l
Global Flags:
-h, --help Print help
For example:
$ akm ls
default
account1
account2
$ akm use --help
Name:
akm use - Use specific AWS credential key
Usage:
akm use PROFILE [[ANY COMMAND]...]
Aliases:
use, u
Description:
Set specific AWS credential in environment values.
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
- AWS_SESSION_TOKEN (if session token is set)
- AWS_DEFAULT_REGION (if region is set)
If an arbitrary command was specified as an argument, store the AWS credentials key in the environment variable and then execute the command.
Examples:
case 1) Set specific AWS credential in environment values.
$ akm use foo
export AWS_ACCESS_KEY_ID='xxxxxxxx';export AWS_SECRET_ACCESS_KEY='xxxxxxxxx';export AWS_DEFAULT_REGION=us-east-1
case 2) Import variables into your environment by eval.
$ eval $(akm use foo)
$ env | grep AWS
AWS_ACCESS_KEY_ID=xxxxxxxx
AWS_SECRET_ACCESS_KEY=xxxxxxxxx
AWS_DEFAULT_REGION=us-east-1
case 3) Store the AWS credentials key in the environment variable and then execute the command.
$ akm use foo terraform plan
Global Flags:
-h, --help Print help
For example:
# Import variables into your environment by eval.
$ eval $(akm use account1)
$ env | grep AWS
AWS_ACCESS_KEY_ID=AKIAI44QH8DHBEXAMPLE
AWS_SECRET_ACCESS_KEY=je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEY
AWS_DEFAULT_REGION=us-east-1
# Command wapper
$ akm use account1 terraform apply
$ akm current --help
Name:
akm current - Show current profile name.
Usage:
akm current
Aliases:
current, c
Global Flags:
-h, --help Print help
For example:
$ akm use account1
$ akm current
account1
$ akm echo --help
Name:
akm echo - Show the AWS key or region with the specified profile name.
Usage:
akm echo PROFILE aws_access_key_id | aws_secret_access_key | region
Aliases:
echo, e
Global Flags:
-h, --help Print help
For example:
$ akm echo account1 aws_access_key_id
AKIAI44QH8DHBEXAMPLE
$ akm echo account1 aws_secret_access_key
je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEY
$ akm echo account1 region
us-east-1
# Show current AWS key
$ aws use account2
$ akm echo $(akm current) aws_access_key_id
AKIAI44QH8DHBEXAMPLE2 # account2's AWS access key id
$ akm configure --help
Name:
akm configure - Configure AWS credentials
Usage:
akm configure PROFILE
Description:
Configure AWS credentials like "aws configure --profile PROFILE".
The set parameters are **overwritten** and saved in the credential file.
Examples:
akm configure foo
Global Flags:
-h, --help Print help
For example:
$ akm configure foo
✔ AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
✔ AWS Secret Access Key [None]: ****************************************
✔ Region: US East (N. Virginia) [us-east-1]
? Overwrite ~/.aws/credentials? [y/N] y
$ akm clear --help
Name:
akm clear - Delete the environment variable of AWS credentials.
Usage:
akm clear
Aliases:
clear, C
Examples:
$ akm clear
unset AWS_ACCESS_KEY_ID;unset AWS_SECRET_ACCESS_KEY;unset AWS_DEFAULT_REGION;
Delete environment variable with eval.
$ env | grep AWS
AWS_ACCESS_KEY_ID=xxxxxxx
AWS_SECRET_ACCESS_KEY=xxxxxxx
AWS_DEFAULT_REGION=us-east-1
$ eval $(akm clear)
$ env | grep AWS
# empty
Global Flags:
-h, --help Print help
For example
$ env | grep AWS
AWS_ACCESS_KEY_ID=AKIAI44QH8DHBEXAMPLE
AWS_SECRET_ACCESS_KEY=je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEY
AWS_DEFAULT_REGION=us-east-1
$ eval $(akm clear)
$ env | grep AWS
# empty
$ akm delete --help
Name:
akm delete - Delete profile from AWS credentials file.
Usage:
akm delete PROFILE
Aliases:
delete, del, d
Description:
Delete profile from AWS credentials file.
When the profile is deleted, the credentials file is **overwritten**.
Examples:
akm delete foo
Global Flags:
-h, --help Print help
For example:
$ akm delete foo
? Remove profile: foo, overwrite ~/.aws/credentials? [y/N] y
- Fork (https://github.com/ohsawa0515/akm/fork)
- Create a feature branch
- Commit your changes
- Rebase your local changes against the master branch
- Run test suite with the
go test ./...
command and confirm that it passes - Run
gofmt -s
- Create new Pull Request
See LICENSE.
Shuichi Ohsawa (@ohsawa0515)