You want to deploy an application on Cloud Run that processes messages from a Cloud Pub/Sub topic.
You want to follow Google-recommended practices.
What should you do?
Click on the arrows to vote for the correct answer
A. B. C. D.D.
The recommended approach to deploying an application on Cloud Run that processes messages from a Cloud Pub/Sub topic is to use a combination of Cloud Run and Cloud Pub/Sub. Specifically, the recommended approach involves creating a Cloud Pub/Sub subscription for the topic and configuring your application on Cloud Run to pull messages from that subscription. Here are the steps involved:
Option B is the correct answer: B. 1. Grant the Pub/Sub Subscriber role to the service account used by Cloud Run. 2. Create a Cloud Pub/Sub subscription for that topic. 3. Make your application pull messages from that subscription.
Step 1: Grant the Pub/Sub Subscriber role to the service account used by Cloud Run
To give your Cloud Run service permission to read messages from a Cloud Pub/Sub topic, you need to grant the appropriate role to the service account that Cloud Run uses. This role is the Pub/Sub Subscriber role. To do this, follow these steps:
Step 2: Create a Cloud Pub/Sub subscription for that topic
After you have granted the Pub/Sub Subscriber role to the service account, you need to create a Cloud Pub/Sub subscription for the topic that your application will be processing messages from. To do this, follow these steps:
Step 3: Make your application pull messages from that subscription
Once you have created the subscription, you need to configure your Cloud Run service to pull messages from it. To do this, you will need to modify your application code to use the Cloud Pub/Sub client library to pull messages from the subscription. Here are the general steps:
By following these steps, you can deploy an application on Cloud Run that processes messages from a Cloud Pub/Sub topic in a way that follows Google-recommended practices.