- Starting from awscli v2.32.0, the
aws logincommand is available. - This allows you to use AWS Console (browser) login credentials in the CLI.
- However, there are the following issues:
- The state of
aws loginis saved in the home directory by default, and the credentials are inherited across different sessions (terminals, etc.). Also, you need to explicitly runaws logoutto clear the authentication state. This raises concerns about accidentally using unexpected credentials in different sessions. aws loginrewrites~/.aws/config, so multiple different login sessions cannot be used.- This results the behavir that
aws loginis run, it will ask you to overwrite~/.aws/configif you runaws loginagain with different credentials.
- This results the behavir that
- Applications using older AWS SDK libraries do not reflect the credentials from
aws login. To reflect the credentials, you need to use theaws configure export-credentialscommand to export credentials to environment variables, etc.
- The state of
alaxwas created as a wrapper command to solve these issues.
- It is implemented in golang so that it can be distributed as a single binary.
- Since it is a security-related feature, only golang's standard library is used.
- This is to avoid the need to check the safety of dependency libraries.
- Pre-built binaries are provided as GitHub Releases Assets, but you can also build them in your own environment if Docker is installed.
-
awscli v2.32.0 or later is installed.
aws --version
-
Download the alax binary and place it in a location where the path is available.
- The binary can be downloaded from GitHub Releases.
- If you are concerned about security, you can build it from the source code. See "Build Instructions" below.
-
Running
alaxexecutesaws login. Ifaws loginsucceeds, a shell is started with theaws loginauthentication state set.- This authentication state is not reflected in other sessions.
- This is achieved by creating a temporary directory and executing
aws loginwith theAWS_LOGIN_CACHE_DIRECTORYenvironment variable set. - Also,
~/.aws/configis copied and theAWS_CONFIG_FILEenvironment variable is set to reference it.- This behavior has the limitation that the contents of
~/.aws/configare not reflected while in thealaxsession.
- This behavior has the limitation that the contents of
-
Inside the shell started by
alax, runningalax exec -- <command>executes<command>with AWS credentials reflected as environment variables.- This is achieved by running the
aws configure export-credentialscommand to export credentials to environment variables before executing the command. - Note that these credentials only last for 15 minutes. If you need long-term credentials, use the following
aws assume <profile>command.
- This is achieved by running the
-
Inside the shell started by
alax, runningalax assume <profile> -- <command>executes the specified command with the credentials for<profile>reflected as environment variables.- This is intended for use with profiles that have
role_arnconfigured. - For details on profile configurations with assumeRole, see https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html.
- Note that if you log in with
aws loginusing an IAM role, credentials for other roles will only last for a maximum of 1 hour.
- This is intended for use with profiles that have
-
To clear the authentication state, simply exit the shell.
-
Linux (amd64)
GOOS=linux GOARCH=amd64 docker compose run --rm build
-
Windows (amd64)
GOOS=windows GOARCH=amd64 docker compose run --rm build
-
macOS (arm64)
GOOS=darwin GOARCH=arm64 docker compose run --rm build
This application and source code are distributed under the MIT License.