Skip to content

Azure ad sso login to aws cli

wordpress meta

title: 'Azure AD SSO Login to AWS CLI'
date: '2019-04-18T15:53:57-05:00'
status: publish
permalink: /azure-ad-sso-login-to-aws-cli
author: admin
excerpt: ''
type: post
id: 1343
    - Uncategorized
tag: []
post_format: []

Note out of scope here is setting up the services itself. This article is about using a Node application to login to Azure on a client and then being able to use the AWS CLI. Specifically this information applied to a Linux desktop.

Setting up the services are documented here:

We are following this tutorial and focussed on one account having an administrative role and then switching to different accounts which allows the original role to administer resources.

Linux Lite 4.4 OS Setup

``` # cat /etc/issue Linux Lite 4.2 LTS \n \l # apt install nodejs npm # npm install -g aws-azure-login --unsafe-perm # chmod -R go+rx $(npm root -g) # apt install awscli
</div>**Configure Named Profile (First Time)**

<div class="wp-block-syntaxhighlighter-code ">```

$ aws-azure-login --profile awsaccount1 --configure
Configuring profile ‘awsaccount1’
? Azure Tenant ID:
? Azure App ID URI: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
? Default Username:
? Default Role ARN (if multiple): 
? Default Session Duration Hours (up to 12): 12
Profile saved.

Login with Named Profile

``` $ aws-azure-login --profile awsaccount1 Logging in with profile ‘awsaccount1’... ? Username: ? Password: [hidden] We texted your phone +X XXXXXXXXXX. Please enter the code to sign in. ? Verification Code: 213194 ? Role: arn:aws:iam::xxxxxxxxxxxx:role/awsaccount1-Admin-Role ? Session Duration Hours (up to 12): 12 Assuming role arn:aws:iam::xxxxxxxxxxxx:role/awsaccount1-Admin-Role
</div>**Update Credentials File For Different Accounts to Switch Roles To**

<div class="wp-block-syntaxhighlighter-code ">```

$ cat .aws/credentials 



Test Access

``` $ aws iam list-account-aliases --profile awsaccount2 { "AccountAliases": [ "awsaccount2" ] } $ aws iam list-account-aliases --profile awsaccount3 { "AccountAliases": [ "awsaccount3" ] } ````

So next time just login with the named profile awsaccount1 and you have AWS CLI to the other accounts. Note you will need to make sure ARN's and roles etc are 100% accurate. It gets a bit confusing.

Also this is informational and you carry your own risks of accessing the wrong account.