Skip to main content

Simple Python library for AWS SSO credential management in local development.

Project description

py-aws-sso

Simple Python library for AWS SSO credential management in local development.

About

py-aws-sso simplifies obtaining short-term credentials for CLI and Boto3 operations when using AWS SSO during local Python development.

How To Video Guide

Video detailing the steps of configuring AWS SSO Profile using AWS CLI and using this module is available on YouTube

Simplying AWS SSO Credentials for Python Developers

Motivation

In our organization developing applications that interact with AWS accounts often requires managing long-term credentials. This can lead to several challenges, including:

  • Security risks: Long-term credentials pose a security risk if compromised.
  • Credential management overhead: Developers need to securely store and manage long-term credentials, which can be cumbersome.
  • Role-switching complexity: Switching between different roles or accounts can be inconvenient with long-term credentials.

py-aws-sso addresses these challenges by providing a simple solution to obtain temporary AWS credentials during local development. By leveraging temporary credentials, developers can:

  • Enhance security: Mitigate the risks associated with long-term credential leaks.
  • Simplify credential management: Eliminate the need to store and manage long-term credentials locally.
  • Effortlessly switch roles: Easily switch between different roles and accounts within their development workflow.

This simple solution to this problem but piggy backing on AWS CLI v2 tool.

How it works

py-aws-sso simplifies obtaining temporary credentials by leveraging the AWS CLI v2 tool. It uses the existing AWS CLI configuration, and uses boto3 library to retrieve temporary credentials for the specified profile. If you haven't already established an SSO login session, py-aws-sso will automatically trigger one for you.

Prerequisites

This Python 3 module requires a working installation of the [AWS CLI v2](https://docs.aws.amazon. com/cli/latest/userguide/install-cliv2.html) and the boto3 library

Setting Up

  1. Install and Configure AWS CLI v2: Follow the official documentation @ https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html to install and configure AWS CLI v2 with your SSO profiles.

  2. Include py-aws-sso: Install py-aws-sso.

pip install py-aws-sso

--or--

pdm add py-aws-sso

  1. Run Your Project:
    • Create a local_run.py file to execute your project using Python.
    • Import set_aws_creds from the awssso module.
    • Call set_aws_creds with these arguments:
      • profile_name (string): The name of the AWS CLI profile to use.
      • verbose (boolean, optional): Set to True to print verbose messages (defaults to False).

Inspiration:

This project is inspired by the aws-sso-credentials project. However, it caters specifically to Python developers and focuses on local development workflows.

Example

from awssso import set_aws_creds

# Assuming your AWS profile name is "my-sso-profile"
set_aws_creds(profile_name="my-sso-profile", verbose=True)

# Now you can use boto3 with the temporary credentials
import boto3

s3_client = boto3.client("s3")
response = s3_client.list_buckets()
print(response)

Example fastapi project is included for quick reference

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_aws_sso-0.1.1.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_aws_sso-0.1.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file py_aws_sso-0.1.1.tar.gz.

File metadata

  • Download URL: py_aws_sso-0.1.1.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for py_aws_sso-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2c072e46e14a9987cc204787f070596357d365104fa84a3e62477066be8e8f75
MD5 c6df78b73b184a1be7b15340b31e66bf
BLAKE2b-256 4b9af2bbd516fd819fdb00dd9e7302933d1d4906bbd002f96b12c247ec6a41c7

See more details on using hashes here.

File details

Details for the file py_aws_sso-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: py_aws_sso-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for py_aws_sso-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b2c45d251a5a5a0c5ceb9b4878daf562cef2f086762f4edf541a0432c76d30eb
MD5 2e7407f3b765987dd1f79e10d011f5cf
BLAKE2b-256 c02cc319c185e3a2989d93d4079b97ce0e608622651672c4fc919a797d35f565

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page