Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ryansonshine/aws-sso-creds-helper

A command line util for using SSO credentials with AWS SDK on AWS CLI v2 until native support is released
https://github.com/ryansonshine/aws-sso-creds-helper

aws aws-cli aws-sdk aws-sso awscli awscli-login awssdk hacktoberfest sso sso-credentials switch-profiles

Last synced: about 1 month ago
JSON representation

A command line util for using SSO credentials with AWS SDK on AWS CLI v2 until native support is released

Awesome Lists containing this project

README

        

# AWS SSO Credentials Helper

> [!IMPORTANT]
> This repository is now archived due to new functionality being added to the
> AWS CLI.
>
> Please update your CLI to the latest version and use `aws sso login --profile `
>
> Additional details are available [here](https://docs.aws.amazon.com/cli/latest/userguide/sso-using-profile.html).

[![npm package][npm-img]][npm-url]
[![Build Status][build-img]][build-url]
[![Downloads][downloads-img]][downloads-url]
[![Issues][issues-img]][issues-url]
[![Code Coverage][codecov-img]][codecov-url]
[![Commitizen Friendly][commitizen-img]][commitizen-url]
[![Semantic Release][semantic-release-img]][semantic-release-url]

When using `aws sso login` on [AWS CLI v2](https://aws.amazon.com/blogs/developer/aws-cli-v2-is-now-generally-available/)
as of July 27th, 2020, the credentials are stored so they will work with the CLI
itself (v2) but don't work on the AWS SDKs and other tools that expect credentials
to be readable from `~/.aws/credentials` (v1).

This package aims to streamline updating the AWS credentials file for AWS SSOΒΉ
users by updating/creating the corresponding profile section in `~/.aws/credentials` with
temporary role credentials. Once a solution is implemented in AWS CLI v2, this
repo will be archived.

ΒΉRenamed to IAM Identity Center as of July 26th, 2022.

> **Note**
>
> As of December 2022, profiles configured with an SSO Session Name using the
> AWS CLI v2.8.2 or later have added functionality for the AWS SDKs to use SSO
> credentials without them being present in the `~/.aws/credentials` file.
>
> This project **will** continue to be maintained and currently supports both legacy
> and new profile formats, since I'm currently not aware if all third party AWS
> tools have made changes required adopted this change.
>
> See [SSO token provider configuration with automatic authentication refresh][cli-auto-refresh-doc]
> for additional details.

## Install

```sh
npm install -g aws-sso-creds-helper
```

## Usage

> Note: If you have not configured your AWS CLI to use SSO for your profile, follow the
instructions [here][cli-sso-config-doc].

```sh
Usage: ssocreds [options]

Options:
-V, --version output the version number
-p, --profile profile to use for obtaining sso credentials (default: "default")
-d, --debug enables verbose logging (default: false)
-v, --verbose enables verbose logging (default: false)
-u, --use-proxy flag for the aws sdk to use HTTPS_PROXY found in env (default: false)
-h, --help display help for command
```

Example:

```sh
$ ssocreds -p my-profile

[aws-sso-creds-helper]: Getting SSO credentials for profile my-profile
[aws-sso-creds-helper]: Successfully loaded SSO credentials for profile my-profile
```

or create an alias in your shell containing

```sh
alias awsmyprofile="ssocreds -p my-profile"
```

or combine with a [profile switching script](https://github.com/antonbabenko/awsp)
if you use multiple profiles to switch profiles and then grab the credentials in one command

```sh
alias awsmyprofile="awsp my-profile && ssocreds -p my-profile"
```

[build-img]:https://github.com/ryansonshine/aws-sso-creds-helper/actions/workflows/release.yml/badge.svg
[build-url]:https://github.com/ryansonshine/aws-sso-creds-helper/actions/workflows/release.yml
[downloads-img]:https://img.shields.io/npm/dt/aws-sso-creds-helper
[downloads-url]:https://www.npmtrends.com/aws-sso-creds-helper
[npm-img]:https://img.shields.io/npm/v/aws-sso-creds-helper
[npm-url]:https://www.npmjs.com/package/aws-sso-creds-helper
[issues-img]:https://img.shields.io/github/issues/ryansonshine/aws-sso-creds-helper
[issues-url]:https://github.com/ryansonshine/aws-sso-creds-helper/issues
[codecov-img]:https://codecov.io/gh/ryansonshine/aws-sso-creds-helper/branch/master/graph/badge.svg
[codecov-url]:https://codecov.io/gh/ryansonshine/aws-sso-creds-helper
[semantic-release-img]:https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
[semantic-release-url]:https://github.com/semantic-release/semantic-release
[commitizen-img]:https://img.shields.io/badge/commitizen-friendly-brightgreen.svg
[commitizen-url]:http://commitizen.github.io/cz-cli/
[cli-sso-config-doc]:https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html
[cli-auto-refresh-doc]:https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html#sso-configure-profile-token

## Contributors ✨

[![All Contributors](https://img.shields.io/badge/all_contributors-7-orange.svg?style=flat-square)](#contributors-)

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):



Ryan Sonshine
Ryan Sonshine

πŸ’»
Steven Tobias
Steven Tobias

πŸ’»
sclarson
sclarson

πŸ’»
Cole Siegel
Cole Siegel

πŸ›
Rinaldi Utomo
Rinaldi Utomo

πŸ›
diogo
diogo

πŸ›
Caleb Hill
Caleb Hill

πŸ›

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!