If your organization uses Azure Active Directory to provide SSO login to the AWS console, then there is no easy way to log in on the command line or to use the AWS CLI. This tool fixes that. It lets you use the normal Azure AD login (including MFA) from a command line to create a federated AWS session and places the temporary credentials in the proper place for the AWS CLI and SDKs.
Inspired by aws-azure-login
$ go install github.com/knqyf263/azaws@latest
$ sudo rpm -ivh https://github.com/knqyf263/azaws/releases/download/v0.0.1/azaws_0.0.1_Tux_64-bit.rpm
$ wget https://github.com/knqyf263/azaws/releases/download/v0.0.1/azaws_0.0.1_Tux_64-bit.deb
$ dpkg -i azaws_0.0.1_linux_amd64.deb
Download binary from https://github.com/knqyf263/azaws/releases
$ azaws --configure
Azure Tenant ID: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
Azure App ID URI: https://signin.aws.amazon.com/saml?XXXXXXXXXXXX
The following command will open Google Chrome.
$ azaws --role [YOUR ROLE NAME]
Enter your credentials and log in to Azure.
After that, you can use aws-cli.
$ aws sts get-caller-identity --profile [YOUR_PROFILE_NAME (default: azaws)]
Usage of azaws:
-configure
Configure options
-profile string
AWS profile name (default "azaws")
-role string
AWS role name (required)
-user-data-dir string
Chrome option (default "/tmp/azaws")
Your Azure AD system admin should be able to provide you with your Tenant ID and App ID URI. If you can't get it from them, you can scrape it from a login page from the myapps.microsoft.com page.
- Load the myapps.microsoft.com page.
- Click the chicklet for the login you want.
- In the window the pops open quickly copy the login.microsoftonline.com URL. (If you miss it just try again. You can also open the developer console with nagivation preservation to capture the URL.)
- The GUID right after login.microsoftonline.com/ is the tenant ID.
- Copy the SAMLRequest URL param.
- Paste it into a URL decoder (like this one) and decode.
- Paste the decoded output into the a SAML deflated and encoded XML decoder (like this one).
- In the decoded XML output the value of the Issuer tag is the App ID URI.
Teppei Fukuda