Metadata-Version: 2.1
Name: pydantic-ssm-settings
Version: 0.2.4
Summary: Replace Pydantic's builtin Secret Support with a configuration provider that loads parameters from AWS Systems Manager Parameter Store.
Home-page: https://github.com/developmentseed/pydantic-ssm-settings/
License: MIT
Author: Anthony Lukach
Author-email: anthonylukach@gmail.com
Maintainer: Anthony Lukach
Maintainer-email: anthonylukach@gmail.com
Requires-Python: >=3.7,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Requires-Dist: boto3 (>=1.21.45,<2.0.0)
Requires-Dist: pydantic (>=1.6.2,<2.0.0)
Project-URL: Repository, https://github.com/developmentseed/pydantic-ssm-settings/
Description-Content-Type: text/markdown

# pydantic-ssm-settings

Replace Pydantic's builtin [Secret Support](https://pydantic-docs.helpmanual.io/usage/settings/#secret-support) with a configuration provider that loads parameters from [AWS Systems Manager Parameter Store](https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-parameter-store.html). Parameters are loaded _lazily_, meaning that they are only requested from AWS if they are not provided via [standard field value priority](https://pydantic-docs.helpmanual.io/usage/settings/#field-value-priority) (i.e. initialiser, environment variable, or via `.env` file).

## Usage

The simplest way to use this module is to inhert your settings `Config` class from `AwsSsmSourceConfig`. This will overwrite the [`file_secret_settings` settings source](https://pydantic-docs.helpmanual.io/usage/settings/#customise-settings-sources) with the `AwsSsmSettingsSource`. Provide a prefix to SSM parameters via the `_secrets_dir` initialiser value or the `secrets_dir` Config value.

```py
from pydantic import BaseSettings
from pydantic_ssm_settings import AwsSsmSourceConfig


class WebserviceSettings(BaseSettings):
    some_val: str
    another_val: int

    class Config(AwsSsmSourceConfig):
        ...

SimpleSettings(_secrets_dir='/prod/webservice')
```

The above example will attempt to retreive values from `/prod/webservice/some_val` and `/prod/webservice/another_val` if not provided otherwise.
