All practice questions

1591 questions

Question 1381Question

A system administrator is deploying a custom Virtual Private Cloud (VPC) network to host internal microservices in Google Cloud. The microservices run on Compute Engine virtual machines that do not have external public IP addresses assigned. These instances must be able to reach Google Cloud Storage buckets and BigQuery API endpoints securely without exposing traffic to the public internet. Which configuration option must be enabled on the subnet to meet this requirement?

Show answer & explanation

Answer: Enable Private Google Access on the subnet.

Answer

Enable Private Google Access on the subnet to allow virtual machines with only internal IP addresses to reach Google Cloud APIs and services.
Enabling Private Google Access on a subnet allows Compute Engine VMs that have only private internal IP addresses to communicate with Google services (such as Cloud Storage and BigQuery) via Google's internal network routes.

Step-by-Step Solution

1
Analyze the network requirements of the virtual machines
The Compute Engine VMs have internal IP addresses only and require connectivity to Google API endpoints (Cloud Storage and BigQuery).
Without public IP addresses or Cloud NAT, standard outbound internet access is disabled.
2
Evaluate Google Cloud networking features for private Google service reachability
Private Google Access is a subnet-level setting that enables instances without external IP addresses to send traffic to Google APIs.
Traffic stays within Google's network infrastructure and reaches default internal routes for Google APIs.
3
Select the correct subnet setting during or after deployment
Setting `--enable-private-ip-google-access` via gcloud CLI or toggling Private Google Access on the subnet in Cloud Console fulfills the requirement.
It directly satisfies the access requirement without requiring external IPs, Cloud NAT, or IAM broad permissions.

Key Concept

Private Google Access Subnet Configuration
Estimated Time:1m 15s
Question 1382Question

An integration engineer must grant a third-party application service account access to publish metric events to a single Cloud Pub/Sub topic named `events-telemetry` within the GCP project `analytics-prod-88`. The application must not be granted permissions to manage Pub/Sub topics or publish messages to any other topics. Which configuration adheres to the principle of least privilege?

Show answer & explanation

Answer: Grant the Pub/Sub Publisher role (roles/pubsub.publisher) to the service account directly on the `events-telemetry` topic resource.

Answer

Grant the predefined Pub/Sub Publisher role (roles/pubsub.publisher) directly on the specific topic resource.
Granting the predefined Pub/Sub Publisher role (`roles/pubsub.publisher`) directly on the target Pub/Sub topic resource enforces the principle of least privilege by scoping permissions strictly to the single topic required.

Step-by-Step Solution

1
Identify the minimum required IAM permission for the task
The application only requires message publishing capabilities on a single target Pub/Sub topic.
Following the principle of least privilege minimizes security exposure by restricting actions.
2
Select the appropriate role type and resource binding scope
Apply the predefined role `roles/pubsub.publisher` directly on the IAM policy binding for the `events-telemetry` topic.
Resource-level bindings prevent granting publishing permissions across other topics in the project or organization.

Key Concept

Applying Least Privilege with Resource-Level IAM Roles
Question 1383Question

A cloud administrator needs to deploy a custom Virtual Private Cloud (VPC) environment in Google Cloud using the gcloud CLI. The environment must host a web application and include a custom network, a region-specific subnet, an ingress firewall rule restricted by network target tags, and a virtual machine instance. Arrange the following administrative steps in the correct chronological execution order from first to last.

Drag items to arrange them in the correct order

Show answer & explanation

Answer

The correct execution order is: 1) Create the custom VPC network (`prod-vpc`), 2) Provision the regional subnet (`prod-subnet-uscentral1`), 3) Create the ingress firewall rule (`allow-prod-https`), 4) Deploy the Compute Engine instance (`web-vm-1`).
In Google Cloud networking, resource creation follows a strict strict dependency hierarchy. First, the custom VPC network (`prod-vpc`) must be initialized using `--subnet-mode=custom` so that default subnets are not created. Next, a specific regional subnet (`prod-subnet-uscentral1`) must be created within that network to define the primary internal CIDR range. Third, the ingress firewall rule (`allow-prod-https`) is added to the network to allow HTTPS traffic on TCP port 443 targeted to the tag `web-server`. Finally, the Compute Engine virtual machine (`web-vm-1`) is created inside the subnet and assigned the `web-server` tag, completing the deployment.

Step-by-Step Solution

