CLOUD-DATABASE-ENGINEER practice question 22 of 25
You are writing an application that will run on Cloud Run and require a database running in the Cloud SQL managed service. You want to secure this instance so that it only receives connections from applications running in your VPC environment in Google Cloud. What should you do?
Full set: 141 questionsTo securely connect a Cloud Run application to a Cloud SQL instance exclusively within a VPC, you must prevent any public internet exposure. This is achieved by assigning a private (internal) IP address to the Cloud SQL instance. This requires configuring a private services access connection between your VPC and the Google-managed services. Because Cloud Run services operate in a serverless environment outside your specific VPC, a Serverless VPC Access connector is necessary to bridge the gap and route traffic from Cloud Run into your VPC. Finally, serverless applications like Cloud Run can scale rapidly, potentially creating many new connections and exhausting the database's connection limit. Using a connection pool is a critical best practice to manage and reuse connections efficiently, ensuring application stability and performance.
A: Using a public IP address exposes the database to the public internet, which contradicts the requirement to only allow connections from the VPC environment. B: This option also uses a public IP address, which is less secure than a private IP and does not meet the core security requirement of the question. C: While the networking setup is correct, using the Cloud SQL Auth proxy is not the most critical final step. Connection pooling is more important for managing connections from a scalable service like Cloud Run.
1. Google Cloud Documentation - Connecting from Cloud Run (private IP): "To connect to a Cloud SQL instance from a Cloud Run service... using a private IP address, you need to use a Serverless VPC Access connector." This document also explicitly recommends connection pooling: "To prevent exceeding the connection limit, we recommend that you use a connection pooler." (Source: Google Cloud, Cloud SQL for MySQL Documentation, "Connecting from Cloud Run", Section: "Connecting using private IP").
2. Google Cloud Documentation - Configuring private IP: "Configuring a Cloud SQL instance to use private IP requires private services access. Private services access enables you to create private connections between your VPC network and the Google Cloud VPC network where your Cloud SQL instance resides." (Source: Google Cloud, Cloud SQL for MySQL Documentation, "Configuring private IP", Section: "About private services access").
3. Google Cloud Documentation - Serverless VPC Access: "Serverless VPC Access enables you to connect directly to your VPC network from serverless environments such as Cloud Run, App Engine, or Cloud Functions. Configuring Serverless VPC Access allows your serverless environment to send requests to your VPC network by using internal DNS and internal IP addresses..." (Source: Google Cloud, VPC Documentation, "Serverless VPC Access overview").
4. Google Cloud Documentation - Managing database connections: "We recommend using a connection pooler to manage your connections... Applications in serverless environments (such as Cloud Functions, Cloud Run, and App Engine) can create a large number of connections to your database." (Source: Google Cloud, Cloud SQL for MySQL Documentation, "Managing database connections", Section: "Connection pooling").
Keep practicing
Take the free CLOUD-DATABASE-ENGINEER practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other CLOUD-DATABASE-ENGINEER practice questions
- Question 1Your DevOps team is using Terraform to deploy applications and Cloud SQL databases. After…
- Question 2Your company is developing a new global transactional application that must be ACID-compl…
- Question 3You are designing a database strategy for a new web application. You plan to start with a…
- Question 4Your application uses Cloud SQL for MySQL. Your users run reports on data that relies on …
- Question 5You plan to use Database Migration Service to migrate data from a PostgreSQL on-premises …
- Question 6You host an application in Google Cloud. The application is located in a single region an…
