Prepare and test your skills

Prepare and test your skills

Free sample question with answers and detailed explanation below. The Professional Cloud Developer practice bank has an additional 608 practice questions.Try 10 free realistic questions: instant score, no credit card, and no account required.
You are deploying a backend application on a new Compute Engine VM instance. The application uses a Google Cloud client library over REST to read, create, and delete objects in a single Cloud Storage bucket named order-receipts.
During setup, you configured the environment as follows:
roles/storage.objectAdmin to the service account at the project levelWhen testing the application, read requests succeed, but object uploads to order-receipts fail with an authorization error.
What should you do to resolve the error while adhering to the principle of least privilege?
roles/storage.objectAdmin directly on the order-receipts bucket.This approach narrows the IAM role binding from the project level down to the individual order-receipts bucket while leaving the Compute Engine VM's default OAuth 2.0 access scopes unchanged.
This configuration fails to resolve the upload authorization error because OAuth 2.0 access scopes and IAM permissions act as two separate layers of control, and both must allow an operation for REST-based client library requests to succeed:
https://www.googleapis.com/auth/devstorage.read_only, which restricts the VM to read-only Cloud Storage operations.roles/storage.objectAdmin grants full object management permissions on order-receipts, the client library's OAuth token lacks the scope required to write or delete objects.gcloud CLI and REST-based client libraries, though they do not apply to gRPC calls.The application only needed read-only access to objects in order-receipts (using roles/storage.objectViewer), or if the VM's access scope was also updated to https://www.googleapis.com/auth/cloud-platform.
https://www.googleapis.com/auth/cloud-platform, remove the project-level role binding, and grant roles/storage.objectAdmin on the order-receipts bucket only.cloud-platform scope with bucket-level IAM doesThis solution combines the recommended full Google Cloud OAuth 2.0 access scope (https://www.googleapis.com/auth/cloud-platform) on the Compute Engine VM with a resource-level IAM role binding (roles/storage.objectAdmin) applied solely to the order-receipts bucket.
https://www.googleapis.com/auth/devstorage.read_only, which blocks write and delete REST API calls from client libraries even when the attached service account has write IAM permissions. Switching the VM to the cloud-platform scope removes that OAuth bottleneck.roles/storage.objectAdmin directly on order-receipts limits the service account to reading, creating, and deleting objects only within that single bucket.roles/storage.objectAdmin provides object CRUD permissions without granting administrative control over bucket configurations or other Google Cloud services.cloud-platform scope avoids debugging mismatches between legacy VM scopes and evolving IAM policies.Google Cloud best practices recommend relying on IAM roles rather than coarse-grained OAuth access scopes for authorization. Pairing the cloud-platform scope with the narrowest predefined role at the lowest resource level satisfies both functional and security requirements.
roles/storage.objectAdmin with the roles/editor basic role on the project for the service account.roles/editor doesroles/editor is a basic IAM role (formerly called a primitive role) that grants thousands of permissions to read, create, modify, and delete resources across almost all Google Cloud services within a project.
This option fails on two fronts—it neither fixes the upload failure nor follows the principle of least privilege:
https://www.googleapis.com/auth/devstorage.read_only active on the instance. Because OAuth 2.0 scopes independently restrict REST client library calls, the VM still cannot write to Cloud Storage regardless of how broad the service account's IAM role is.roles/editor at the project level gives the service account write and delete permissions across Compute Engine, Cloud SQL, Pub/Sub, all Cloud Storage buckets, and dozens of other services.roles/editor bypasses trust boundaries between application components.There is virtually no production scenario where roles/editor combined with restrictive default scopes would be the correct solution; basic roles are only occasionally acceptable in isolated development or test environments that require broad cross-service access.
https://www.googleapis.com/auth/cloud-platform and keep the roles/storage.objectAdmin role binding at the project level.Setting the OAuth 2.0 access scope to https://www.googleapis.com/auth/cloud-platform removes the coarse-grained OAuth restriction imposed by the VM's default scopes, while keeping roles/storage.objectAdmin at the project level grants the service account administrative control over Cloud Storage objects across the entire project.
Although this change resolves the upload error, it fails to follow the principle of least privilege. In Google Cloud's resource hierarchy, IAM allow policies are inherited from parent resources by all child resources:
roles/storage.objectAdmin at the project level automatically grants the service account permission to read, overwrite, and delete objects in every Cloud Storage bucket in the project.order-receipts, exposing other buckets in the same project creates unnecessary security risk if the VM or service account is compromised.cloud-platform intentionally delegates all fine-grained authorization to IAM, so IAM bindings must be scoped tightly.The backend application legitimately needed to read, create, and delete objects across all Cloud Storage buckets in the project rather than a single specific bucket.
Answer them yourself and get your score the moment you finish. No account needed.
Full access includes
Keep the momentum going with these hand-picked practice scenarios
Last updated Validated