Medium1 markMultiple Choice
Domain 3.3: Deploying Cloud Run and Cloud FunctionsDomain 3Cloud FunctionsPub/SubEventarc

GCP ACE · Question 26 · Domain 3.3: Deploying Cloud Run and Cloud Functions

You are writing a Cloud Function that needs to process messages as soon as they are published to a Cloud Pub/Sub topic named order-events.

How should you configure the Cloud Function to achieve this?

Answer options:

A.

Deploy the function with an Eventarc trigger (or --trigger-topic) pointing to the Pub/Sub topic.

B.

Deploy the function with an HTTP trigger and configure Pub/Sub to send a webhook to the URL.

C.

Use Cloud Scheduler to trigger the function every minute to pull messages from the topic.

D.

Write a loop inside the Cloud Function that continuously polls the Pub/Sub topic.

How to approach this question

Recognize the native event-driven capabilities of Cloud Functions. They can be directly triggered by GCP events.

Full Answer

A.Deploy the function with an Eventarc trigger (or --trigger-topic) pointing to the Pub/Sub topic.✓ Correct
Deploy the function with an Eventarc trigger (or --trigger-topic) pointing to the Pub/Sub topic.
Cloud Functions can be triggered directly by Google Cloud events. To process Pub/Sub messages, you deploy the function as a background/event-driven function and specify the Pub/Sub topic as the trigger (using Eventarc in 2nd gen, or `--trigger-topic` in 1st gen). The function will automatically execute every time a new message is published.

Common mistakes

Choosing polling mechanisms (Cloud Scheduler or loops) which defeat the purpose of event-driven serverless architecture.

Practice the full GCP Associate Cloud Engineer Practice Exam 5

50 questions · hints · full answers · grading

More questions from this exam