8000 GitHub - ikedam/alax: aws login and execute · GitHub
[go: up one dir, main page]

Skip to content
ikedamPublic

About

aws login and execute

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

alax: aws login and execute

日本語バージョン

Background

  • Starting from awscli v2.32.0, the aws login command 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 login is saved in the home directory by default, and the credentials are inherited across different sessions (terminals, etc.). Also, you need to explicitly run aws logout to clear the authentication state. This raises concerns about accidentally using unexpected credentials in different sessions.
    • aws login rewrites ~/.aws/config, so multiple different login sessions cannot be used.
      • This results the behavir that aws login is run, it will ask you to overwrite ~/.aws/config if you run aws login again with different credentials.
    • Applications using older AWS SDK libraries do not reflect the credentials from aws login. To reflect the credentials, you need to use the aws configure export-credentials command to export credentials to environment variables, etc.
  • alax was created as a wrapper command to solve these issues.

alax Implementation and Distribution Policy

  • 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.

Prerequisites

  • 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.

How to Use alax

  1. Running alax executes aws login. If aws login succeeds, a shell is started with the aws login authentication state set.

    • This authentication state is not reflected in other sessions.
    • This is achieved by creating a temporary directory and executing aws login with the AWS_LOGIN_CACHE_DIRECTORY environment variable set.
    • Also, ~/.aws/config is copied and the AWS_CONFIG_FILE environment variable is set to reference it.
      • This behavior has the limitation that the contents of ~/.aws/config are not reflected while in the alax session.
  2. Inside the shell started by alax, running alax exec -- <command> executes <command> with AWS credentials reflected as environment variables.

    • This is achieved by running the aws configure export-credentials command 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.
  3. Inside the shell started by alax, running alax assume <profile> -- <command> executes the specified command with the credentials for <profile> reflected as environment variables.

  4. To clear the authentication state, simply exit the shell.

Build Instructions

  • 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

License

This application and source code are distributed under the MIT License.

About

aws login and execute

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0