Skip to content
This repository was archived by the owner on Oct 30, 2025. It is now read-only.

ogiogidayo/aconf

Repository files navigation

aconf

Version License workflow

Outline

  • AWSアカウントをCLI上でMFA認証するときに以下のコードを簡単なコマンドで実行できるようにするツール
OUTPUT=$(aws sts get-session-token \
  --serial-number <arm> \
  --profile <profile> --token-code xxxxxx)
export AWS_ACCESS_KEY_ID=$(echo $OUTPUT | jq -r .Credentials.AccessKeyId)
export AWS_SECRET_ACCESS_KEY=$(echo $OUTPUT | jq -r .Credentials.SecretAccessKey)
export AWS_SESSION_TOKEN=$(echo $OUTPUT | jq -r .Credentials.SessionToken)

使用方法

  • AWSアカウントの切り替え
aconf switch <profile>
  • MFA認証の設定(armとプロファイルの結びつけ)
aconf add <profile> <arm> 
  • MFA認証(codeはワンタイムパスワード)
aconf <profile> <code>

初期設定

  1. Goファイルをビルドする
cd cmd/aconf/
go build -o aconf
  1. 所定の場所に移動する
sudo mv ./aconf /usr/local/bin/
  1. シェルエイリアスを使った実行 .zshrc.bashrcに以下を追加する
aconf() {
  local output
  output=$(/usr/local/bin/aconf "$@")
  if [ $? -ne 0 ]; then
    echo "$output"
    return 1
  fi
  eval "$output"
}

保存後, 再読み込み

source ~/.zshrc

Warning

JetBrains社のBeta版コンソールでは正常に動作しない可能性がある

About

Tools for AWS account switching and MFA authentication on CLI

Resources

License

Stars

Watchers

Forks

Packages

No packages published