Git Product home page Git Product logo

rs.aws-login's Introduction

aws-login

A command line utility to simplify logging into AWS accounts and services.

$ aws-login use
? Please select a profile to use: ›
❯ dev-read
  dev-write

$ echo $AWS_PROFILE
dev-read

$ aws-login use --profile dev-write

$ echo $AWS_PROFILE
dev-write

Table of Contents

Requirements

  • AWS CLI v2

Development

  • Rust 1.57

Installation

  1. Go to the Releases page.
  2. Download a release for your OS.
  3. Unzip the release.
    • unzip -j aws-login_linux_amd64.zip
  4. Make aws-login executable.
    • chmod 755 aws-login
  5. Move aws-login to somewhere in your $PATH.
  6. Run aws-login shell install -s $SHELL, where $SHELL is your supported shell.
    • See aws-login shell --help for a list of supported shells.
  7. Start a new shell session.

macOS

On more recent versions of macOS, Gatekeeper will block your attempt to run the application because it is not signed with an Apple Developer certificate. Please see this guide on how to work around this issue.

Usage

Before we dive into using the application, you need to be aware of how profiles work with the AWS CLI. The official AWS CLI supports the use of profiles so that information such as accounts, roles, and preferences are remembered. This saves you from having to provide that information each time you want to do something.

The aws-login utility attempts to take full advantage of AWS CLI profiles. When "active AWS CLI profile" is mentioned, it means one of two things:

  • The value of the AWS_PROFILE environment variable.
  • Or "default".

By default, everything you do with aws-login will use the profile found in one of the places mentioned above and in the order they are listed. However, like AWS CLI, you can change the profile you are working with by using the --profile option.

Configuring Docker to use ECR

aws-login ecr

This subcommand will configure Docker to use the Elastic Container Registry in the AWS account for your active AWS CLI profile. If the region for your ECR differs from the default region configured for your profile, remember to specify it with the --region option.

Configure kubectl to use EKS

aws-login eks

This subcommand will prompt you to choose an EKS cluster from a list found in the AWS account for your active AWS CLI profile. Once a selection is made, the configuration for kubectl is updated to support connecting to that EKS cluster. Remember to log in before attempting to do so, fresh credentials may be required.

Log into an RDS Proxy using IAM

aws-login rds $USERNAME

This subcommand will prompt you to choose an RDS Proxy from a list found in the AWS account for your active AWS CLI profile. Once a selection is made, the database authentication token will be generated for you to use in your preferred database client.

It is important to note that generating a token will almost always succeed, even if you do not have permission to access the RDS Proxy endpoint. If authentication fails, you will want to check a few things:

  1. Make sure your TLS settings match.
  2. Make sure you are using the correct AWS CLI profile.
  3. Make sure your role has the IAM rds-db:connect permission.

Log into an AWS account using AWS SSO portal

aws-login sso

This subcommand will use the AWS SSO portal settings in your active AWS CLI profile for authentication. If the required settings are missing, you will be prompted to provide them before authentication can proceed.

Setting up and activating AWS CLI profiles

aws-login use

This subcommand will prompt you to selected from a list of existing AWS CLI profiles and available profile templates. If a profile template is selected and a corresponding AWS CLI profile does not already exist, it will be automatically configured using the template. Once a selection has been made, the shell environment is modified to make it the active AWS CLI profile for the duration of the shell session.

Working with profile templates

The use subcommand does not simply offer you the ability to select existing AWS CLI profiles, but also offers the ability to use profile templates to configure new AWS CLI profiles. These templates are stored in JSON file called templates.json (found in ~/.config/aws-login/ or %APPDATA\Roaming\AWS Login\).

This is what a collection of profile templates looks like:

{
    "base": {
        "enabled": false,
        "settings": {
            "output": "json",
            "region": "us-east-1",
            "sso_region": "us-east-1",
            "sso_start_url": "https://my-sso-portal.awsapps.com/start"
        }
    },
    "dev-read": {
        "extends": "base",
        "settings": {
            "sso_account_id": 123456789012,
            "sso_role_name": "ReadOnly"
        }
    },
    "dev-write": {
        "extends": "dev-read",
        "settings": {
            "sso_role_name": "Developer"
        }
    }
}

The base profile template serves as the foundation for other templates to build upon. It provides some common settings such as where the SSO portal is located. Because this is not a fully configured profile, and is intended to be used by other templates, enabled is set to false so that it is not listed as an option to select from when aws-login use is run.

