-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: update pydantic version and use settings class inste…
…ad of config
- Loading branch information
1 parent
aa0c65f
commit 55abf64
Showing
6 changed files
with
65 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,22 @@ | ||
# 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). | ||
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. initializer, 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. | ||
The simplest way to use this module is to inhert your settings class from `AwsSsmSettings`. This will overwrite the [`pydantic` settings sources order](https://docs.pydantic.dev/latest/concepts/pydantic_settings/#customise-settings-sources) with the `AwsSsmSettingsSource`. Provide a prefix to SSM parameters via the `_secrets_dir` initializer value or the `secrets_dir` Config value. | ||
|
||
```py | ||
from pydantic import BaseSettings | ||
from pydantic_ssm_settings import AwsSsmSourceConfig | ||
from pydantic_ssm_settings import AwsSsmSettings | ||
|
||
|
||
class WebserviceSettings(BaseSettings): | ||
class WebserviceSettings(AwsSsmSettings): | ||
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. | ||
The above example will attempt to retrieve values from `/prod/webservice/some_val` and `/prod/webservice/another_val` if not provided otherwise. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from .settings import AwsSsmSourceConfig | ||
from .settings import AwsSsmSettings | ||
|
||
__all__ = ("AwsSsmSourceConfig",) | ||
__all__ = ("AwsSsmSettings",) | ||
__version__ = "0.2.4" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters