Soru

Zorluk: ZorDeploying and Managing Compute Engine Virtual Machines

A Cloud Engineer is writing a deployment script to provision a backend database proxy virtual machine named `proxy-prod-01` on Compute Engine in zone `us-central1-a`.

The instance must meet the following strict requirements:
1. Prevent direct exposure to the public internet by omitting an external IP address.
2. Run using a user-managed service account named `[email protected]`.
3. Adhere to Google Cloud security best practices by delegating access control strictly to IAM roles assigned to the service account, rather than restricting access via legacy API access scopes.
4. Ensure the workload runs continuously without risk of sudden 30-second termination notices caused by host resource reclaim events.

Which `gcloud compute instances create` command correctly configures the instance according to these requirements?

  1. gcloud compute instances create proxy-prod-01 \
    --zone=us-central1-a \
    --no-address \
    --service-account=app-proxy-sa@my-gcp-project.iam.gserviceaccount.com \
    --scopes=https://www.googleapis.com/auth/cloud-platform
    Cevap
  2. B
    gcloud compute instances create proxy-prod-01 \
    --zone=us-central1-a \
    --no-address \
    --iam-account=app-proxy-sa@my-gcp-project.iam.gserviceaccount.com \
    --scopes=https://www.googleapis.com/auth/cloud-platform
  3. C
    gcloud compute instances create proxy-prod-01 \
    --zone=us-central1-a \
    --no-address \
    --service-account=app-proxy-sa@my-gcp-project.iam.gserviceaccount.com \
    --scopes=https://www.googleapis.com/auth/cloud-platform \
    --provisioning-model=SPOT
  4. D
    gcloud compute instances create proxy-prod-01 \
    --zone=us-central1-a \
    --no-address \
    --service-account=app-proxy-sa@my-gcp-project.iam.gserviceaccount.com \
    --scopes=editor

Cevap

The command using `gcloud compute instances create proxy-prod-01` with `--no-address`, `--service-account=app-proxy-sa@my-gcp-project.iam.gserviceaccount.com`, and `--scopes=https://www.googleapis.com/auth/cloud-platform` without `--provisioning-model=SPOT` correctly meets all requirements.
The correct command uses `--no-address` to omit external IP assignment, specifies `--service-account` with the target user-managed service account, and grants `--scopes=https://www.googleapis.com/auth/cloud-platform`. This allows the exact IAM roles bound to the service account to govern access without scope limitations, while leaving out Spot VM flags guarantees continuous availability.

Adım Adım Çözüm

1
Analyze network exposure requirement.
To ensure the instance does not get assigned an external public IP address, the `--no-address` flag must be passed to `gcloud compute instances create`.
By default, Compute Engine instances receive an ephemeral external IP address unless `--no-address` is specified.
2
Determine service account flag syntax and IAM access scope best practices.
The correct flag to attach a service account is `--service-account=<EMAIL>`. To allow IAM roles attached to the service account to dictate permission boundaries, use `--scopes=https://www.googleapis.com/auth/cloud-platform`.
Google Cloud best practices dictate enabling the `cloud-platform` scope on custom service accounts so that IAM policies govern specific GCP resource access rather than legacy restricted scope aliases.
3
Evaluate workload availability requirements.
The database proxy is a stateful continuous workload, so standard provisioning must be used instead of `--provisioning-model=SPOT`.
Spot/Preemptible VMs can be reclaimed by Google at any time with a 30-second warning, making them unfit for non-fault-tolerant infrastructure components.

Anahtar Kavram

Compute Engine Instance Provisioning Flags and Security Scopes
Tahmini Süre:2m 0s
Bu soruyu puanla