Code Monkey home page Code Monkey logo

aws-sso's Introduction

aws-sso

Python AWS SSO login helper.

This is a simple python package that will log into AWS SSO (using the AWS CLI and configured profiles) and then set environmental variables for the AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY/AWS_SESSION_TOKEN within that terminal. This make it easy to get credentials into the console without the need to constantly revisit the SSO login page and manual copy/paste credentials. This in conjunction with zshrc/bashrc allows for easy authentication anywhere. This does rely on you having the appropriate settings within "~/.aws/config", there is an example below along with an example of a function to put within zshrc/bashrc.

You will need to install this module locally using setup tools.

Example SSO configuration in "~/.aws/config"

[default]
region = eu-west-1
output = json
[profile ssoprofile]
sso_start_url = https://ssologinpage.awsapps.com/start
sso_region = eu-west-1
sso_account_id = 123456789123
sso_role_name = role_name
region = eu-west-1
output = json

Example zshrc/bashrc configuration

sso(){
    value=`python3 -m aws-sso -p $1`
    account_id=`echo $value | jq .account_id -r` 
    role_name=`echo $value | jq .role_name -r` 
    
    access_key_id=`echo $value | jq .accessKeyId -r` 
    secret_access_key=`echo $value | jq .secretAccessKey -r` 
    session_token=`echo $value | jq .sessionToken -r` 

    expiration=`echo $value | jq .expiration -r` 
    tput setaf 2
    
    echo "Account ID: $account_id"
    echo "Role Name:  $role_name"
    echo "Access Key: $access_key_id"
    echo "Expiration: $expiration"

    export AWS_ACCESS_KEY_ID=`echo $access_key_id`
    export AWS_SECRET_ACCESS_KEY=`echo $secret_access_key`
    export AWS_SESSION_TOKEN=`echo $session_token`
}

aws-sso's People

Contributors

samhopwell avatar renovate-bot avatar

Stargazers

Thys Meintjes avatar

Watchers

 avatar

Forkers

davidhubbell

aws-sso's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

pip_requirements
requirements.txt
  • boto3 >=1.18.21

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.