The dev-read profile template uses the base template by specifying it under the extends key, and adds its own SSO settings that make it ready to be used for authentication. If dev-read provided its own region, it would override the region set by the base profile.

The dev-write profile template demonstrates that your profile dependency tree can go as deep as you need. In this template, we re-use all of the settings from dev-read (and consequently, base) but override the sso_role_name we want to use.

Okay, but why?

Here is an example scenario:

You are a new hire at a company that hosts all of their services in AWS. As part of the onboarding process, you work on setting up your workstation so that you can use AWS CLI to interact with the cloud environment. Instead of asking around, searching Confluence/Sharepoint/etc, or figuring it out on your own, you install aws-login and run the pull subcommand with a URL you were provided.

You now have immediate access to various AWS accounts and services.

Downloading and installing profile templates

You may want to familiarize yourself with this first: Setting up and activating AWS CLI profiles

aws-login pull https://www.example.com/path/to/templates.json

This subcommand will download a remote profile templates file and store a copy for later use. If a local templates file already exists, you will be asked if you would like to merge with the existing file or replace it.

rs.aws-login's People

Contributors

kherge avatar kherrera-ebsco avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

kherrera-ebsco

rs.aws-login's Issues

Unable to navigate profile names in `aws-login use` when using Git for Windows (MINGW).

The following checks have been done.

  • I could not find another bug report that covers what I discovered.
  • This report does not request new features or enhancements.

What is the current behavior?

When presented with a long list of profiles when running aws-login use, keyboard navigation through the list does not work.

What is the expected behavior?

For keyboard navigation to work properly as it does in other shells.

Some additional context.

No response

The ability to generate a new profile from any profile template, but with a different name.

The following checks have been done.

  • I could not find another enhancement request that covers what I need.
  • This request does not cover existing functionality.

What existing feature needs to be enhanced?

The ability to create profiles from templates.

What problem is being solved?

Currently, profile templates can only be used to generate profiles of the same name.

How would you like to see this problem solved?

There should be a way to use any existing profile template to generate a new profile using any desired name.

With a new subcommand

aws-login new template-name profile-name

The purpose of the new command would be solely to use templates for new profiles of any name.

With an existing subcommand

aws-login use --as profile-name

The subcommand would check if the --as option is being used and either create a new profile from the selected template or copy an existing profile.

Some additional context.

No response

Use red font when displaying error messages.

The following checks have been done.

  • I could not find another enhancement request that covers what I need.
  • This request does not cover existing functionality.

What existing feature needs to be enhanced?

All error messages that are printed to the screen.

What problem is being solved?

It could be beneficial to use red font color so that users can immediately understand that something has gone wrong instead of coming to that conclusion after having read the message.

How would you like to see this problem solved?

Whenever an error message is printed to the screen, the red font color should be used.

Some additional context.

No response

Document managing ExecutionPolicy for PowerShell profile scripts.

The following checks have been done.

  • I could not find another enhancement request that covers what I need.
  • This request does not cover existing functionality.

What existing feature needs to be enhanced?

The documentation for integrating into PowerShell.

What problem is being solved?

Some PowerShell configurations may have their ExecutionPolicy undefined which prevents the integration script from being loaded.

How would you like to see this problem solved?

Update the documentation to help PowerShell users that get caught by this issue.

  1. Check what the ExecutionPolicy is for CurrentUser.
    Get-ExecutionPolicy -List
  2. Allow local scripts to be executed.
    Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned

Some additional context.

This appears to be a Windows specific issue beginning with PowerShell 6.0 (see -ExecutionPolicy documentation).

The configuration directory is not automatically created.

The following checks have been done.

  • I could not find another bug report that covers what I discovered.
  • This report does not request new features or enhancements.

What is the current behavior?

When using pull to download the templates file, the configuration directory is not automatically created.

$ aws-login pull https://...
Could not save the downloaded templates.
  Could not write to the profile templates file: /Users/kherrera/.config/aws-login/templates.json
    No such file or directory (os error 2)

What is the expected behavior?

When working with the configuration directory, it is automatically created if it does not exist.

Some additional context.

Maybe the full path should be created in case the parent directory does not also exist?

Color change for error messages persist after app.

The following checks have been done.

  • I could not find another bug report that covers what I discovered.
  • This report does not request new features or enhancements.

What is the current behavior?

When you run the application and an error message is printed, all following text is now the same color as the error text. This persists even with other applications that are used.

What is the expected behavior?

