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 building an event-driven order-processing microservice on Cloud Run that receives messages from a Pub/Sub topic. To meet security requirements, you deployed the Cloud Run service with --no-allow-unauthenticated and created a user-managed service account (pubsub-invoker@project-id.iam.gserviceaccount.com) in the same project, where the Pub/Sub service agent already holds the roles/iam.serviceAccountTokenCreator role.
You now need to configure authenticated push delivery with the following requirements:
Which configuration should you implement?
roles/run.invoker role on the Cloud Run service to the Pub/Sub service agent (service-PROJECT_NUMBER@gcp-sa-pubsub.iam.gserviceaccount.com), and create the Pub/Sub push subscription with --push-endpoint set to the Cloud Run service URL without specifying --push-auth-service-account.This configuration assigns the roles/run.invoker role directly to the Google-managed Pub/Sub service agent (service-PROJECT_NUMBER@gcp-sa-pubsub.iam.gserviceaccount.com) and creates an unauthenticated push subscription by omitting the --push-auth-service-account flag.
--push-auth-service-account, Pub/Sub treats the subscription as an unauthenticated webhook and sends HTTP POST requests without an Authorization: Bearer OIDC JWT header.--no-allow-unauthenticated, any incoming request lacking a valid OIDC token is immediately rejected with an authentication error before IAM role bindings are even evaluated.roles/iam.serviceAccountTokenCreator), not to act as the OIDC identity presented to target services.--push-auth-service-account never generate JWTs, even if the Pub/Sub service agent holds roles/iam.serviceAccountTokenCreator.email claim matches a principal granted roles/run.invoker.roles/run.invoker to the Pub/Sub service agent has no effect when no token is present in the request header.This is never a valid configuration for authenticated push delivery to Cloud Run. To authenticate push requests, you must always specify a user-managed service account via --push-auth-service-account (or oidc_token in Terraform) and grant roles/run.invoker to that user-managed service account.
roles/run.invoker role on the Cloud Run service to pubsub-invoker@project-id.iam.gserviceaccount.com, assign it as the Cloud Run service's runtime service account, and append a secret ?token= query parameter to --push-endpoint instead of configuring --push-auth-service-account.This configuration assigns pubsub-invoker@project-id.iam.gserviceaccount.com as the runtime identity of the Cloud Run container, grants it roles/run.invoker, and relies on a shared secret query string (?token=...) in the push endpoint URL instead of OIDC authentication.
--push-auth-service-account means Pub/Sub does not sign or attach an OIDC JWT in the Authorization header.--no-allow-unauthenticated, Cloud Run's ingress layer rejects requests that lack a valid Google-signed bearer token with HTTP 401/403 before the request ever reaches the application code to inspect the ?token= query parameter.--push-auth-service-account represents the caller invoking Cloud Run, whereas the Cloud Run runtime service account represents the workload itself.?token= query string is an application-level shared-secret pattern used for public webhooks, not a substitute for platform-enforced IAM and OIDC authentication.You were pushing to a publicly accessible webhook (such as an unauthenticated App Engine endpoint) that explicitly validates a static query parameter inside application code rather than relying on Cloud Run's built-in OIDC and IAM authentication.
roles/run.invoker role on the Cloud Run service to pubsub-invoker@project-id.iam.gserviceaccount.com, and create the Pub/Sub push subscription with --push-endpoint set to the Cloud Run service URL and --push-auth-service-account set to pubsub-invoker@project-id.iam.gserviceaccount.com.Authenticated Pub/Sub push delivery uses OpenID Connect (OIDC) JSON Web Tokens (JWTs) signed by Google to prove the identity of incoming HTTP POST requests sent from Pub/Sub to a private endpoint. When targeting a private Cloud Run service, Cloud Run automatically validates the OIDC token signature and enforces Identity and Access Management (IAM) authorization before routing the request to your container.
--push-auth-service-account=pubsub-invoker@project-id.iam.gserviceaccount.com when creating the push subscription instructs Pub/Sub to generate a signed OIDC JWT containing the service account in the email claim and attach it to the Authorization: Bearer header of every push request.roles/run.invoker on the Cloud Run service to pubsub-invoker@project-id.iam.gserviceaccount.com satisfies Cloud Run's built-in IAM authorization check when --no-allow-unauthenticated is enabled.service-PROJECT_NUMBER@gcp-sa-pubsub.iam.gserviceaccount.com) already holds roles/iam.serviceAccountTokenCreator, it has the iam.serviceAccounts.getOpenIdToken permission needed to mint tokens on behalf of the invoker service account.aud claim to match the push endpoint URL, aligning seamlessly with Cloud Run's default audience validation.--no-allow-unauthenticated), blocking unauthenticated internet traffic with HTTP 401/403 responses.This configuration follows the standard Cloud Run and Pub/Sub security model by separating token minting (handled by the Pub/Sub service agent) from service authorization (handled by the user-managed invoker service account with roles/run.invoker).
roles/pubsub.subscriber role on the subscription to pubsub-invoker@project-id.iam.gserviceaccount.com, and create the Pub/Sub push subscription with --push-endpoint set to the Cloud Run service URL and --push-auth-service-account set to pubsub-invoker@project-id.iam.gserviceaccount.com.This approach enables OIDC token generation on the push subscription using --push-auth-service-account, but grants the roles/pubsub.subscriber role on the Pub/Sub subscription instead of granting roles/run.invoker on the Cloud Run service.
pubsub-invoker@project-id.iam.gserviceaccount.com, Cloud Run checks whether that identity has permission to invoke the Cloud Run service (run.routes.invoke, provided by roles/run.invoker). Without roles/run.invoker, Cloud Run rejects every push delivery with an HTTP 403 Forbidden error.roles/pubsub.subscriber role grants permissions to consume messages from a Pub/Sub pull subscription (such as pubsub.subscriptions.consume) and attach subscriptions, which is unrelated to invoking an HTTPS Cloud Run endpoint.POST request to Cloud Run.HTTP 403 responses cause Pub/Sub to treat deliveries as failed, triggering exponential backoff retries until messages expire or move to a dead-letter topic.You were configuring a pull subscriber application running on Compute Engine or GKE that uses the Pub/Sub client library to actively pull and acknowledge messages from a subscription, rather than a push subscription invoking a private Cloud Run service.
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