Seamless settings management with Pydantic and Google Cloud Secret Manager
Pydantic's settings management capabilities make configuring your application easy across different environments, and you can easily extend it to new sources.
There are a few tried and trusted ways to pass settings to your Python code. Environment variables are one of those, `.env` files are another and command line arguments are yet another.
Many developers create custom solutions to solve the challenge of settings management. However, the well-known Pydantic package provides a solid implementation for settings management that we can extend when needed.
Using Pydantic's settings management, you can have a standardised solution across all your projects with the added benefit of quickly extending it to sources not supported out of the box.
It is common to use Google Cloud Secret Manager when deploying solutions to Google Cloud. It is unfortunately not supported as standard in Pydantic's settings management tooling. To demonstrate how you can extend Pydantic's settings management to connect to Google Cloud Secret Manager, I have created a GitHub repository with an example and a YouTube video to provide a quick overview. I hope you find this as useful as I have.
GitHub Repo: https://github.com/christo-olivier/pydantic-google-secrets