The color should reset to their defaults after the error message is printed.

Some additional context.

No response

Outdated Cargo.lock failing builds.

The following checks have been done.

  • I could not find another bug report that covers what I discovered.
  • This report does not request new features or enhancements.

What is the current behavior?

Current build fails on the following command:

cargo build --release --locked

What is the expected behavior?

For the build to successfully complete.

Some additional context.

I introduced this issue when I pushed directly to master. Lesson learned.

Support cross-platform testing in the test workflow.

The following checks have been done.

  • I could not find another enhancement request that covers what I need.
  • This request does not cover existing functionality.

What existing feature needs to be enhanced?

The test workflow setup on GitHub.

What problem is being solved?

The test workflow is only running the test suite on Linux.

How would you like to see this problem solved?

The test workflow should run the test suite on all platforms releases are built for.

Some additional context.

No response

Support shell integration with Fish.

The following checks have been done.

  • I could not find another enhancement request that covers what I need.
  • This request does not cover existing functionality.

What existing feature needs to be enhanced?

Shell integration support.

What problem is being solved?

When switching profiles, the active profile is not automatically set when using Fish.

How would you like to see this problem solved?

Provide shell integration support for Fish.

Some additional context.

Make profile list searchable.

The following checks have been done.

  • I could not find another enhancement request that covers what I need.
  • This request does not cover existing functionality.

What existing feature needs to be enhanced?

The aws-login use prompt that is used to select a profile.

What problem is being solved?

I would like to make it easier to find a profile to use.

How would you like to see this problem solved?

The list of profiles to select from should be filtered by a text search against a full or partial match of the profile name.

Before

❯ aws-login use
? Please select a profile to use: ›
❯ profile-1
  profile-2a
  profile-2b
  profile-3
(Move up and down to reveal more choices)

After

❯ aws-login use
? Please select a profile to use: › 2
❯ profile-2a
  profile-2b
(Move up and down to reveal more choices)

Some additional context.

No response

Documentation is not clear about SSO support.

The following checks have been done.

  • I could not find another bug report that covers what I discovered.
  • This report does not request new features or enhancements.

What is the current behavior?

The current documentation does not clearly specify that SSO support is for AWS SSO, not other services such as Okta.

What is the expected behavior?

The documentation to explicitly state that SSO support is for AWS SSO.

Some additional context.

No response

Allow endpoint to be selected for RDS subcommand.

The following checks have been done.

  • I could not find another enhancement request that covers what I need.
  • This request does not cover existing functionality.

What existing feature needs to be enhanced?

The ability to generate an auth token for RDS Proxy IAM authentication.

What problem is being solved?

We currently cannot select an endpoint for an RDS proxy.

How would you like to see this problem solved?

Include the option of selecting an endpoint for a proxy (e.g. read/write, read-only, etc.).

Some additional context.

No response

Support shell integration with PowerShell.

The following checks have been done.

  • I could not find another enhancement request that covers what I need.
  • This request does not cover existing functionality.

What existing feature needs to be enhanced?

Shell integration support.

What problem is being solved?

When switching profiles, the active profile is not automatically set when using PowerShell.

How would you like to see this problem solved?

Provide shell integration support for PowerShell.

Some additional context.

A subcommand for handling RDS IAM authentication.

The following checks have been done.

  • I could not find another feature request that covers what I need.
  • This request does not cover existing functionality.

What problem is being solved?

Generating a token for authenticating with RDS IAM can be confusing and tedious.

How would you like to see this problem solved?

A subcommand could be created to handle prompting the user for the necessary information and then using to generate the token.

Some additional context.

Bonus points if you can get dropped straight into the respective database client in the terminal.

Rank and sort profiles by usage.

The following checks have been done.

  • I could not find another enhancement request that covers what I need.
  • This request does not cover existing functionality.

What existing feature needs to be enhanced?

The profile listing for selection.

What problem is being solved?

There are some profiles I use far more frequently than others. Sorting alphabetically may not be the most convenient way of listing the available profiles.

How would you like to see this problem solved?

Add an option to allow profiles to be sorted by how often they are used. When a profile is selected, increment an internal counter for it by one. The next time the profile list is presented, sort by that internal number for each profile in the list.

Some additional context.

No response

Create a subcommand to assume a role.

It would be very handy to have a subcommand that simplifies the process of assuming and unassuming a role.

  • Create an assume subcommand.
  • Create an unassume subcommand.

Support using `$SHELL` as `shell install -s` option value.

