Simple AWS environment manager, inspired by rvm.
awsvm helps you manage multiple AWS configurations and switch between them easily. The command-line output is colorized to improve readability.
-
Backup your existing AWS configuration (if any):
mv ~/.aws ~/.aws.bak
-
Clone the repository:
git clone https://github.com/raravena80/awsvm.git ~/.awsvm -
Initialize
awsvm:~/.awsvm/bin/awsvm initFollow the instructions on the screen to add
awsvmto your shell's startup file (e.g.,~/.bash_profileor~/.zshrc). -
Reload your shell: Open a new terminal window or source your profile file (e.g.,
source ~/.bash_profile). -
(Optional) Import your old configuration:
awsvm create old_config mv ~/.aws.bak/* ~/.awsvm/configurations/old_config/ rm -rf ~/.aws.bak
awsvm works by maintaining a set of configurations in the ~/.awsvm/configurations directory. Each configuration is a directory containing your AWS config files.
Switch to a different AWS configuration. This command works by creating a symlink from ~/.aws to the selected configuration directory (~/.awsvm/configurations/{config_name}).
Shortcut: You can also just type awsvm {config_name}.
Export AWS credentials as environment variables. This is useful for tools that do not read the ~/.aws configuration files directly. The default profile is default.
To use it, run the following command in your shell:
eval $(awsvm export my_config)This will set AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN (if available), and AWS_DEFAULT_REGION in your current shell session.
List all available configurations. The current and default configurations are marked.
Create a new, empty configuration directory.
Delete a configuration.
Copy an existing configuration to a new one.
Rename a configuration.
Set the default configuration. This configuration will be used when you open a new shell.
Open a configuration directory in your default editor ($EDITOR).
Display the name of the current configuration.
Update awsvm to the latest version from the git repository.
Each configuration is a directory inside ~/.awsvm/configurations/. When you switch to a configuration with awsvm use, this directory is symlinked to ~/.aws.
A typical configuration directory can contain:
credentials: A file in INI format containing your AWS access keys.[default] aws_access_key_id = YOUR_ACCESS_KEY aws_secret_access_key = YOUR_SECRET_KEY
config: A file in INI format for other settings, like the default region.[default] region = us-east-1
- Other files, like PEM keys for EC2 instances.
awsvm also supports named profiles within your configuration files. For example, when using awsvm export my_config personal, it will look for the [personal] profile in the credentials file and the [profile personal] section in the config file.
You can use awsvm current in your PS1 to see your current config in your prompt:
PS1="\$(awsvm current) $ "Fork the repository and send a pull request.
The project uses bats for testing. To run the tests, you can use the provided Vagrant setup.
-
Start the Vagrant VM:
vagrant up
This will bring up an Ubuntu VM, install
awsvm, and run the tests. -
Re-run tests: To re-run the tests on the running VM:
vagrant provision
-
Shutdown the VM:
vagrant destroy