Skip to main content

Settings management using AWS Secrets Manager and Pydantic

Project description

Pydantic Settings AWS

CI codecov PyPI - Implementation PyPI - Python Version Pydantic v2 only PyPI - License

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.

Download files

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

Source Distribution

pydantic_settings_aws-1.0.0b1.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

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

pydantic_settings_aws-1.0.0b1-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file pydantic_settings_aws-1.0.0b1.tar.gz.

File metadata

  • Download URL: pydantic_settings_aws-1.0.0b1.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pydantic_settings_aws-1.0.0b1.tar.gz
Algorithm Hash digest
SHA256 c6bef357395273274a7d3ac2d69b308664c95c0f179b11be93c0e491ac54cb8d
MD5 00e0704035247918c0557266fe28731c
BLAKE2b-256 8076832373547248f877da0e8c3cd47daaabbf2e119e09d7c359ab2905d735a3

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydantic_settings_aws-1.0.0b1.tar.gz:

Publisher: ci.yml on ceb10n/pydantic-settings-aws

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydantic_settings_aws-1.0.0b1-py3-none-any.whl.

File metadata

File hashes

Hashes for pydantic_settings_aws-1.0.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 6176eee1a443da69fef387b007982c865246294a19c5c5aed5fec5e114983764
MD5 2905444cb6f3de6e779ba9c13b02d148
BLAKE2b-256 f4f246839eb3efe576fb52b6f8203fcae767e16c9bad50da58d3111f281ae9bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydantic_settings_aws-1.0.0b1-py3-none-any.whl:

Publisher: ci.yml on ceb10n/pydantic-settings-aws

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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