Skip to content

handle your Amazon AWS profile/account on your host globally

License

Notifications You must be signed in to change notification settings

peterbueschel/awsdefault

Repository files navigation

awsdefault

Build Status Go Report Card Coverage Status

Change Amazon AWS profiles/accounts globally.

This tool sets one of your AWS profiles, configured in your $HOME/.aws/credentials file (see here), to the default profile. Means:

  • adding parameters like --profile=my-profile to the aws cli
  • or changing the environment variable with export AWS_PROFILE=my-profile in every new terminal window

are not required anymore.

Table of Contents

Example Usage

Use either the cli tool

Change the default AWS profile to 'personal'

  • command:
$ awsdefault to personal

Disable/unset the AWS profile

command:

$ awsdefault rm

the complete list of parameters can be found here

Or the UI tool

Linux

awsdefault-gkt3-example1

Note i3block was used as statusbar in this example. You can find the config in the doc folder.

Windows

TODO

Installation

Option 1 — Download binaries

precompiled binaries for Linux, (TODO: Windows and MacOS) are available at the [release] page.

curl 

Option 2 — Compile it

  • for the cli tool, see here
  • for the gtk3-UI, see here

Configure your environment (only first time)

Set the environment variable AWS_PROFILE to default (aws userguide).

Linux

Add the following line to your .xinitrc, .zshrc or .bashrc file:

export AWS_PROFILE=default

Windows

TODO

How it works

The awsdefault (cli or UI) tool creates, changes or deletes the [default] profile section in your AWS credentials file. This default section contains the same aws_access_key_id and aws_secret_access_key as stored in one of the other profile sections. Together with the configured environment variable AWS_PROFILE=default, this approach enables or disables the credentials of the specific AWS profile. In other words, the default profile points to the required profile or will be deleted if no profile is needed.

  • The environment variable
$ env | grep AWS_PROFILE
AWS_PROFILE=default
  • The AWS credentials file — no default was set; default was unset
$ cat ~/.aws/credentials
[live]
aws_access_key_id     = A
aws_secret_access_key = B

[dev]
aws_access_key_id     = C
aws_secret_access_key = D

[personal]
aws_access_key_id     = E
aws_secret_access_key = F
  • The AWS credentials file — default was set to personal (comment was added automatically)
$ cat ~/.aws/credentials
; active_profile=personal
[default]
aws_access_key_id     = E
aws_secret_access_key = F
                         
[live]                   
aws_access_key_id     = A
aws_secret_access_key = B
                         
[dev]                    
aws_access_key_id     = C
aws_secret_access_key = D
                         
[personal]               
aws_access_key_id     = E
aws_secret_access_key = F

License

See LICENSE.