Google Cloud Professional Cloud Developer — Question 322
You are using the latest stable version of Python 3 to develop an API that stores data in a Cloud SQL database. You need to perform CRUD operations on the production database securely and reliably with minimal effort. What should you do?
Answer options
- A. 1. Use Cloud Composer to manage the connection to the Cloud SQL database from your Python application. 2. Grant an IAM role to the service account that includes the composer.worker permission.
- B. 1. Use the Cloud SQL API to connect to the Cloud SQL database from your Python application. 2. Grant an IAM role to the service account that includes the cloudsql.instances.login permission.
- C. 1. Use the Cloud SQL connector library for Python to connect to the Cloud SQL database through a Cloud SQL Auth Proxy. 2. Grant an IAM role to the service account that includes the cloudsql.instances.connect permission.
- D. 1. Use the Cloud SQL emulator to connect to the Cloud SQL database from Cloud Shell 2. Grant an IAM role to the user that includes the cloudsql.instances.login permission.
Correct answer: C
Explanation
The correct answer is C because using the Cloud SQL connector library with a Cloud SQL Auth Proxy provides a secure and straightforward method for connecting to the database. Option A is incorrect as Cloud Composer is not typically used for direct API access, while B does not utilize the recommended secure connector approach. Option D is also not suitable for production use as the emulator is intended for development and testing rather than production connections.