1
Create the custom-mode VPC network using `gcloud compute networks create prod-vpc --subnet-mode=custom`.
An empty custom VPC network container without auto-generated subnets is created.
Google Cloud requires a VPC network to exist before subnets or firewall rules can be attached to it.
2
Provision a regional subnet using `gcloud compute networks subnets create prod-subnet-uscentral1 --network=prod-vpc --region=us-central1 --range=10.100.0.0/24`.
A custom IP range (`10.100.0.0/24`) is allocated in `us-central1` under `prod-vpc`.
Compute Engine virtual machines in custom-mode networks require an existing subnet in their target region to bind their primary internal IP.
3
Define the ingress firewall rule using `gcloud compute firewall-rules create allow-prod-https --network=prod-vpc --allow=tcp:443 --target-tags=web-server`.
Firewall policy is attached to `prod-vpc` to permit HTTPS traffic to instances tagged `web-server`.
Establishing security policies on the network before instance creation ensures incoming traffic is properly controlled as soon as the instance provisions.
4
Deploy the Compute Engine instance using `gcloud compute instances create web-vm-1 --zone=us-central1-a --subnet=prod-subnet-uscentral1 --tags=web-server`.
The VM instance boots up attached to `prod-subnet-uscentral1` with the `web-server` network tag applied.
Instance creation requires both the target subnet and the target tags specified in previous steps.

Key Concept

Resource dependency hierarchy in GCP VPC network provisioning (VPC Network → Subnet → Firewall Rule → VM Instance).
Question 1384Question

A DevOps team needs to grant a newly onboarded service account permissions to deploy and manage Cloud Run services within project `proj-staging-101`, as well as read build artifacts stored inside a specific Cloud Storage bucket named `bkt-staging-artifacts-99`. To adhere strictly to the Principle of Least Privilege without granting unnecessary permissions across other resources or projects, which TWO IAM role assignments should the team configure?

Select all that apply

Show answer & explanation

Answer: Grant Cloud Run Developer (`roles/run.developer`) on project `proj-staging-101`.; Grant Storage Object Viewer (`roles/storage.objectViewer`) directly on the `bkt-staging-artifacts-99` bucket.

Answer

Assign Cloud Run Developer (roles/run.developer) at the project level and Storage Object Viewer (roles/storage.objectViewer) directly on the specific Cloud Storage bucket.
Combining the predefined Cloud Run Developer role at the project level with the Storage Object Viewer role restricted to the targeted bucket provides the exact capabilities required while avoiding excessive permissions across other services or projects.

Step-by-Step Solution

1
Identify the minimal role required for Cloud Run management.
Cloud Run Developer (roles/run.developer) provides service management rights without broad administrative access.
Predefined roles are preferred over primitive roles (such as Editor) to follow the Principle of Least Privilege.
2
Identify the narrowest resource boundary for Cloud Storage access.
Applying Storage Object Viewer at the bucket resource scope limits access exclusively to `bkt-staging-artifacts-99`.
Assigning roles higher up in the resource hierarchy (such as at the Folder level) causes downstream inheritance across unintended projects and buckets.

Key Concept

Applying Least Privilege using Predefined Roles and Resource-Level IAM Bindings
Estimated Time:1m 30s
Question 1385Question

An organization maintains a Cloud DNS private managed zone named `corp-internal-zone` that provides internal domain name resolution for workloads. The private zone is currently associated with a single Virtual Private Cloud (VPC) network named `vpc-analytics`. An operations engineer must extend DNS resolution for `corp-internal-zone` so that virtual machines in a second VPC network named `vpc-services` can also resolve these internal DNS records without removing access from `vpc-analytics`. Which `gcloud` command should the engineer run to accomplish this goal?

Show answer & explanation

Answer: gcloud dns managed-zones update corp-internal-zone --networks=vpc-analytics,vpc-services

Answer

The command `gcloud dns managed-zones update corp-internal-zone --networks=vpc-analytics,vpc-services` is correct because updating a private Cloud DNS zone's authorized VPC networks replaces the existing list with the values supplied to the `--networks` flag.
Updating a Cloud DNS private zone to authorize multiple VPC networks requires passing a complete, comma-separated list of all VPC networks to the `--networks` flag of `gcloud dns managed-zones update`. Including both `vpc-analytics` and `vpc-services` ensures both networks maintain private DNS resolution.

Step-by-Step Solution

1
Identify the target resource and command group for managing Cloud DNS zone configurations.
Determined that private zone network bindings are updated using the `gcloud dns managed-zones update` command.
VPC network visibility is a property of the managed zone resource.
2
Determine the required behavior of the `--networks` flag during a zone update.
Recognized that the `--networks` flag replaces the entire list of authorized VPC networks rather than incrementally appending.
To preserve existing access for `vpc-analytics` while adding `vpc-services`, both networks must be explicitly listed as a comma-separated string.

Key Concept

Cloud DNS Private Zone VPC Network Binding Management
Question 1386Question

