Installing and using aws-vault
Command Summary
Command | Description |
---|---|
brew install aws-vault | To install aws-vault via Home Brew |
aws-vault –version | To check the version of aws-vault |
aws-vault exec {{profile}} –stdout – aws s3 ls | List S3 buckets for profile provided |
Introduction
This guide will walk you through installing aws-vault, a tool that securely stores and manages your AWS credentials. aws-vault uses your operating system’s secure storage to store credentials, making accessing multiple AWS accounts safer and more convenient without exposing sensitive information.
If you regularly work with AWS, especially across different environments, aws-vault can streamline the authentication process while improving security.
By the end of this guide, you’ll have aws-vault installed and ready to use, setting you up to securely manage AWS credentials in your daily workflow.
Note: This article assumes you are using Homebrew for macOS installation.
What is aws-vault?
aws-vault is a tool designed to store and access AWS credentials on your local machine securely. It helps manage AWS access keys and session tokens by encrypting them and allowing you to switch between different profiles or roles easily.
Here’s a brief overview of how it works:
Storage: aws-vault stores your AWS credentials in a secure, encrypted format using your system’s keychain. These credentials can be long-lived (not a recommended practice) or short-lived credentials from the AWS Identity Center product.
Session Management: It manages AWS sessions, allowing you to assume roles and generate temporary credentials with specific permissions.
Profile Management: You can create and manage multiple profiles, which is helpful if you work with different AWS accounts or roles.
Command Execution: You can use aws-vault to execute AWS CLI commands or other applications that need AWS credentials without directly exposing them.
Overall, it’s a valuable tool for maintaining security and convenience when working with AWS credentials.
Installing aws-vault
Prerequisites
Prior to installing vault you’ll need the following:
- macOS or Linux (I believe there is a Windows Version by milleage may differ significantly)
- A package managers - in my case I’m using Home Brew
- awscli
- AWS Credentials (Short Term or Long-lived)
Note: The aws-vault project can be found at aws-vault
Installation
To install aws-vault, we will leverage Homebrew to install aws-vault. If you don’t have Homebrew installed you can install this from the following link: Home Brew. Open up your terminal and enter the command
If all was successful you should the following output
Checking the version
Once successfully installed we can test binary execution using the following command
Using AWS Identity Center with aws-vault
In my day to day work with multiple clients I tend to leverage AWS Identity Center as this is a common patterns for AWS Landing Zone deployment. This article assumes that you have predefine aws configuration pattern at ~/.aws/config
. If not you can used the following templates to create an SSO configuration
Note: You can leverage long-lived keys with aws-vault
however long-lived and overly permissive keys provider a significant security risk and should be avoided.
Now that we have our aws-vault install and aws cli configured, we can run the following command. It should generate a link and automatically from the cli and redirect you to your browser.
However if you have multiple browsers or profiles you can add the --stdout
option so that automatic browser redirection doesn’t occur. This way you can copy the output link to the correct browser and authentication there.
Once you follow the link in your choosen browser you will be able to click approve request.
Your output should looks something like the following:
Note: The bucket names have be obsfucated for security
From now on you can leverage aws-vault
to pass authenticated credentials to scripts or tools like Terragrunt or Terraform.