Giter Club home page Giter Club logo

awsp-plus's Introduction

AWSP Plus - Upgraded AWS Profile Switcher

Easily switch between AWS Profiles.

Expanded fork of awsp by johnnyopao with additional features and ongoing maintenance.*

* no guarantee expressed or implied.

How it works

The AWS CLI will use the profile present in the AWS_PROFILE environment variable, if no flag is set. This script parses the current aws profiles (~/.aws/config) and provides a filterable list, and then sets that environment variable based on your selection.

Prerequisites

Set up any number of profiles using the aws cli.

aws configure --profile PROFILE_NAME

You can also leave out the --profile PROFILE_NAME param to set your default credentials

Refer to the AWS CLI Documentation for more information: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html

Setup

npm install -g awsp-plus

Add the following line to your .bashrc or .zshrc config:

alias awsp="source _awspp"

An alias is used because _awspp needs to be sourced to be able to modify the calling shell's environment variables.

Usage

Standard usage is just to call awsp and select a profile:

awsp

You can type to filter the list, or arrow through the shown options. Press <Enter> to select the highlighted option.

You can also type a profile with the command to immediately switch:

awsp development

This is equivalent to export AWS_PROFILE='development'.

Recommendation: Show your AWS Profile in your shell prompt

For better visibility into which AWS Profile is selected it's helpful to configure your prompt to show the value of the env variable AWS_PROFILE.

Examples

Here is a simplified example:

function aws_prof {
  local profile="${AWS_PROFILE:=default}"

  echo "aws:(${profile})"
}

PS1="$PS1 \$(aws_prof)"

Here's @johnnyopao's example using oh-my-zsh themes, with nice colors:

function aws_prof {
  local profile="${AWS_PROFILE:=default}"

  echo "%{$fg_bold[blue]%}aws:(%{$fg[yellow]%}${profile}%{$fg_bold[blue]%})%{$reset_color%} "
}

PROMPT='OTHER_PROMPT_STUFF $(aws_prof)'

A more advanced example for bash can be found in my dotfiles at https://github.com/abyss/dotfiles.

Contributing

Issues and pull requests are welcome. ๐Ÿ˜„

License

This project and the original work are licensed under the ISC License.

Copyright (c) 2021 Abyss

Original Work Copyright (c) 2020 Johnny Opao (@ https://github.com/johnnyopao/awsp)

awsp-plus's People

Contributors

abyss avatar johnnyopao avatar deepanshu2506 avatar tcsadquirencia-devops avatar

Stargazers

 avatar

Watchers

 avatar

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.