An enterprise organization uses a multi-project structure in Google Cloud. A Cloud Engineer sets up an organization-level aggregated Log Router sink to export all Cloud Audit logs from all projects to a BigQuery dataset hosted in a dedicated security telemetry project (proj-sec-logs). After configuring the sink filter and destination, the engineer observes that audit logs are not populating the target BigQuery tables. What step must the engineer perform to ensure logs are successfully delivered to BigQuery?

Show answer & explanation

Answer: Grant the unique Writer Identity service account generated by the sink the BigQuery Data Editor role on the destination dataset.

Answer

Grant the unique Writer Identity service account generated by the sink the BigQuery Data Editor role on the destination dataset.
When a Log Router sink routes logs to a destination in another project (such as a BigQuery dataset in a central security project), Google Cloud creates a unique service account called a Writer Identity for that sink. To complete log delivery, that Writer Identity service account must be granted appropriate write permissions (such as BigQuery Data Editor) directly on the target dataset.

Step-by-Step Solution

1
Identify the service account identity associated with the Log Router sink.
When a Log Router sink is created (especially cross-project or aggregated sinks), Google Cloud assigns a unique Writer Identity (service account email address) to the sink.
Log sink operations execute using dedicated service identities to ensure secure and auditable log delivery.
2
Determine the destination permissions required for BigQuery ingestion.
Writing entries into a BigQuery dataset requires the BigQuery Data Editor (roles/bigquery.dataEditor) role on the destination dataset.
Log Router sinks require dataset-level write access to insert incoming log records into tables.
3
Apply IAM role binding to the sink's Writer Identity on the destination BigQuery dataset.
The sink Writer Identity obtains authorization to create and append table data in the destination security project.
Explicit IAM role assignment on the destination dataset resolves authorization failures during log routing.

Key Concept

Cross-Project Log Router Sink Ingestion and Writer Identity Authorization
Estimated Time:2m 0s
Question 1387Question

A DevOps team is configuring an automated deployment workflow executed from a developer workstation to provision cloud infrastructure inside a staging project named `proj-staging-884`. Organizational security directives prohibit exporting long-lived JSON service account keys to developer machines and mandate the principle of least privilege. The workflow requires creating a dedicated user-managed service account named `deployer-sa` in `proj-staging-884`, granting this service account the `roles/resourcemanager.projectIamAdmin` role on `proj-staging-884`, and enabling developer `[email protected]` to generate short-lived credentials for `deployer-sa` via impersonation. Which sequence of `gcloud` commands correctly fulfills these security and operational requirements?

Show answer & explanation

Answer: Run `gcloud iam service-accounts create deployer-sa --project=proj-staging-884`, bind `roles/resourcemanager.projectIamAdmin` to `serviceAccount:[email protected]` on project `proj-staging-884`, and grant `roles/iam.serviceAccountTokenCreator` to `user:[email protected]` on the `deployer-sa` service account resource.

Answer

The correct sequence creates the user-managed service account in the staging project, assigns the predefined `roles/resourcemanager.projectIamAdmin` role to the service account on the project, and grants `roles/iam.serviceAccountTokenCreator` to the specific user on the service account resource to enable short-lived token generation without static keys.
Creating the service account and assigning `roles/iam.serviceAccountTokenCreator` directly on that service account to the developer user allows keyless impersonation using short-lived credentials while enforcing least privilege with `roles/resourcemanager.projectIamAdmin`.

Step-by-Step Solution

1
Create the user-managed service account
Service account `[email protected]` is provisioned.
Dedicated workloads require user-managed service accounts rather than built-in default accounts.
2
Bind least-privilege predefined IAM role to the service account
Service account receives `roles/resourcemanager.projectIamAdmin` on `proj-staging-884`.
Assigning predefined roles adheres to least privilege while providing needed management rights.
3
Grant token creation role on the service account to the developer identity
User `[email protected]` gains `roles/iam.serviceAccountTokenCreator` on the service account.
Allows short-lived OAuth2 access token generation for impersonation without creating long-lived private key files.

Key Concept

Keyless service account management and IAM impersonation via `roles/iam.serviceAccountTokenCreator`.
Question 1388Question

A Cloud Engineer must set up telemetry collection for a fleet of Linux-based Compute Engine virtual machines. The requirements state that custom application log files must be ingested into Cloud Logging, and system-level performance metrics (such as memory utilization and disk space usage) must be reported to Cloud Monitoring. Access permissions must strictly adhere to the principle of least privilege. Which TWO actions should the engineer take to achieve this configuration? (Select TWO.)

Select all that apply

Show answer & explanation

Answer: Install and configure the unified Google Cloud Ops Agent on each Compute Engine instance.; Grant the Logs Writer (roles/logging.logWriter) and Monitoring Metric Writer (roles/monitoring.metricWriter) predefined roles to the VM instance service account.

Answer

To collect system-level memory metrics alongside custom application logs while enforcing least privilege, the engineer must install the unified Google Cloud Ops Agent on the virtual machines and grant the service account attached to the instances the Logs Writer (roles/logging.logWriter) and Monitoring Metric Writer (roles/monitoring.metricWriter) predefined roles.
Installing the Google Cloud Ops Agent is the Google-recommended approach for gathering both system metrics (like memory) and application log files from Compute Engine VMs. Combining this agent deployment with targeted predefined roles (roles/logging.logWriter and roles/monitoring.metricWriter) ensures the VM service account has only the permissions required to send observability data to Google Cloud.

Step-by-Step Solution

1
Deploy the unified telemetry agent.
Install Google Cloud Ops Agent on the VM instances to collect both logs and extended system metrics.
The Ops Agent replaces legacy Stackdriver agents and provides support for memory metrics and custom log file tracking.
2
Configure IAM permissions according to least privilege.
Attach predefined roles/logging.logWriter and roles/monitoring.metricWriter to the VM service account.
These predefined roles allow ingestion of telemetry data without granting excessive project administrative rights.

Key Concept

Google Cloud Ops Agent configuration and least-privilege IAM telemetry roles
Question 1389Question

An organization deployed a backend microservice named `analytics-collector` on Cloud Run in the `us-central1` region. You need to ensure that only a dedicated service account, `[email protected]`, is authorized to invoke this Cloud Run service while preventing all unauthenticated public access. Which `gcloud` command should you execute to grant the necessary access using the principle of least privilege?

Show answer & explanation

Answer: gcloud run services add-iam-policy-binding analytics-collector --region=us-central1 --member="serviceAccount:[email protected]" --role="roles/run.invoker"

Answer

Execute `gcloud run services add-iam-policy-binding analytics-collector --region=us-central1 --member="serviceAccount:[email protected]" --role="roles/run.invoker"` to grant explicit invocation permissions to the service account adhering to least privilege.
The correct command uses `gcloud run services add-iam-policy-binding` to bind the specific service account member to the predefined `roles/run.invoker` role on the Cloud Run service. This restricts invocation access strictly to that service account while enforcing the principle of least privilege.

Step-by-Step Solution

1
Identify the resource type and operational requirement.
The resource is a Cloud Run service (`analytics-collector`) requiring invocation authorization for a specific service account.
Cloud Run services require the Cloud Run Invoker role (`roles/run.invoker`) for authorized HTTP requests when unauthenticated access is disabled.
2
Select the appropriate gcloud command group and IAM role following least privilege.
Use `gcloud run services add-iam-policy-binding` with `--role="roles/run.invoker"`.
Predefined roles like `roles/run.invoker` grant exact calling permissions without exposing management permissions provided by primitive roles like Editor.

Key Concept

Cloud Run IAM Access Control & Least Privilege
Question 1390Question

An operations engineer needs to update an existing Cloud NAT gateway named `nat-gateway` managed by Cloud Router `router-central` in the `us-central1` region. The gateway must be updated to use a newly provisioned static regional external IP address named `nat-static-ip` instead of automatically allocated IPs, and detailed logging for all translation connections must be enabled. Which TWO commands should the engineer run to accomplish this setup?

Select all that apply

Show answer & explanation

Answer: gcloud compute addresses create nat-static-ip --region=us-central1; gcloud compute routers nats update nat-gateway --router=router-central --region=us-central1 --nat-external-ip-pool=nat-static-ip --enable-logging --log-filter=ALL

Answer

The engineer must create a regional static external IP address using `gcloud compute addresses create nat-static-ip --region=us-central1` and update the NAT configuration using `gcloud compute routers nats update nat-gateway --router=router-central --region=us-central1 --nat-external-ip-pool=nat-static-ip --enable-logging --log-filter=ALL`.
To assign a specific static IP to a Cloud NAT gateway, a regional external IP address must first be created in the matching region (`us-central1`). Next, the Cloud NAT gateway configuration on the Cloud Router must be updated using `--nat-external-ip-pool` to bind the IP address, alongside `--enable-logging` and `--log-filter=ALL` to capture translation logs.

Step-by-Step Solution

1
Reserve a regional static external IP address in the region where the Cloud NAT gateway resides.
The IP address resource `nat-static-ip` is created in region `us-central1`.
Cloud NAT operates at the regional scope and requires regional external IP addresses.
2
Update the Cloud NAT gateway configuration to attach the static IP and enable translation logging.
The NAT gateway is configured with the specified static IP pool and logs all NAT translations.
The `--nat-external-ip-pool` flag assigns the specific reserved static IP, while `--enable-logging` combined with `--log-filter=ALL` enables connection translation logs.

Key Concept

Cloud NAT configuration and static IP allocation using gcloud CLI
Question 1391Question

A cloud engineer needs to create a standardized custom boot image from an existing baseline Compute Engine VM instance named `web-base-vm` and deploy a new instance named `web-prod-1` in zone `us-central1-b` using this custom image. Arrange the administrative steps required to complete this VM cloning and deployment workflow in the correct chronological order from first to last.

Drag items to arrange them in the correct order

Show answer & explanation

Answer

The correct sequence begins by stopping the source VM instance, creating a persistent disk snapshot, generating a custom image from that snapshot, deploying the new VM instance using the custom image flag, and finally restarting the original source VM instance.
To create a clean, consistent boot image and deploy a new Compute Engine VM from it, the engineer must first stop the source VM to prevent uncommitted disk writes. Next, a snapshot of the boot disk is created. That snapshot is then used as the source to build a custom Compute Engine image. With the image ready, the new VM instance (`web-prod-1`) is created using the `--image` parameter. Finally, the source VM can be restarted.

Step-by-Step Solution

1
Stop the baseline VM instance.
The VM enters the TERMINATED state, locking persistent disk writes.
Capturing a snapshot from a stopped instance avoids disk corruption and guarantees a consistent image state.
2
Create a disk snapshot from the boot disk.
A persistent disk snapshot is generated in Google Cloud Storage.
Snapshots store point-in-time byte data required to build image resources.
3
Create a custom image from the snapshot.
A custom Compute Engine disk image resource is registered in the project.
Custom images allow cross-zone and cross-region provisioning of standardized VM boot disks.
4
Execute `gcloud compute instances create web-prod-1 --zone=us-central1-b --image=web-custom-image-v1`.
The new VM instance boots up with the pre-configured OS and environment.
Specifying the custom image provisions a new instance initialized with the exact baseline software stack.
5
Start the baseline VM instance `web-base-vm`.
The source instance resumes RUNNING state.
The image capturing dependency chain is complete, so baseline operations can resume.

Key Concept

Compute Engine Custom Image Deployment Workflow
Question 1392Question

An application deployed on Google Cloud outputs structured JSON logs to Cloud Logging. An Operations SRE must configure an automated real-time notification whenever the system generates more than 50 HTTP 500 error responses within a 5-minute rolling window. Which approach follows Google Cloud recommended practices to achieve this objective?

Show answer & explanation

Answer: Create a custom log-based counter metric in Cloud Logging using a filter for HTTP status code 500, and then create a Cloud Monitoring alerting policy based on that metric.

Answer

The correct approach is to create a custom log-based counter metric in Cloud Logging filtered for HTTP status code 500, and configure a Cloud Monitoring alerting policy conditioned on this metric.
Log-based metrics bridge Cloud Logging and Cloud Monitoring by turning log data matching a specific query filter (such as HTTP status code 500) into numerical metric time series. SREs can then attach standard Cloud Monitoring alerting policies to these metrics to trigger notifications when thresholds are breached.

Step-by-Step Solution

1
Define a filter query in Cloud Logging for HTTP 500 errors
Identifies structured log records where `httpRequest.status = 500` or equivalent payload fields match the error pattern.
Filtering isolate specific events needed to track error frequency.
2
Create a log-based counter metric
Translates log entries matching the filter into a numerical time series metric in Cloud Monitoring.
Cloud Monitoring requires time series metric data to evaluate threshold conditions over time windows.
3
Configure a Cloud Monitoring Alerting Policy
Triggers alert notifications when the log-based metric exceeds 50 counts over the 5-minute aggregation window.
Completes the operational requirement for automated real-time incident alerting.

Key Concept

Custom Log-based Metrics and Alerting Policies
Estimated Time:2m 0s
Question 1393Question

An organization hosts a data-processing workload on a Compute Engine virtual machine instance located in GCP Project `proj-analytics`. The application requires read-only access to a Cloud Storage bucket situated in a separate project named `proj-data-warehouse`. According to Google Cloud security best practices for creating and managing service accounts, which of the following actions should the administrator perform to enable cross-project authorization securely? (Select TWO correct answers.)

Select all that apply

Show answer & explanation

Answer: Create a user-managed service account in `proj-analytics` and attach it to the Compute Engine VM instance upon creation.; Grant the user-managed service account principal from `proj-analytics` the Storage Object Viewer (`roles/storage.objectViewer`) role on the specific Cloud Storage bucket in `proj-data-warehouse`.

Answer

