Skip to content

Latest commit

 

History

History
24 lines (15 loc) · 1.4 KB

README.md

File metadata and controls

24 lines (15 loc) · 1.4 KB

pydantic-ssm-settings

Replace Pydantic's builtin Secret Support with a configuration provider that loads parameters from AWS Systems Manager Parameter Store. Parameters are loaded lazily, meaning that they are only requested from AWS if they are not provided via standard 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 with the AwsSsmSettingsSource. Provide a prefix to SSM parameters via the _secrets_dir initialiser value or the secrets_dir Config value.

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.