创建通知集成以向 Google Cloud Pub/Sub 主题发送通知¶
要向 Google Cloud Pub/Sub 主题发送通知,您必须为该主题创建通知集成。要这样做,请执行以下操作:
- Create a Pub/Sub topic.
- Create a Pub/Sub subscription.
- Create a notification integration.
- Grant Snowflake access to the Pub/Sub subscription.
Note
Currently, this feature is limited to Snowflake accounts hosted on Google Cloud (GC).
创建 Pub/Sub 主题¶
Create a Pub/Sub topic that can receive error notification messages from Snowflake, or reuse an existing topic. You can create the topic using Cloud Shell (https://cloud.google.com/shell) or Cloud SDK (https://cloud.google.com/sdk). For more information, see Create and use topics (https://cloud.google.com/pubsub/docs/admin) in the Pub/Sub documentation.
例如,执行以下命令以创建一个空主题:
如果主题已存在,则该命令将使用该主题;如果不存在,将创建一个新主题。
创建 Pub/Sub 订阅¶
Optionally, create a subscription to the Pub/Sub topic to retrieve notifications. You can create a subscription with pull
delivery using the Cloud Console, gcloud command-line tool, or the Cloud Pub/Sub API. For instructions, see
Managing topics and subscriptions (https://cloud.google.com/pubsub/docs/admin) in the Pub/Sub documentation.
在 Snowflake 中创建通知集成¶
Run the CREATE NOTIFICATION INTEGRATION command to create a notification integration. An integration is a Snowflake object that references the Pub/Sub topic you created.
Snowflake associates the notification integration with a Google Cloud (GC) service account created for your account. Snowflake creates a single service account that is referenced by all GCP notification integrations in your Snowflake account. The GCP service account for notification integrations is different from the service account created for storage integrations.
When running the command, set GCP_PUBSUB_TOPIC_NAME to the name of the topic that you created earlier.
例如:
授予 Snowflake 对 Pub/Sub 订阅的访问权限¶
-
Execute the DESCRIBE NOTIFICATION INTEGRATION command to display the properties of the notification that you just created.
For example, to display the properties of the notification integration named
my_notification_int: -
记录 GCP_PUBSUB_SERVICE_ACCOUNT 属性的值(服务账户名称),其格式如下:
-
Log into the Google Cloud console as a project editor.
-
From the home dashboard, choose Big Data » Pub/Sub » Subscriptions.
-
选择要配置访问权限的订阅。
-
Select SHOW INFO PANEL in the upper-right corner. The information panel for the subscription slides out.
-
In the Add members field, search for the service account name you recorded.
-
From the Select a role dropdown, select Pub/Sub Publisher.
-
Select Add.
The service account name is added to the Pub/Sub Publisher role dropdown in the information panel.