pydantic-settings-aws 0.1.0

Last updated:

0 purchases

pydantic-settings-aws 0.1.0 Image
pydantic-settings-aws 0.1.0 Images
Add to Cart

Description:

pydanticsettingsaws 0.1.0

Pydantic Settings AWS






Settings management using Pydantic and Amazon Web Services / Secrets Manager.
💽 Installation
Install using pip install -U pydantic-settings-aws.
📜 Example
You can create and manage your own secrets manager client or leave it to pydantic-settings-aws.
If you want to leave to pydantic-settings-aws to deal with boto3, you can either pass your credential information or leave it to boto3 to figure it out.
To check how boto3 will look for your configurations, check Configuring credentials.
🧑🏻‍💻 With secrets manager client
import boto3
from pydantic_settings_aws import SecretsManagerBaseSettings


client = boto3.client("secretsmanager")


class AWSSecretsSettings(SecretsManagerBaseSettings):
model_config = SettingsConfigDict(
secrets_name="my/secret",
secrets_client=client
)

username: str
password: str
name: str | None = None

my_settings = AWSSecretsSettings()

And your secrets manager should be:
{
"username": "admin",
"password": "admin",
"name": "John"
}

🙋🏾‍♂️ With profile name
class AWSSecretsSettings(SecretsManagerBaseSettings):
model_config = SettingsConfigDict(
secrets_name="my/secret",
aws_region="us-east-1",
aws_profile="dev"
)

username: str
password: str

🔑 With access key
class AWSSecretsSettings(SecretsManagerBaseSettings):
model_config = SettingsConfigDict(
secrets_name="my/secret",
aws_region="us-east-1",
aws_access_key_id="aws_access_key_id",
aws_secret_access_key="aws_secret_access_key",
aws_session_token="aws_session_token"
)

username: str
password: str

🔒 With AWS IAM Identity Center (SSO)
aws sso login --profile my-profile

class AWSSecretsSettings(SecretsManagerBaseSettings):
model_config = SettingsConfigDict(
secrets_name="my/secret"
)

username: str
password: str

👩🏼‍⚖️ License
This project is licensed under the terms of the MIT license.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.