Medium1 markMultiple Choice
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?
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
Q01You are starting a new initiative and need to create a new Google Cloud project using the command...EasyQ02A developer on your team needs to manage App Engine applications, including deploying new version...MediumQ03You have created a new Google Cloud project. You need to allow a specific group of developers to ...MediumQ04Which statement best describes the relationship between Google Cloud projects and billing accounts?EasyQ05Your company wants to be notified immediately in their Slack channel whenever their monthly Googl...Medium
Expert