Skip to content

Instantly share code, notes, and snippets.

@matarillo
Last active March 2, 2026 06:36
Show Gist options
  • Select an option

  • Save matarillo/191243336c83a56dfbb719d9519252db to your computer and use it in GitHub Desktop.

Select an option

Save matarillo/191243336c83a56dfbb719d9519252db to your computer and use it in GitHub Desktop.

saml2aws

https://github.com/Versent/saml2aws をベースに一部修正

インストール方法

Windows

winget install saml2aws
saml2aws --version

Linux (WSL)

CURRENT_VERSION=$(curl -Ls https://api.github.com/repos/Versent/saml2aws/releases/latest | grep 'tag_name' | cut -d'v' -f2 | cut -d'"' -f1)
wget https://github.com/Versent/saml2aws/releases/download/v${CURRENT_VERSION}/saml2aws_${CURRENT_VERSION}_linux_amd64.tar.gz
tar -xzvf saml2aws_${CURRENT_VERSION}_linux_amd64.tar.gz
mkdir -p ~/.local/bin
mv saml2aws ~/.local/bin/
chmod u+x ~/.local/bin/saml2aws
saml2aws --version

設定

saml2aws configure

以下、次のように入力。AWS Profile と Username は何も入力せずEnterを押してよい。

? Please choose a provider:  [Use arrows to move, type to filter]
> Browser

? AWS Profile (saml)

? URL
https://launcher.myapps.microsoft.com/api/signin/XXXXXXXX?tenantId=YYYYYYYY

? Username

設定内容は ~/.saml2aws ファイルに書かれる。

wsl@apmchamp:~/dev$ cat ~/.saml2aws
[default]
name                    = default
app_id                  =
url                     = https://launcher.myapps.microsoft.com/api/signin/XXXXXXXX?tenantId=YYYYYYYY
username                =
provider                = Browser
mfa                     = Auto
mfa_ip_address          =
skip_verify             = false
timeout                 = 0
aws_urn                 = urn:amazon:webservices
aws_session_duration    = 3600
aws_profile             = saml
resource_id             =
subdomain               =
role_arn                =
policy_file             =
policy_arn_list         =
region                  =
http_attempts_count     =
http_retry_delay        =
credentials_file        =
saml_cache              = false
saml_cache_file         =
target_url              =
disable_remember_device = false
disable_sessions        = false
download_browser_driver = false
headless                = false
prompter                =
kc_broker               =

実行

saml2aws login -p saml

Username と Password は何も入力せずEnterを押してよい。

Using IdP Account default to access Browser https://launcher.myapps.microsoft.com/api/signin/59d27334-a849-432e-9a68-84b26c737a2e?tenantId=ea6968e4-7bf7-4a58-b1ac-112da7ee041f
To use saved password just hit enter.
? Username 

? Password

ブラウザ(Choromium)のウィンドウが開く

ログインに成功すると、ロールを選ぶことができる

ロールを選ぶとクレデンシャル情報が ~/.aws/credentials に保存される。

git-remote-codecommit でのクローン

~/.aws/credentials が存在すれば、codecommitへのアクセスURLを codecommit::(リージョン)://(プロファイル名)@(リポジトリ名) としてアクセスできる。

git clone codecommit::(リージョン)://(プロファイル名)@(リポジトリ名) (ディレクトリ名)

リージョンは ~/.aws/config に記述しておくこともできる

[profile saml]
region=us-west-1
output = json

~/.aws/config~/.aws/credentials が存在すれば、codecommitへのアクセスURLを codecommit://(プロファイル名)@(リポジトリ名) としてアクセスできる。

git clone codecommit://(プロファイル名)@(リポジトリ名) (ディレクトリ名)

Note

プロファイル名を指定しない (デフォルト) であれば (リポジトリ名) でいい

HTTPSでのクローン

次の設定をする

git config --global credential.helper '!aws --profile (プロファイル名) codecommit credential-helper $@'
git config --global credential.UseHttpPath true

設定は ~/.gitconfig に保存される

codecommitへのアクセスURLを https://git-codecommit.(リージョン).amazonaws.com/v1/repos/(リポジトリ名) としてアクセスできる。

git clone https://git-codecommit.(リージョン).amazonaws.com/v1/repos/(リポジトリ名) (ディレクトリ名)

Note

プロファイル名を指定しない (デフォルト) であれば git config --global credential.helper '!aws codecommit credential-helper $@' でいい

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment