Medium1 markMultiple Choice
Domain 5.2: Managing service accountsDomain 5Service AccountsSecurity Best PracticesCompute Engine

GCP ACE · Question 46 · Domain 5.2: Managing service accounts

You are deploying a custom application on a Compute Engine VM. The application needs to read configuration files from a specific Cloud Storage bucket.

What is the MOST secure way to grant the VM access to the bucket?

Answer options:

A.

Create a custom service account, grant it the roles/storage.objectViewer role on the bucket, and attach the service account to the VM.

B.

Use the default Compute Engine service account, as it automatically has Editor access to the project.

C.

Generate a JSON key for a service account, store it on the VM, and configure the application to authenticate using the key file.

D.

Make the Cloud Storage bucket public so the VM can read it without authentication.

How to approach this question

Apply the principle of least privilege. Avoid default accounts with broad access, and avoid managing physical keys when GCP can do it natively.

Full Answer

A.Create a custom service account, grant it the `roles/storage.objectViewer` role on the bucket, and attach the service account to the VM.✓ Correct
Create a custom service account, grant it the roles/storage.objectViewer role on the bucket, and attach the service account to the VM.
The best practice for granting VMs access to GCP resources is to create a user-managed (custom) service account, grant that specific account only the permissions it needs (e.g., `roles/storage.objectViewer` on the specific bucket), and attach that service account to the VM during creation. The application can then use Application Default Credentials (ADC) to authenticate securely without you ever needing to manage or download JSON keys.

Common mistakes

Using the default compute service account out of convenience, which grants the VM Editor access to the entire project.

Practice the full GCP Associate Cloud Engineer Practice Exam 5

50 questions · hints · full answers · grading

More questions from this exam