• Stars
    star
    128
  • Rank 279,760 (Top 6 %)
  • Language
    Go
  • License
    MIT License
  • Created about 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Get AWS SSO temporary creds from an SSO profile

aws-sso-creds

aws-sso-creds is a helper utility to retrieve temporary credentials when using AWS SSO

About

If you're using AWS SSO, you're able to set up your AWS profile like so:

[profile sso-profile]
output = json
region = us-west-2
sso_account_id = <my-account-id>
sso_region = us-west-2
sso_role_name = <role-to-assume>
sso_start_url = <special-sso-url>

This is great, because it means you're able to login very easily using aws sso login from the AWS CLI

This retrieves a set of cached credentials, which are saved into ~/.aws/sso/cache and you can now use the AWS CLI with those credentials.

However

Unfortunately, the AWS SDK's in nearly every language currently do not support these credentials. In this case, you can retrieve temporary credentials that look like the AWS credentials you're used to:

AWS_ACCESS_KEY_ID=<key>
AWS_SECRET_ACCESS_KEY=<key>
AWS_SESSION_TOKEN=<key>

However, it's really quite annoying to have to login to the URL and grab these tokens manually. The AWS CLI has support for retrieving them, but you have to run:

aws sso get-role-credentials --role-name <SOME_ROLE_I_CANNOT_REMEMBER> --account-id <WHATS_MY_ACCOUNT_ID_AGAIN?> --access-token <I_HAVE_TO_LOOK_THIS_UP_IN_A_FILE_WHERE?>