The following checks have been done.

  • I could not find another enhancement request that covers what I need.
  • This request does not cover existing functionality.

What existing feature needs to be enhanced?

The shell script installer.

What problem is being solved?

It is not convenient to read through the documentation to specify the desired shell integration.

How would you like to see this problem solved?

Use the SHELL environment variable to determine which shell integration option to use.

Some additional context.

No response

A subcommand to assume and unassume IAM roles.

The following checks have been done.

  • I could not find another feature request that covers what I need.
  • This request does not cover existing functionality.

What problem is being solved?

Using AWS CLI to assume and assume roles can be tedious and confusing.

How would you like to see this problem solved?

A subcommand could be created to automatically handle shell environment changes required for assuming and unassuming roles.

Some additional context.

Incorrect path separator used when running in Git for Windows (MINGW) when install shell script.

The following checks have been done.

  • I could not find another bug report that covers what I discovered.
  • This report does not request new features or enhancements.

What is the current behavior?

Windows path separator is used in Windows when running in Git for Windows shell while running shell script installer.

What is the expected behavior?

Use the Unix path separator on shell script installation.

Some additional context.

No response

No help font color in PowerShell.

The following checks have been done.

  • I could not find another bug report that covers what I discovered.
  • This report does not request new features or enhancements.

What is the current behavior?

When running the application in PowerShell without any arguments, the help screen does not have any font color.

What is the expected behavior?

When running the application in PowerShell without any arguments, the help screen should have the same colors that other terminals support.

Some additional context.

Missing `~/.config/aws-login/templates.json` file is not handled gracefully.

The following checks have been done.

  • I could not find another bug report that covers what I discovered.
  • This report does not request new features or enhancements.

What is the current behavior?

The use subcommand produces an error if no existing AWS CLI profiles are found and the profile templates file does not exist.

$ aws-login use
Could not get a list of existing AWS CLI profiles.
  No such file or directory (os error 2)

What is the expected behavior?

The subcommand should detect this scenario and display a more elegant error message.

$ aws-login use
There are no profiles available.

Some additional context.

No response

The default PowerShell profile is not properly handled.

The following checks have been done.

  • I could not find another bug report that covers what I discovered.
  • This report does not request new features or enhancements.

What is the current behavior?

The application does not integrate into the correct PowerShell profile.

What is the expected behavior?

The application properly detects the active PowerShell profile and uses it for integration.

Some additional context.

  • The application assumes that the profile is always in one location, which is not necessarily the case.
  • A StackOverflow provided a nice explanation on how PowerShell profiles can be discovered.

An empty object is saved when `pull` is used.

The following checks have been done.

  • I could not find another bug report that covers what I discovered.
  • This report does not request new features or enhancements.

What is the current behavior?

When using the pull subcommand, an empty object is saved to the templates.json file.

What is the expected behavior?

When using the pull command, the downloaded templates should be saved to the templates.json file.

Some additional context.

  • Running the command in admin mode does not change anything.
  • Maybe reqwest is failing silently?

A check is not performed to see if the AWS CLI is available in PATH.

The following checks have been done.

  • I could not find another bug report that covers what I discovered.
  • This report does not request new features or enhancements.

What is the current behavior?

When using aws-login without having aws in PATH, a vague error message is displayed.

$ aws-login eks
The list of available EKS clusters could not be retrieved from the AWS CLI.
  No such file or directory (os error 2)

What is the expected behavior?

The application should detect that aws is not available and display a better error message.

$ aws-login eks
Please ensure that the AWS CLI is available in PATH.

Some additional context.

Use a self-signed certificate to sign macOS builds.

The following checks have been done.

  • I could not find another enhancement request that covers what I need.
  • This request does not cover existing functionality.

What existing feature needs to be enhanced?

All releases for macOS.

What problem is being solved?

The binaries are not signed and complicate the user experience in launching the application.

How would you like to see this problem solved?

Create and use a self-signed certificate to sign macOS releases.

Some additional context.

Use the CarLI command line application framework.

The following checks have been done.

  • I could not find another enhancement request that covers what I need.
  • This request does not cover existing functionality.

What existing feature needs to be enhanced?

The application infrastructure.

What problem is being solved?

aws-login directly owns responsibility for how the application should be designed.

How would you like to see this problem solved?

Delegate this to a library dedicated for it, and possibly benefit from improvements made to the library over time.

Some additional context.

I am mostly dogfooding CarLI.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.