Skip to content

Latest commit

 

History

History
27 lines (12 loc) · 1.23 KB

File metadata and controls

27 lines (12 loc) · 1.23 KB

Connect a Python application on Cloud Run to a Cloud SQL for PostgreSQL database

Using Cloud SQL Python connector to securely connect your Python application to your Cloud SQL database.

This repository will demonstrate how to connect a Python application on Cloud Run to a Cloud SQL for PostgreSQL database securely with a service account using IAM Authentication.

Environment Variables

To run this project, you will need to add the following environment variables to your .env file

INSTANCE_CONNECTION_NAME = "{PROJECT_ID}:{REGION}:{INSTANCE_NAME}"

DB_USER = "sql-client-service-account@{PROJECT_ID}.iam"

DB_PASS = (optional, if followed the cloudsql.iam_authentication)

PRIVATE_IP = (conditional) if true it will use PRIVATE_IP is not set it will use PUBLIC_IP to connect to Cloud SQL

DB_NAME = your-database

Supported Articles

Connect a Python application on Cloud Run to a Cloud SQL for PostgreSQL database