This simple utility is designed to take the pain out of this process. It can:

  • Grab you a set of credentials to copy and paste for a specific account/profile (If you're so inclinded)
  • Generate an eval compatible output to ease the process of grabbing these credentials
  • List the accounts and roles you have access to for ease of management

Usage

Get credentials

If you just want to retrieve a set of credentials for your AWS SSO based profile, just run aws-sso-creds get:

$ aws-sso-creds get
Your temporary credentials for account <foo> are:

AWS_ACCESS_KEY_ID	 <KEY>
AWS_SECRET_ACCESS_KEY <ACCESS_KEY>
AWS_SESSION_TOKEN	<A_LONG_SESSION_TOKEN>

These credentials will expire at: Mon Oct 31 16:03:20 PST 52495 

aws-sso-creds will automatically use the AWS_PROFILE environment variable you have set. You can also specify a profile with aws-sso-creds --profile

Populate your shell with vars

If you want to just get going without any copying and pasting, use eval with aws-sso-creds export

eval $(aws-sso-creds export)

This command generates output in the form of export variables:

$ aws-sso-creds export
export AWS_ACCESS_KEY_ID=<KEY>
export AWS_SECRET_ACCESS_KEY=<SECRET_KEY>
export AWS_SESSION_TOKEN=<SESSION_TOKEN>

List accounts

You can also list the accounts you have available within AWS SSO:

$ aws-sso-creds list accounts
ID             NAME                 EMAIL ADDRESS
<id>           dev-sandbox          [email protected]
<id>           -ci                  [email protected]

List account roles

You can list the roles available in an account like so:

$ aws-sso-creds list roles <account-id>

NOTE: currently this tool doesn't support multiple roles when getting credentials, if this is necessary, please file a feature request

Installation

This is a compiled go binary, so just put it in your $PATH.

If you're on os x make sure to then run xattr -d com.apple.quarantine /path/to/aws-sso-creds to allow it to run.

Homebrew

A tap is provided to install via homebrew:

brew tap jaxxstorm/tap
brew install aws-sso-creds

Nix

nixpkgs includes a recipe for aws-sso-creds.

  • If flakes are enabled: nix profile install nixpkgs#aws-sso-creds
  • Otherwise: nix-env --install --attr aws-sso-creds

More Repositories

1

hookpick

A tool to manage some operational concepts of Hashicorp Vault
Go
83
star
2

unseal

A command line tool to unseal multiple Hashicorp Vault servers quickly
Go
82
star
3

connecti

A command line tool to quickly create a connection to cloud infrastructure
Go
48
star
4

graphping

Ping a list of endpoints and write the results to statsd
Go
42
star
5

ploy

Go
37
star
6

pulumi-examples

Python
35
star
7

action-install-gh-release

GitHub Action to install the Github Release binaries
JavaScript
32
star
8

redphone

A rubygem for talking to monitoring service APIs
Ruby
23
star
9

sensu-wrapper

A wrapper to send shell command results to sensu
Go
21
star
10

graylog2-server-rpm

Deprecated RPM config for graylog2
Shell
14
star
11

terraform-digitalocean-kubernetes

A terraform module for managing and creating a Kubernetes cluster on digital ocean
HCL
11
star
12

graylog2-web-rpm

Deprecated RPM config for graylog2
11
star
13

pulumi-automationapi-workshop

HTML
10
star
14

pulumi-azurenative-workshop

HTML
10
star
15

change-aws-credentials

A simple tool to change your AWS credentials quickly from the commandline
Go
9
star
16

terraform-cloud-custodian

A terraform module to install the prerequisites for cloud-custodian
HCL
9
star
17

pulumi-kubernetes-example

An example of using Kubernetes with Pulumi
TypeScript
6
star
18

pulumi-productionapp

An example production application Pulumi Package
Go
6
star
19

secure-cloud-access

Reference repo for accessing cloud resources securely from GitHub actions
TypeScript
6
star
20

iac-in-go

An example of a full stack Infrastructure as Code in Go
Go
5
star
21

aksctl

Create AKS clusters from the CLI, using the power of Pulumi!
Go
5
star
22

brig.gs

Code for running the brig.gs mastodon instance
TypeScript
5
star
23

lbrlabs

Configuration of my cloud providers and base infrastructure
TypeScript
4
star
24

node-age-operator

A Kubernetes controller that cordons nodes older than a specified age
Go
4
star
25

kr8-cfgmgmt-example

An example of using kr8 to deploy components to Kubernetes clusters
Jsonnet
4
star
26

puppet-teleport

A puppet module for Teleport: https://github.com/gravitational/teleport
Ruby
4
star
27

docker-credential-vault

Store and retrieve your docker registry credentials using Hashicorp Vault
Go
4
star
28

kubernetes-rpm

Build an RPM for k8s
4
star
29

managed-kubernetes-platforms

A list of all the cloud providers that provide managed Kubernetes platforms
4
star
30

ploop-flexvol

Ploop flexvolume driver for kubernetes
Go
4
star
31

pulumi-cdk-http

An AWS CDK construct embedded inside a Pulumi Automation API webserver
JavaScript
3
star
32

jkcfg-example

An example usage of jkcfg
JavaScript
3
star
33

pulumi-component-workshop

Python
3
star
34

pulumi-do

A Digital Ocean (DO) Pulumi resource package, providing multi-language access to Digital Ocean
Python
3
star
35

eks-vb-net

Deploy to Kubernetes with VB.Net
Visual Basic .NET
3
star
36

pulumi-rke

An RKE pulumi resource package, providing multi language access to RKE
Go
3
star
37

kubeless-events-example

A repo containing examples of how to manage kubernetes events with kubeless
Python
3
star
38

puppet-consul-demo

Demo of configuration for using puppet and consul togerher
HCL
3
star
39

pulumi-nginx-demo

Deploying the nginxinc ingress controller and application
Python
3
star
40

jolokia_exporter

Jolokia exporter for prometheus, written in golang.
Go
2
star
41

pulumi-aws-fargatewebapp

A Pulumi multi language package to deploy an application to AWS Fargate
Python
2
star
42

pulumi-awsloadbalancercontroller

Install the AWS LoadBalancer Controller in AWS EKS with Pulumi
Go
2
star
43

runmydamncontainer

Run your container in the cloud provider of your choice
Go
2
star
44

puppet-inspec

A puppet module to install chef inspec
Ruby
2
star
45

puppet-coredns

A puppet module for CoreDNS
Ruby
2
star
46

pulumi-gcp-workshop

HTML
2
star
47

containers-from-the-couch

A repo containing examples for containers from the couch
Python
2
star
48

dotfiles

An opinionated set of dotfiles for productivity wins
Shell
2
star
49

gh-actions

A configuration generator for github actions
TypeScript
2
star
50

node-age-controller

A kubernetes controller to cordon nodes older than a specified age
Go
2
star
51

pulumi-aws-loadbalancercontroller

Installable Pulumi package for the AWS LoadBalancer Controller
TypeScript
2
star
52

pulumi-docker

Experimental SDK focused pulumi images
Dockerfile
2
star
53

leebriggs.co.uk

A Jekyll blog theme with just the right amount of style
HTML
2
star
54

pulumi-awsvpc

A best practice AWS VPC
Go
1
star
55

graylog2-radio-rpm

1
star
56

hubot-cachet

A hubot script for interacting with Cachet
CoffeeScript
1
star
57

slack-notifier

Output channel creation/archive events to a slack channel
Ruby
1
star
58

sms_forwarder

Forward messages from one number to the other
Python
1
star
59

puppet-kubeadm

Install, configure and bootstrap Kubernetes clusters with kubeadm
Ruby
1
star
60

pulumi-eksplatform-workshop

An interactive workshop for EKS + Pulumi in TypeScript
TypeScript
1
star
61

puppet-sensu_wrapper

A puppet module to deploy sensu_wrapper
Puppet
1
star
62

nbcgen

A very VERY simple ruby app which generates real links for NBC Sport Live Extra
Ruby
1
star
63

aad-pod-identity-verifier

Go
1
star