Courseiva
Deploying and Implementing a Cloud SolutionhardMultiple ChoiceObjective-mapped

Google ACE Deploying and Implementing a Cloud Solution Practice Question

A DevOps engineer needs to deploy a containerized microservice to Cloud Run that processes messages from Pub/Sub. The service must authenticate to Google Cloud APIs using a service account. Which Cloud Run deployment command should they use to ensure the service uses a specific service account?

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

gcloud run deploy my-service --image gcr.io/my-project/my-image --service-account my-sa@my-project.iam.gserviceaccount.com --platform managed

Cloud Run supports the --service-account flag to attach a specific service account. The --image flag specifies the container image. The other options either use incorrect flags (--account is for gcloud CLI user, not service account) or miss required flags.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • gcloud run deploy my-service --image gcr.io/my-project/my-image --service-account my-sa@my-project.iam.gserviceaccount.com --platform managed

    Why this is correct

    Using the `--service-account` flag with `gcloud run deploy` explicitly assigns the specified IAM service account as the runtime identity for the Cloud Run service. This is the correct syntax because the flag is designed to set the service account that the container will run as, and `--platform managed` ensures the command targets Cloud Run (fully managed) rather than other platforms. The deployed service will inherit the IAM permissions of `my-sa@my-project.iam.gserviceaccount.com`, which is exactly what the DevOps engineer needs.

  • gcloud run deploy my-service --image gcr.io/my-project/my-image --account my-sa@my-project.iam.gserviceaccount.com

    Why it's wrong here

    The `--account` flag in gcloud is used to override the active user account for the gcloud CLI session, not to set the identity of the deployed service. When you pass a service account email to `--account`, gcloud attempts to authenticate the CLI itself with that identity, which will fail or be ignored in most contexts because it expects a user account or a key that matches the CLI's authentication configuration. To bind a service account to a Cloud Run service, the correct flag is `--service-account`, not `--account`.

  • gcloud run deploy my-service --image gcr.io/my-project/my-image --impersonate-service-account my-sa@my-project.iam.gserviceaccount.com

    Why it's wrong here

    The `--impersonate-service-account` flag enables gcloud commands to act on behalf of that service account for the duration of the CLI operation, but it does not configure the Cloud Run service's own runtime identity. Even if impersonation is successful, the deployed service will still run with the default compute engine service account unless `--service-account` is specified. This flag is useful for temporarily granting the caller elevated permissions to run gcloud commands, but it is the wrong tool for defining the microservice's long-term IAM identity.

  • gcloud run deploy my-service --image gcr.io/my-project/my-image

    Why it's wrong here

    This command works but omits the `--service-account` flag, so Cloud Run automatically assigns the default compute engine service account (e.g., `PROJECT_NUMBER-compute@developer.gserviceaccount.com`) as the runtime identity. That default service account typically has broad or overly permissive access to project resources, which violates the principle of least privilege and is often unacceptable for production microservices. The DevOps engineer's intent is to use a dedicated service account (`my-sa@...`), which requires the explicit `--service-account` flag to override the default.

About these practice questions

One of 769 original ACE practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This ACE practice question is part of Courseiva's free Google Cloud certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the ACE exam.