Google Professional Cloud Developer Question 423
Select 3Google Cloud PlatformYou are developing an application that needs to integrate with the Google Cloud Translation API to translate user-provided text. The application is deployed on Cloud Run. What steps should you take to securely authenticate and access the Translation API while following best practices?
- A
Use a service account with the appropriate IAM roles and grant it to the Cloud Run service.
- B
Embed the API key for the Translation API directly in your application's code for authentication.
- C
Enable the Translation API in your Google Cloud project.
- D
Use Application Default Credentials (ADC) to authenticate your application with the Translation API.
- E
Allow unauthenticated access to your Cloud Run service to simplify integration.
Show answer and explanation
Correct answers: A, C, D
Explanation
To securely integrate an application running on Cloud Run with the Google Cloud Translation API, you should enable the API in your project, use a service account with appropriate IAM roles, and rely on Application Default Credentials (ADC) for authentication. These practices ensure security and follow the principle of least privilege. Embedding API keys in code or allowing unauthenticated access are insecure and should be avoided.
- A. Correct.
Correct. Using a service account with the appropriate IAM roles (e.g., 'Cloud Translation API User') is the recommended approach to securely authenticate and access Google Cloud APIs like the Translation API.
- B. Incorrect.
Incorrect. Embedding API keys directly in code is a security risk because they could be exposed and misused if the codebase is compromised.
- C. Correct.
Correct. The Translation API must be enabled in your Google Cloud project to allow your application to make requests to it.
- D. Correct.
Correct. Using Application Default Credentials (ADC) is a best practice for authenticating applications running on Google Cloud services, as it automatically uses the service account assigned to your Cloud Run service.
- E. Incorrect.
Incorrect. Allowing unauthenticated access to your Cloud Run service is not secure and does not follow best practices for integrating with Google Cloud APIs.