AWS CLI SSO – Federated SSO to AWS Using CLI

amazon-web-servicesaws-clisingle-sign-on

We have successfully setup an external idP using google and connected it to AWS. Our users now have Federated SSO with AWS and can easily log into the web console with SAML 2.0 federation Role we created. This role also allows programmatic access but I can't find any documentation how to accomplish this. The normal way to do this is we create an IAM user who uses their own access keys with the CLI but in this case we don't have any IAM users… they are authenticating outside of AWS. Anyone have any ideas how to set this up?

Best Answer

This is doable, but not very convenient. A Chrome plugin exists to extract the access-key, secret-key, and security-token values (needed for an STS login through CLI) after logging in to the AWS Console through SAML. This handles the back-n-forth between the identity provider and the SAML endpoint for AWS.

For a pure-CLI solution, I'm afraid you're going to have to do some scripting. The route is described in the AWS documentation, but involves:

  1. Client sends a request to the IdP of your organization.
  2. The IdP server sends a SAML assertion back.
  3. Client hits the AWS AssumeRoleWithSAML API endpoint (aws sts assume-role-with-saml )
  4. AWS returns the access-key, secret-key, and security-token needed for authentication.

At that point, you have credentials. Once you apply them to your environment, CLI commands work the way they always have. For unattended scripts, your ability to use this route depends entirely on your IdP's ability to allow that workflow.

Related Topic