Google Associate Cloud Engineer Question 374
Select 2Google Cloud PlatformAs a Google Cloud Associate Cloud Engineer, you need to generate short-lived credentials for a service account to allow a third-party application to access resources temporarily. Which of the following steps should you take to achieve this?
- A
Use the 'gcloud iam service-accounts' command to create a new service account key file.
- B
Utilize the 'gcloud auth application-default login' command to generate temporary credentials.
- C
Create an OAuth 2.0 access token using the service account's private key.
- D
Use the 'gcloud iam service-accounts keys create' command to generate a JSON key file.
- E
Leverage the 'gcloud auth print-access-token' command to obtain a short-lived access token.
Show answer and explanation
Correct answers: C, E
Explanation
To generate short-lived credentials for a service account, you can create an OAuth 2.0 access token using the service account's private key and leverage the 'gcloud auth print-access-token' command to obtain a short-lived access token. These tokens are temporary and suitable for granting limited-time access to resources.
- A. Incorrect.
Creating a new service account key file doesn't create short-lived credentials; it creates long-lived credentials.
- B. Incorrect.
'gcloud auth application-default login' is used for user authentication, not for service accounts.
- C. Correct.
Creating an OAuth 2.0 access token using the service account's private key is a valid method to generate short-lived credentials.
- D. Incorrect.
Generating a JSON key file with 'gcloud iam service-accounts keys create' results in long-lived credentials.
- E. Correct.
The 'gcloud auth print-access-token' command can be used to obtain a short-lived access token for a service account.