To establish secure cross-project authorization, the administrator must create a dedicated user-managed service account in the source project hosting the Compute Engine instance and grant that service account's email address the predefined Storage Object Viewer role on the bucket in the destination project.
Secure cross-project access in Google Cloud relies on creating a custom user-managed service account within the source project where the compute resource resides, attaching that service account to the VM instance, and granting its email address a minimal predefined role (such as Storage Object Viewer) directly on the target resource in the remote project.

Step-by-Step Solution

1
Provision a user-managed service account in the source project (`proj-analytics`).
A dedicated service account identity is established for the workload rather than relying on default service accounts.
User-managed service accounts allow fine-grained access control tailored to specific application requirements.
2
Attach the custom service account to the Compute Engine VM instance.
Application API calls from the VM automatically retrieve application default credentials (ADC) for identity assertion.
Attaching the service account directly eliminates the need to manage static JSON security keys on local disk.
3
Grant the service account email the Storage Object Viewer role on the destination bucket in `proj-data-warehouse`.
The identity in the source project is authorized to read objects in the destination bucket.
IAM roles can be assigned to cross-project service account principals using their full email identity.

Key Concept

Cross-Project Service Account Access and Principle of Least Privilege
Question 1394Question

A cloud engineer is deploying a Compute Engine virtual machine instance named `gpu-worker-1` with an attached NVIDIA GPU in zone `us-central1-a` using the `gcloud` CLI. The initial deployment command fails because the default host maintenance behavior is incompatible with GPU-attached instances. Which `gcloud compute instances create` flag configuration must the engineer specify to deploy the instance successfully?

Show answer & explanation

Answer: Specify `--on-host-maintenance=TERMINATE` to stop the instance during host maintenance events.

Answer

Specify `--on-host-maintenance=TERMINATE` to stop the instance during host maintenance events.
Compute Engine instances equipped with GPUs cannot be live-migrated to another host during physical host maintenance. Therefore, Google Cloud requires setting `--on-host-maintenance=TERMINATE` during instance creation so the VM is stopped rather than migrated.

Step-by-Step Solution

1
Identify host maintenance limitations for hardware accelerators in Compute Engine.
NVIDIA GPUs attached to Compute Engine VM instances do not support live migration during host maintenance events.
Hardware state in GPUs cannot be moved transparently across physical hypervisor hosts.
2
Determine the required host maintenance flag for `gcloud compute instances create`.
The `--on-host-maintenance` flag must be set explicitly to `TERMINATE`.
Compute Engine defaults to `MIGRATE` for standard VM instances, which causes creation failure when GPUs are attached unless overridden.

Key Concept

Compute Engine Host Maintenance Policies for GPU Workloads
Question 1395Question

A cloud administrator is managing an internal web service hosted on a Compute Engine Managed Instance Group (MIG). During temporary traffic spikes, the application suffers performance degradation because the MIG's autoscaler scales out too late and immediately scales in as soon as CPU load drops briefly, resulting in rapid instance thrashing. Upon reviewing the configuration, the administrator observes that target CPU utilization is set to 95%95\% with a scale-in stabilization period of 00 seconds. Which configuration change to the autoscaling policy should the administrator make to stabilize the instance group in accordance with Google-recommended best practices?

Show answer & explanation

Answer: Lower the target CPU utilization threshold to a moderate level such as 60%60\%-70%70\% and configure a non-zero scale-in stabilization period.

Answer

Lower the target CPU utilization threshold to a moderate level such as 60%-70% and configure a non-zero scale-in stabilization period.
The correct action is to lower the target CPU utilization threshold and establish a non-zero scale-in stabilization period. Google Cloud recommends keeping CPU utilization targets moderate (e.g., 60%-80%) so that existing instances can handle load increases while new instances boot up. Adding a scale-in stabilization period ensures the autoscaler evaluates sustained metrics rather than reacting immediately to short-term dips in load, thereby preventing instance thrashing.

Step-by-Step Solution

1
Analyze the autoscaling symptoms
Identified instance thrashing and delayed scale-out response due to aggressive metric targets (95% CPU threshold and 0-second stabilization).
An overly high target CPU utilization threshold leaves insufficient capacity buffer for traffic bursts, while a 0-second scale-in stabilization period immediately terminates instances when CPU drops briefly.
2
Apply Google Cloud MIG autoscaling best practices
Adjust target CPU utilization to 60%-70% and set a stabilization period (e.g., 300 seconds).
Lowering the target ensures the MIG triggers scale-out early enough to absorb incoming demand. The scale-in stabilization period forces the autoscaler to evaluate historic load over a window before scaling down, eliminating thrashing.

Key Concept

Managed Instance Group (MIG) Autoscaling Metrics & Stabilization
Question 1396Question

