Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

iogi/pydantic-google-secret-manager-json-test

Repository files navigation

pydantic-google-secret-manager-json-test

pydantic-settingsを拡張して、以下を実現するexampleです

  • Google Secret Managerの指定したsecretに格納されたJSONをparseして設定値として利用する
  • developmentではローカルの .env ファイルを利用する

要件

  • Python 3.14+ (動作確認環境)
  • gcloud CLI
  • uv

セットアップ

  1. 依存関係のインストール
    uv sync
  2. gcloudのログイン
    gcloud auth login
  3. settings.pyPROJECT_IDSECRET_NAME_PREFIX を適切な値に変更
  4. 指定した PROJECT_ID の Secret Manager で <SECRET_NAME_PREFIX>-staging<SECRET_NAME_PREFIX>-production の2つのsecretを作成し、以下のようなJSONを格納
    • staging用secretの中身例
      {
        "A": "A staging",
        "B": "B staging"
      }
    • production用secretの中身例
      {
        "A": "A prod",
        "B": "B prod"
      }

実行

ENV 指定なしでは development として扱われます

uv run main.py

ENVproduction に指定して実行

ENV=production uv run main.py

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages