Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion pydantic_settings/sources/providers/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ def __init__(
env_nested_delimiter: str | None = '--',
env_parse_none_str: str | None = None,
env_parse_enums: bool | None = None,
version_id: str | None = None,
) -> None:
import_aws_secrets_manager()
self._secretsmanager_client = boto3_client('secretsmanager', region_name=region_name, endpoint_url=endpoint_url) # type: ignore
self._secret_id = secret_id
self._version_id = version_id
super().__init__(
settings_cls,
case_sensitive=case_sensitive,
Expand All @@ -58,7 +60,12 @@ def __init__(
)

def _load_env_vars(self) -> Mapping[str, str | None]:
response = self._secretsmanager_client.get_secret_value(SecretId=self._secret_id) # type: ignore
request = {'SecretId': self._secret_id}

if self._version_id:
request['VersionId'] = self._version_id

response = self._secretsmanager_client.get_secret_value(**request) # type: ignore

return parse_env_vars(
json.loads(response['SecretString']),
Expand Down