Google Professional Cloud Developer Question 230
Single answerGoogle Cloud PlatformYou are developing a web application that needs to securely connect to a Cloud SQL instance from a Compute Engine VM. The application should not expose database credentials and must follow Google Cloud’s recommended practices. Which method should you use to authenticate your application to the Cloud SQL instance?
- A
Use the Cloud SQL Auth proxy to establish a secure connection using the service account attached to the Compute Engine VM.
- B
Embed the database username and password in the application code to authenticate directly with the Cloud SQL instance.
- C
Use a static API key stored in a configuration file to authenticate the application with the Cloud SQL instance.
- D
Manually create and manage SSL certificates to authenticate and connect to the Cloud SQL instance.
Show answer and explanation
Correct answer: A
Explanation
The most secure and recommended method for authenticating to a Cloud SQL instance is by using the Cloud SQL Auth proxy. It simplifies the connection process by automatically handling authentication with the attached service account, eliminating the need to manage credentials or SSL certificates manually.
- A. Correct.
Correct. The Cloud SQL Auth proxy is the recommended way to securely connect to a Cloud SQL instance. It uses IAM-based authentication, leveraging the service account attached to the Compute Engine VM, eliminating the need to manage credentials manually.
- B. Incorrect.
Incorrect. Embedding database credentials in application code is insecure and highly discouraged. It increases the risk of credentials being exposed.
- C. Incorrect.
Incorrect. Using a static API key is not a valid method for authenticating to Cloud SQL. API keys are generally used for other Google Cloud services and are not recommended for secure authentication to databases.
- D. Incorrect.
Incorrect. While SSL certificates can be used, manually managing them increases operational overhead and is not the recommended practice for connecting to Cloud SQL in Google Cloud.