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.
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
Connect a Python application on Cloud Run to a Cloud SQL for PostgreSQL database