A cloud engineer needs to manage an operational Cloud Run service named `order-service` deployed in the `us-central1` region. To handle peak traffic demands while preventing runaway infrastructure costs, the engineer must update the existing service configuration so that no more than 50 container instances scale out, and each instance handles up to 80 concurrent requests. Which TWO `gcloud` CLI commands or flags can the engineer execute to correctly set these parameters? (Select TWO.)

Select all that apply

Show answer & explanation

Answer: Run `gcloud run services update order-service --max-instances=50 --concurrency=80 --region=us-central1`.; Run `gcloud run deploy order-service --image=gcr.io/my-project/order-service:v2 --max-instances=50 --concurrency=80 --region=us-central1`.

Answer

The configurations can be applied either by updating the service inline with `gcloud run services update --max-instances=50 --concurrency=80 --region=us-central1` or by deploying a container image revision with `gcloud run deploy --max-instances=50 --concurrency=80 --region=us-central1`.
Both updating an active service with `gcloud run services update` and deploying a revision using `gcloud run deploy` support setting instance scaling limits (`--max-instances`) and container concurrency (`--concurrency`). Both commands correctly apply the maximum instance ceiling to 50 and request concurrency per instance to 80.

Step-by-Step Solution

1
Identify the target resource and configuration requirements
Resource is Cloud Run service `order-service` in region `us-central1`. Parameters to adjust are maximum instances (50) and concurrency per instance (80).
Cloud Run service settings require valid `gcloud run` command syntax matching Cloud Run resource flags.
2
Evaluate CLI subcommands for resource modifications
Both `gcloud run services update` and `gcloud run deploy` modify service configuration templates and revision settings.
`update` changes settings without redeploying code, whereas `deploy` updates settings alongside a new container image.
3
Validate flags and eliminate non-applicable commands
`update-traffic` is invalid because it only adjusts traffic percentages between revisions, and `gcloud functions deploy` targets Cloud Functions rather than Cloud Run.
Distinguishing subcommands ensures accurate operation management without command parameter errors.

Key Concept

Cloud Run Service Configuration and Scaling Management via gcloud CLI
Question 1397Question

An organization uses an automated security auditing script running on a centralized admin virtual machine. The script needs temporary credentials to inspect configuration settings across multiple Google Cloud projects by impersonating a target service account named `[email protected]`. The security policy strictly prohibits creating or downloading long-lived service account key files. Which IAM configuration should the cloud engineer apply to enable this setup while adhering to the principle of least privilege?

Show answer & explanation

Answer: Grant the admin VM's identity the Service Account Token Creator role (roles/iam.serviceAccountTokenCreator) on the auditor service account.

Answer

Grant the admin VM's identity the Service Account Token Creator role (`roles/iam.serviceAccountTokenCreator`) on the auditor service account.
To impersonate a service account and generate short-lived credentials (like access tokens or ID tokens), a principal must have the Service Account Token Creator role (`roles/iam.serviceAccountTokenCreator`) granted on the target service account. This allows keyless authentication while adhering to least privilege.

Step-by-Step Solution

1
Identify the authentication requirement
The automated auditing script requires short-lived credential generation for service account impersonation without downloading long-lived JSON keys.
Security policy forbids static service account keys.
2
Evaluate required IAM permissions for impersonation
The Service Account Token Creator role (`roles/iam.serviceAccountTokenCreator`) grants `iam.serviceAccounts.getAccessToken` and related permissions needed to generate short-lived tokens.
This enables secure, direct impersonation of the target service account.
3
Apply least privilege scoping
Bind `roles/iam.serviceAccountTokenCreator` directly on the target service account resource rather than assigning broad project-level roles.
Ensures the admin principal can only impersonate the specific designated auditing identity.

Key Concept

Service Account Impersonation and Short-Lived Credentials
Question 1398Question

A cloud administrator needs to replace the default Compute Engine service account on an existing virtual machine with a newly created custom user-managed service account. The application running on the instance requires read-only access to objects inside a specific Google Cloud Storage bucket. Following Google Cloud security best practices, in what correct sequential order should the administrator perform the steps to configure and attach the identity?

Drag items to arrange them in the correct order

Show answer & explanation

Answer

The correct operational sequence is: 1) Create the custom user-managed service account, 2) Grant the roles/storage.objectViewer role to the service account on the target bucket, 3) Grant the roles/iam.serviceAccountUser role to the administrator on the service account, and 4) Stop the instance and update its service account assignment using gcloud compute instances set-service-account.
The correct logical sequence follows dependency order in GCP identity management: first create the identity, second define what resources the identity can access (bucket-level Object Viewer), third grant the deploying user permission to use the identity (roles/iam.serviceAccountUser), and finally update the workload configuration to bind the identity to the Compute Engine virtual machine.

