Google Professional Cloud Developer Question 398
Select 4Google Cloud PlatformYou are developing a serverless application on Google Cloud that uses Cloud Run to handle HTTP requests. Your application needs to connect to a Cloud SQL database securely. Which steps should you take to manage the connection effectively?
- A
Enable the Cloud SQL Admin API and configure the Cloud SQL instance with a private IP.
- B
Use the Cloud SQL Auth proxy to handle authentication and connection pooling.
- C
Assign the Cloud Run service a service account with Cloud SQL Client role permissions.
- D
Store the Cloud SQL database credentials in a configuration file and upload it to Cloud Storage for secure access.
- E
Configure the Cloud Run service to connect to the Cloud SQL instance using the instance connection name.
Show answer and explanation
Correct answers: A, B, C, E
Explanation
To securely and effectively connect a Cloud Run service to a Cloud SQL database, you need to follow best practices such as enabling required APIs, using the Cloud SQL Auth proxy for authentication and connection pooling, assigning appropriate IAM roles to the service account, and configuring the instance connection name. Avoid storing credentials in plain text or insecure locations like configuration files.
- A. Correct.
Correct. Enabling the Cloud SQL Admin API and configuring the instance with a private IP ensures secure and manageable connections.
- B. Correct.
Correct. The Cloud SQL Auth proxy handles authentication and connection pooling efficiently, reducing connection overhead.
- C. Correct.
Correct. Assigning the Cloud Run service a service account with the Cloud SQL Client role ensures it has the necessary permissions to access the database.
- D. Incorrect.
Incorrect. Storing credentials in a configuration file and uploading it to Cloud Storage is insecure and does not follow best practices for secret management.
- E. Correct.
Correct. The instance connection name is required for the Cloud Run service to connect to the Cloud SQL instance.