Git Product home page Git Product logo

awsctx's Introduction

awsctx

Setup

Add your .bashrc or .zshrc and follow "OPTIONAL"

sync-aws-profile() {
    if [ -e "$AWSCTX/aws_profile" ]; then
        export AWS_PROFILE=$(cat $AWSCTX/aws_profile)
    fi
}
sync-aws-profile

# ---
# Enable tab completion

# zsh:
eval "$(awsctx completion zsh)"

# bash:
eval "$(awsctx completion bash)"
# ---

# ---
# OPTIONAL: Insert MFA Secret
# Uncomment me If you want to use CLI based 2FA
# MFA_TOKEN=$(oathtool -b --totp $AWS_MFA_SECRET)
# alias awsctx='awsctx --mfa=$(oathtool -b --totp $MFA_TOKEN)'
# ---

Usage

awsctx [completion|help|list|login|show] ...

# List available accounts
awsctx list

# Show current AWS account
awsctx show

# Login
awsctx login myservice-production

# Login with MFA
awsctx login --mfa=123456 myservice-production

# Login and open AWS Management Console (-c, --console)
awsctx login -c myservice-production

# Login and get login URL (-l, --link)
awsctx login -l myservice-production

# Login and open AWS Management Console (with Firefox Multi-Account Containers) (-F, --firefox)
awsctx login -cF myservice-production

Extra: Setup Firefox (Multi-Account Containers)

Install addons:

Multi-Account Containers: https://addons.mozilla.org/ja/firefox/addon/multi-account-containers/

Open container tabs from URL (Protocol Handler): https://addons.mozilla.org/en-US/firefox/addon/open-url-in-container/

Extra: Setup oathtool (MFA_TOKEN)

twilio-authy

  1. Export TOTP tokens Get authy-export from: https://github.com/alexzorin/authy
authy-export
# Enter TOTP backup password
  1. Copy secret
otpauth://totp/~~~:~~~?digits=~&secret=<COPY_HERE>

Save to env

AWS_MFA_SECRET=<SECRET>

Get token from oathtool

  1. Install oath-toolkit
# Ubuntu/Debian
sudo apt install oathtool

# Fedora/RHEL
sudo dnf install oathtool

# macOS
brew install oath-toolkit
  1. Get TOKEN from SECRET
oathtool -b --totp $AWS_MFA_SECRET

awsctx's People

Contributors

laica-lunasys avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

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