Step-by-Step Solution

1
Provision the new service account resource using gcloud CLI.
Generates a unique service account email address (e.g., [email protected]).
An identity must exist before permissions can be bound or assigned.
2
Bind the granular IAM role roles/storage.objectViewer to the service account email on the specific bucket.
Configures resource-level permissions following the principle of least privilege.
Configuring resource permissions before attaching identity prevents permission gap windows upon workload startup.
3
Assign roles/iam.serviceAccountUser on the service account to the identity performing the VM update.
Authorizes the administrator to attach the service account to compute workloads.
Without the Service Account User role, Compute Engine prevents users from attaching service accounts to instances.
4
Stop the Compute Engine instance and reassign its identity with gcloud compute instances set-service-account.
The VM replaces its default service account identity with the custom user-managed service account.
Changing a running VM's service account requires stopping the instance or using the set-service-account command with appropriate flags.

Key Concept

Lifecycle and delegation pattern for user-managed service account creation, IAM role assignment, and Compute Engine attachment.
Estimated Time:2m 0s
Question 1399Question

A security team needs to grant a newly hired compliance auditor access to review IAM policy bindings and inspect Cloud Logging logs within project `analytics-prod-404`. The auditor must NOT be granted access to read actual data stored inside Cloud Storage buckets or BigQuery tables, nor be permitted to modify any security policies. Which of the following IAM role assignments adhere to the principle of least privilege while fulfilling these requirements? (Select TWO.)

Select all that apply

Show answer & explanation

Answer: Assign the Security Reviewer role (`roles/iam.securityReviewer`) on project `analytics-prod-404`.; Assign the Logs Viewer role (`roles/logging.viewer`) on project `analytics-prod-404`.

Answer

The correct role assignments are granting the Security Reviewer role (`roles/iam.securityReviewer`) on project `analytics-prod-404` and granting the Logs Viewer role (`roles/logging.viewer`) on project `analytics-prod-404`.
Combining the predefined roles `roles/iam.securityReviewer` and `roles/logging.viewer` at the project resource level directly satisfies the least-privilege requirement. It provides read access to security configurations and Cloud Logging logs without exposing stored data or extending access beyond project `analytics-prod-404`.

Step-by-Step Solution

1
Identify the required permissions needed for the job role
The compliance auditor needs read-only access to IAM policy configurations and Cloud Logging logs specifically within project `analytics-prod-404`.
Security auditing requires viewing access control policies and operational logs.
2
Select predefined roles that fulfill least privilege without granting data access
`roles/iam.securityReviewer` provides read access to security configuration settings, and `roles/logging.viewer` grants read access to log entries.
Predefined roles limit permission scope compared to primitive roles like Project Viewer which grant broad access to stored data.
3
Determine the appropriate resource hierarchy scope for the binding
Bind both roles directly to project `analytics-prod-404`.
Granting roles at the Organization level would unnecessarily grant access across all projects via resource hierarchy inheritance.

Key Concept

Principle of Least Privilege with Predefined Roles and Resource Hierarchy Scoping
Question 1400Question

A cloud engineer is deploying a custom VPC network named `prod-vpc` with multiple subnets across different regions. To secure an internal microservice running on Compute Engine instances within `subnet-backend`, the engineer needs to allow ingress TCP traffic on port 8080 specifically to these backend instances without exposing other instances in `prod-vpc`. Which configuration approach correctly achieves this selective access?

Show answer & explanation

Answer: Create an ingress firewall rule specifying target network tags assigned to the backend instances, with port 8080 allowed for the required source IP range.

Answer

Create an ingress firewall rule specifying target network tags assigned to the backend instances, with port 8080 allowed for the required source IP range.
Specifying target network tags on an ingress firewall rule allows the rule to apply strictly to Compute Engine instances labeled with those network tags, isolating port 8080 access to the intended microservice workloads without affecting other VMs in the VPC.

Step-by-Step Solution

1
Identify the target instances requiring specific port access
Network tags (or service accounts) are assigned to the target backend Compute Engine instances.
Firewall rules in Google Cloud VPC use target network tags or target service accounts to restrict applicability to specific instances.
2
Configure ingress firewall rule parameters
Define direction as Ingress, action as Allow, protocol/port as tcp:8080, and target tags matching the backend instances.
This ensures only instances bearing the specified tag allow incoming traffic on port 8080.

Key Concept

Target network tags in GCP firewall rules allow selective rule application to specific VM instances inside a VPC network.
Estimated Time:1m 30s
PreviousPage 70 / 80Next
All practice questions — Google Cloud Associate Cloud Engineer | Examkin