Google Cloud Associate Cloud Engineer — Question 145
You received a JSON file that contained a private key of a Service Account in order to get access to several resources in a Google Cloud project. You downloaded and installed the Cloud SDK and want to use this private key for authentication and authorization when performing gcloud commands. What should you do?
Answer options
- A. Use the command gcloud auth login and point it to the private key.
- B. Use the command gcloud auth activate-service-account and point it to the private key.
- C. Place the private key file in the installation directory of the Cloud SDK and rename it to ג€credentials.jsonג€.
- D. Place the private key file in your home directory and rename it to ג€GOOGLE_APPLICATION_CREDENTIALSג€.
Correct answer: B
Explanation
The correct command is gcloud auth activate-service-account, which is specifically designed for activating a service account using its private key. The other options are incorrect because gcloud auth login is meant for user accounts, and simply placing the key file in specific locations or renaming it does not authenticate the service account properly.