Google Cloud Professional Cloud Developer — Question 342
You are developing an application that needs to connect to a Cloud SQL for PostgreSQL database by using the Cloud SQL Auth Proxy. The Cloud SQL Auth Proxy is hosted in a different Google Cloud VPC network. The Cloud SQL for PostgreSQL instance has public and private IP addresses. You are required to use the private IP for security reasons. When testing the connection to the Cloud SQL instance, you can connect by using the public IP address, but you are unable to connect by using the private IP address. How should you fix this issue?
Answer options
- A. Run the Cloud SQL Auth Proxy as a background service.
- B. Add the --private-ip option when starting the Cloud SQL Auth Proxy.
- C. Set up VPC Network Peering between your VPC and the VPC where the Cloud SQL instance is deployed.
- D. Grant yourself the IAM role that provides access to the Cloud SQL instance.
Correct answer: C
Explanation
The correct answer is C because VPC Network Peering allows the two VPCs to communicate privately, enabling access to the Cloud SQL instance via its private IP. Options A and B do not address the networking issue, while option D is unnecessary if the network configuration is not set up correctly.