Connect to a GCP database through proxy

Reading Time: < 1
Learn how to connect to a Google Cloud Platform (GCP) database that's not internet-accessible using a provided proxy.
gcp database connection via proxy

Table of Contents

To connect to a GCP database not accessible through internet, you need to pass through a proxy provided by GCP. To do so you need to use this command by replacing ${INSTANCE_NAME} by your proxy instance name and ${OTHER_INSTANCE_NAME} by your database instance name.

				
					docker run -it --rm \
-u "$(id -u):$(id -g)" \
    -v "$HOME/.config/gcloud/application_default_credentials.json:/config/gcloud/application_default_credentials.json" \
    -p 127.0.0.1:3307:3306 \
    gcr.io/cloudsql-docker/gce-proxy:latest \
    /cloud_sql_proxy \
    -instances=${INSTANCE_NAME}:europe-west1:${OTHER_INSTANCE_NAME}=tcp:0.0.0.0:3306 \
    -credential_file=/config/gcloud/application_default_credentials.json
				
			

Share it on:

Twitter
LinkedIn
Facebook
WhatsApp

About the Author

Gary Gitton
Hello, I'm Gary Gitton - an accomplished Software Engineer, Tech Lead, specializing in PHP, API Engineering, DevOps, and Cloud Management. Throughout my career, I've had the privilege to enhance multiple software solutions with my expertise in multiple languages and platforms. I bring my unique blend of technical and business acumen to every project, ensuring efficient, scalable, and innovative outcomes. I'm also passionate about fostering a culture of continuous learning, mentoring developers, and leading projects with agile methodologies. Whether concocting a bespoke API or orchestrating cloud environments, I'm committed to delivering quality and excellence. Let's connect and transform your vision into a digital reality.

You might also like