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
-
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.
-
Include py-aws-sso: Install py-aws-sso.
-
Run Your Project:
- Create a
local_run.pyfile to execute your project using Python. - Import
set_aws_credsfrom theawsssomodule. - Call
set_aws_credswith these arguments:profile_name(string): The name of the AWS CLI profile to use.verbose(boolean, optional): Set toTrueto print verbose messages (defaults to False).
- Create a
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dbbf4e39b35b2862994d6c31419ddf22f213b2b28a8178cf55d39bf5541dc0d0
|
|
| MD5 |
95d0c4ac957bf9123d726808d26fd810
|
|
| BLAKE2b-256 |
f5dcc519058d499535d04bb276a4b96422aec1a2ee47e57bf520d4f1d56fab15
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4569660ed82ce65e53007f7712ed02eaa0787457175f0673ee812e0e667f2db3
|
|
| MD5 |
13a6ffd7c0d45ce129a2b0edccb45a4d
|
|
| BLAKE2b-256 |
99f02ffb801c35c52556a5122a95e08e707b0a84a11b3e7f71664b3c388faf2d
|