Giter VIP home page Giter VIP logo

awsmfa's Introduction

AWS MFA resolver in Go

DEMO

The 'awsmfa' is a simple cli tool for AWS MFA. Both AWS STS GetSessionToken and AssumeRole API are supported.

From my exeperience, MFA and STS operation are sometimes a point of a trouble shooting. Therefore, awsmfa is designed to show you request parameters visually.

Feature

  • Visual design
  • Available all region
  • Easy to set up. Almost all keys are same as aws-cli v2's default.
  • Available various cli options like aws-cli v2 (such as --duration-seconds, --serial-number)
  • Set default params via awsmfa's configuration file (${HOME}/.awsmfa/configuration)
  • Support both GetSessionToken and AssumeRole API

Installing

Homebrew

$ brew tap Jimon-s/awsmfa
$ brew install awsmfa

The others

clone this repo

$ go install

or

Go 1.16~

$ go install github.com/Jimon-s/awsmfa@latest

Quick start

First, you should set profile in your shared credentials and config file (By default, it's placed ${HOME}/.aws/credentials and ${HOME}/.aws/config). It will be used in executing sts api to obtain temporary credentials.

No worries! You can easily get templates by using helper options.

  • awsmfa --generate-credentials-skeleton get-session-token
  • awsmfa --generate-config-skeleton get-session-token
  • awsmfa --generate-credentials-skeleton assume-role
  • awsmfa --generate-config-skeleton assume-role

example: credentials (get-session-token)

[sample-before-mfa]
aws_access_key_id     = YOUR_ACCESS_KEY_ID_HERE!!!
aws_secret_access_key = YOUR_SECRET_ACCESS_KEY_HERE!!!

example: config (get-session-token)

[profile sample-before-mfa]
region     = REGION_TO_CONNECT_IN_EXECUTING_STS_GET_SESSION_TOKEN # Such as ap-northeast-1, us-east-1
output     = json
mfa_serial = YOUR_MFA_SERIAL_HERE!!! # Such as arn:aws:iam::XXXXXXXXXXX:mfa/YYYY

[profile sample]
region = REGION_TO_CONNECT_AFTER_MFA # Such as ap-northeast-1, us-east-1
output = json

Then, you simply exec these command.

$ awsmfa --profile sample

The awsmfa automatically exec sts api and add/update shared credentials.

Automatically add new credentials in shared credentials file.

[sample]
aws_access_key_id     = NEW_ACCESSKEY_ID
aws_secret_access_key = NEW_SECRET_ACCESS_KEY
aws_session_token     = NEW_SESSION_TOKEN
expiration            = 2999-11-23T14:15:16Z

Supported API

AWS provides us two types of API to obtain temporary security credentials for cli access. AWS: Requesting temporary security credentials

You can select the api by using --mode get-session-token or --mode assume-role (by default, get-session-token is activated).

The available APIs are different according to your environment, please check your IAM setting.

The image of the operation is below.

GetSessionToken

$ awsmfa --profile sample
or
$ awsmfa --profile sample --mode get-session-token

GetSessionToken

AssumeRole

$ awsmfa --profile sample --mode assume-role

AssumeRole

Priority of params

The awsmfa is designed to match the priority of params with aws cli's default order.

Basically, each params give priority according to the order below.

  1. CLI option
  2. environment variable
  3. shared credentials file (${HOME}/.aws/credentials)
  4. shared config file (${HOME}/.aws/config)
  5. awsmfa's configuration file (${HOME}/.awsmfa/configuration)
  6. awsmfa's build in default value

License

MIT

awsmfa's People

Contributors

donngi avatar

Stargazers

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