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.

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 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.

  3. 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.0.tar.gz (5.4 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.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: py_aws_sso-0.1.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.16.1 CPython/3.12.4 Darwin/23.5.0

File hashes

Hashes for py_aws_sso-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dbbf4e39b35b2862994d6c31419ddf22f213b2b28a8178cf55d39bf5541dc0d0
MD5 95d0c4ac957bf9123d726808d26fd810
BLAKE2b-256 f5dcc519058d499535d04bb276a4b96422aec1a2ee47e57bf520d4f1d56fab15

See more details on using hashes here.

File details

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

File metadata

  • Download URL: py_aws_sso-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.16.1 CPython/3.12.4 Darwin/23.5.0

File hashes

Hashes for py_aws_sso-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4569660ed82ce65e53007f7712ed02eaa0787457175f0673ee812e0e667f2db3
MD5 13a6ffd7c0d45ce129a2b0edccb45a4d
BLAKE2b-256 99f02ffb801c35c52556a5122a95e08e707b0a84a11b3e7f71664b3c388faf2d

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