AWS Vault is a tool to securely store and access AWS credentials in a development environment.
AWS Vault stores IAM credentials in your operating system's secure keystore and then generates temporary credentials from those to expose to your shell and applications. It's designed to be complementary to the AWS CLI tools, and is aware of your profiles and configuration in
Check out the announcement blog post for more details.
You can install AWS Vault:
- by downloading the latest release
- on macOS with Homebrew Cask:
brew install --cask aws-vault
- on macOS with MacPorts:
port install aws-vault
- on Windows with Chocolatey:
choco install aws-vault
- on Windows with Scoop:
scoop install aws-vault
- on Linux with Homebrew on Linux:
brew install aws-vault
- on Arch Linux:
pacman -S aws-vault
- on FreeBSD:
pkg install aws-vault
- on OpenSUSE: enable devel:languages:go repo then
zypper install aws-vault
- with Nix:
nix-env -i aws-vault
- with asdf-vm:
asdf plugin-add aws-vault https://github.com/karancode/asdf-aws-vault.git && asdf install aws-vault <version>
Config, usage, tips and tricks are available in the USAGE.md file.
The supported vaulting backends are:
- macOS Keychain
- Windows Credential Manager
- Secret Service (Gnome Keyring, KWallet)
- Encrypted file
--backend flag or
AWS_VAULT_BACKEND environment variable to specify.
# Store AWS credentials for the "jonsmith" profile $ aws-vault add jonsmith Enter Access Key Id: ABDCDEFDASDASF Enter Secret Key: %%% # Execute a command (using temporary credentials) $ aws-vault exec jonsmith -- aws s3 ls bucket_1 bucket_2 # open a browser window and login to the AWS Console $ aws-vault login jonsmith # List credentials $ aws-vault list Profile Credentials Sessions ======= =========== ======== jonsmith jonsmith -
How it works
aws-vault uses Amazon's STS service to generate temporary credentials via the
AssumeRole API calls. These expire in a short period of time, so the risk of leaking credentials is reduced.
AWS Vault then exposes the temporary credentials to the sub-process in one of two ways
- Environment variables are written to the sub-process. Notice in the below example how the AWS credentials get written out
$ aws-vault exec jonsmith -- env | grep AWS AWS_VAULT=jonsmith AWS_DEFAULT_REGION=us-east-1 AWS_REGION=us-east-1 AWS_ACCESS_KEY_ID=%%% AWS_SECRET_ACCESS_KEY=%%% AWS_SESSION_TOKEN=%%% AWS_SECURITY_TOKEN=%%% AWS_SESSION_EXPIRATION=2020-04-16T11:16:27Z
- Local EC2 Instance Metadata server is started. This approach has the advantage that anything that uses Amazon's SDKs will automatically refresh credentials as needed, so session times can be as short as possible. The downside is that only one can run per host and because it binds to
169.254.169.254:80, your sudo password is required.
The default is to use environment variables, but you can opt-in to the local instance metadata server with the
--server flag on the
Roles and MFA
Here's an example configuration using roles and MFA:
[default] region = us-east-1 [profile jonsmith] mfa_serial = arn:aws:iam::111111111111:mfa/jonsmith [profile foo-readonly] source_profile = jonsmith role_arn = arn:aws:iam::22222222222:role/ReadOnly [profile foo-admin] source_profile = jonsmith role_arn = arn:aws:iam::22222222222:role/Administrator mfa_serial = arn:aws:iam::111111111111:mfa/jonsmith [profile bar-role1] source_profile = jonsmith role_arn = arn:aws:iam::333333333333:role/Role1 mfa_serial = arn:aws:iam::111111111111:mfa/jonsmith [profile bar-role2] source_profile = bar-role1 role_arn = arn:aws:iam::333333333333:role/Role2 mfa_serial = arn:aws:iam::111111111111:mfa/jonsmith
Here's what you can expect from aws-vault
||session-token + role||session-token||Yes|
||session-token + role + role||session-token||Yes|
||role + role||role||Yes|
The macOS release builds are code-signed to avoid extra prompts in Keychain. You can verify this with:
$ codesign --verify --verbose $(which aws-vault)
If you are developing or compiling the aws-vault binary yourself, you can generate a self-signed certificate by accessing Keychain Access > Certificate Assistant > Create Certificate -> Certificate Type: Code Signing. You can then sign your binary with:
$ go build . $ codesign --sign <Name of certificate created above> ./aws-vault
References and Inspiration
There is no documentation for this package.