Google Professional Cloud Developer Question 422
Select 3Google Cloud PlatformYou are developing a serverless application running on Cloud Run that needs to integrate with the Google Cloud Translation API to dynamically translate user-provided content. To achieve this, which of the following steps should you take to ensure secure and efficient integration?
- A
Assign the Cloud Translation API role to the Cloud Run service account.
- B
Use an API key for authenticating requests to the Cloud Translation API from your application.
- C
Leverage the Google Cloud client libraries to interact with the Translation API.
- D
Store the service account key in your application code for authentication.
- E
Ensure the necessary IAM permissions for the Translation API are granted to the Cloud Run service account.
Show answer and explanation
Correct answers: A, C, E
Explanation
To securely integrate with Google Cloud APIs, such as the Translation API, the best practice is to use IAM roles and service accounts for authentication. By assigning the appropriate role to the Cloud Run service account and leveraging the Google Cloud client libraries, you avoid hardcoding sensitive credentials and ensure seamless and secure API interactions.
- A. Correct.
Correct: Assigning the Cloud Translation API role to the Cloud Run service account ensures that the application has the required permissions to call the API securely without embedding credentials.
- B. Incorrect.
Incorrect: Using an API key is not recommended, as API keys are less secure compared to using service accounts and IAM roles. Service accounts provide a more secure and manageable way to authenticate.
- C. Correct.
Correct: Google Cloud client libraries simplify interactions with APIs, providing built-in support for authentication and error handling.
- D. Incorrect.
Incorrect: Storing service account keys in application code is a security risk and violates Google Cloud best practices. Instead, rely on the service account attached to the Cloud Run service.
- E. Correct.
Correct: Ensuring the service account has the required IAM permissions allows the application to access the Translation API securely and avoids runtime authorization errors.