awsmfa

package module
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

README

awsmfa (AWS MFA Refresher)

Test Status Apache-2.0 license

awsmfa replaces the config and credentials for MFA in AWS.

Usage

$ awsmfa [options] [token-code]
  • The config file uses ~/.aws/config by default. You can override it with the environment variable AWS_CONFIG_FILE.
  • The credentials file uses ~/.aws/credentials by default. You can override it with the environment variable AWS_SHARED_CREDENTIALS_FILE.
Options
--profile string
	The name of the profile from which the session can be obtained (default `default`)

--mfa-profile-name string
	MFA profile name (default `mfa`)

--duration-seconds int64
	Session expiration duration secounds (default `43200`)

--serial-number string
	AWS serial number. `--serial-number` is required

--quiet bool
	if enabled, log is not printed in the console. (default `false`)
Example
$ awsmfa --serial-number arn:aws:iam::123456789012:mfa/future-architect --profile my-profile 123456
2021/02/28 11:01:49 {
  Credentials: {
    AccessKeyId: "AKIAIOSFODNN7EXAMPLE",
    Expiration: 2021-02-28 14:01:49.689 +0000 UTC,
    SecretAccessKey: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY",
    SessionToken: "AQoEXAMPLEH4aoA...."
  }
}
initial
  • .aws/config
BeforeAfter
[default]
region = us-east-1
output = json
[default]
region = us-east-1
output = json

[profile mfa]

  • .aws/credentials
BeforeAfter
[default]
aws_access_key_id = ABCDEFGHIJKLMNOPQRST
aws_secret_access_key = ChcdJbC9kraRNW5iy8XgDyR4QNRT44kKRPmKEGQT
[default]
aws_access_key_id     = ABCDEFGHIJKLMNOPQRST
aws_secret_access_key = ChcdJbC9kraRNW5iy8XgDyR4QNRT44kKRPmKEGQT

[mfa]
aws_access_key_id     = AKIAIOSFODNN7EXAMPLE
aws_secret_access_key = wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY
aws_session_token     = AQoEXAMPLEH4aoA....

next time

Update aws_access_key_id, aws_secret_access_key and aws_session_token in the target section (default is mfa) of .aws/credentials.

Installation

  • From binary
# binary
$ curl -sfL https://raw.githubusercontent.com/future-architect/awsmfa/master/install.sh | sudo sh -s -- -b /usr/local/bin
  • From source code
# go get
$ go get github.com/future-architect/awsmfa/cmd/awsmfa

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, c *Config) error

Run executes awsmfa.

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config holds information about the configuration of awsmfa.

func NewConfig

func NewConfig(c *cli.Context) (*Config, error)

NewConfig generates the Config.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL