| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
This sample integrates with the Identity Platform to authenticate users to the application and connects to a Cloud SQL postgreSQL database for data storage.
Use it with the End user Authentication for Cloud Run.
For more details on how to work with this sample read the Google Cloud Run Python Samples README.
Cloud Run services can be configured with Environment Variables. Required variables for this sample include:
OR
Other environment variables:
Set TABLE to change the postgreSQL database table name.
Set DB_HOST to use the proxy with TCP. See instructions below.
Set DB_SOCKET_PATH to change the directory when using the proxy with Unix sockets. See instructions below.
Both postgres-secrets.json and static/config.js should not be committed to a git repository and should be added to .gitignore.
Saving credentials directly as environment variables is convenient for local testing, but not secure for production; therefore using CLOUD_SQL_CREDENTIALS_SECRET in combination with the Cloud Secrets Manager is recommended.
To run this application locally, download and install the cloud_sql_proxy by following the instructions.
The proxy can be used with a TCP connection or a Unix Domain Socket. On Linux or Mac OS you can use either option, but on Windows the proxy currently requires a TCP connection.
Instructions to launch proxy with Unix Domain Socket
Instructions to launch proxy with TCP
Tests expect the Cloud SQL instance to already be created and environment Variables to be set.
pytest test_app.pyexport GOOGLE_CLOUD_PROJECT=<YOUR_PROJECT_ID>
export CLOUD_SQL_CONNECTION_NAME=<YOUR_CLOUD_SQL_CONNECTION_NAME>
export DB_PASSWORD=<POSTGRESQL_PASSWORD>
export IDP_KEY=<IDENTITY_PLATFORM_API_KEY> # See tutorial for creation of this key ("API_KEY")
pytest e2e_test.py| Back | FazBrowse Home | New Git URL |