Skip to content

Conversation

adrianohrl
Copy link
Contributor

During testing and development phases, I use a motoserver docker container to interact with my AWS resources of my application locally.

I was able to connect with motoserver by using the following code:

    @classmethod
    def settings_customise_sources(
        cls,
        settings_cls: type[BaseSettings],
        init_settings: PydanticBaseSettingsSource,
        env_settings: PydanticBaseSettingsSource,
        dotenv_settings: PydanticBaseSettingsSource,
        file_secret_settings: PydanticBaseSettingsSource,
    ) -> tuple[PydanticBaseSettingsSource, ...]:
        aws_secrets_manager_settings = AWSSecretsManagerSettingsSource(
            settings_cls,
            secret_id=os.getenv('APP_SECRETS_MANAGER_SECRET'),
            region_name=os.getenv('AWS_DEFAULT_REGION'),
            endpoint_url=os.getenv('AWS_SECRETS_MANAGER_ENDPOINT'),
            env_prefix='',
            env_nested_delimiter='__',
            case_sensitive=True,
        )
        return (
            init_settings,
            env_settings,
            dotenv_settings,
            file_secret_settings,
            aws_secrets_manager_settings,
        )

My proposal keeps the original behavior in the AWSSecretsManagerSettingsSource class and add a more complete configuration to interact with the AWS Secrets Manager provider.

During testing and development phases, I use a `motoserver` docker container to interact with my AWS resources of my application locally. 

I was able to connect with `motoserver` by using the following code:

```python
    @classmethod
    def settings_customise_sources(
        cls,
        settings_cls: type[BaseSettings],
        init_settings: PydanticBaseSettingsSource,
        env_settings: PydanticBaseSettingsSource,
        dotenv_settings: PydanticBaseSettingsSource,
        file_secret_settings: PydanticBaseSettingsSource,
    ) -> tuple[PydanticBaseSettingsSource, ...]:
        aws_secrets_manager_settings = AWSSecretsManagerSettingsSource(
            settings_cls,
            secret_id=os.getenv('APP_SECRETS_MANAGER_SECRET'),
            region_name=os.getenv('AWS_DEFAULT_REGION'),
            endpoint_url=os.getenv('AWS_SECRETS_MANAGER_ENDPOINT'),
            env_prefix='',
            env_nested_delimiter='__',
            case_sensitive=True,
        )
        return (
            init_settings,
            env_settings,
            dotenv_settings,
            file_secret_settings,
            aws_secrets_manager_settings,
        )
```

My proposal keeps the original behavior in the `AWSSecretsManagerSettingsSource` class and add a more complete configuration to interact with the AWS Secrets Manager provider.
@hramezani
Copy link
Member

Thanks @adrianohrl

@hramezani hramezani merged commit 53ade97 into pydantic:main Aug 6, 2025
19 checks passed
@adrianohrl adrianohrl deleted the patch-1 branch August 6, 2025 18:06
@adrianohrl
Copy link
Contributor Author

adrianohrl commented Aug 12, 2025

@hramezani, is it possible to release a new version so that this new feature become available?

@hramezani
Copy link
Member

@hramezani, is it possible to release a new version so that this new feature become available?

I am busy these days and also waiting for some PRs.
I will probably do it next week. Please ping me here again if I forgot to do it.
Thanks!

@hramezani
Copy link
Member

pydantic-settings 2.11.0 has been released!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants