Google Professional Cloud Developer Question 428
Single answerGoogle Cloud PlatformYou are developing a serverless application using Cloud Functions and need to integrate it with Cloud Pub/Sub for asynchronous messaging. After setting up your Cloud Pub/Sub topic and creating your Cloud Function, you notice that the function fails to trigger from the topic. Which step is most likely missing?
- A
Enabling the Cloud Functions and Cloud Pub/Sub APIs in your Google Cloud project
- B
Creating a Cloud Scheduler job to trigger the Cloud Function
- C
Granting the Cloud Pub/Sub Publisher role to the Cloud Function service account
- D
Configuring the Cloud Function trigger to listen for changes in a Cloud Storage bucket
Show answer and explanation
Correct answer: A
Explanation
When using Google Cloud services like Cloud Functions and Cloud Pub/Sub, you must ensure that the required APIs are enabled in your project. Without enabling the APIs, your resources won't interoperate correctly, and triggers or integrations will fail to work as expected. This is a common step that new developers might miss.
- A. Correct.
Correct. Cloud Functions and Cloud Pub/Sub APIs must be enabled in your Google Cloud project for these services to work together. Without enabling these APIs, the integration will not function.
- B. Incorrect.
Incorrect. Cloud Scheduler is not required to trigger a Cloud Function from a Cloud Pub/Sub topic. This is unrelated to the issue described.
- C. Incorrect.
Incorrect. While permissions are important, the Cloud Function service account does not need the Cloud Pub/Sub Publisher role for the integration to work. It needs Pub/Sub Subscriber permissions instead, which is not the issue described in this scenario.
- D. Incorrect.
Incorrect. Configuring a Cloud Function trigger to listen to Cloud Storage bucket changes is unrelated to the described scenario. This does not resolve the problem with Cloud Pub/Sub integration.