Google Professional Cloud Developer Question 108
Single answerGoogle Cloud PlatformYou are developing a cloud-based application that requires secure access to an external API. The API key for accessing the external API must be stored securely, rotated periodically, and accessed programmatically by the application. Which approach should you use to meet these requirements?
- A
Store the API key in a configuration file within the application code and update it manually when it changes.
- B
Use Google Cloud Secret Manager to store the API key, grant the application access to the secret, and implement automated rotation.
- C
Embed the API key directly into the application source code and use a version control system to manage updates.
- D
Store the API key in a Google Cloud Storage bucket and use a publicly accessible URL for the application to retrieve it when needed.
Show answer and explanation
Correct answer: B
Explanation
Google Cloud Secret Manager is specifically designed for securely managing and accessing application secrets like API keys. It provides strong access controls, integrates easily with Google Cloud services, and supports automated secret rotation, which aligns with best practices for secure application development.
- A. Incorrect.
Storing the API key in a configuration file within the application code is insecure and requires manual updates, which is error-prone and not scalable. This does not meet the security or rotation requirements.
- B. Correct.
Using Google Cloud Secret Manager is the recommended approach. It allows you to securely store secrets like API keys, grant fine-grained access to applications, and implement automated rotation for better security.
- C. Incorrect.
Embedding the API key in the application source code is a security risk. If the source code is exposed (e.g., in a public repository), the API key could be compromised.
- D. Incorrect.
Storing the API key in a Google Cloud Storage bucket with a publicly accessible URL is highly insecure. Anyone with the URL could access the key, resulting in a significant security risk.