【问题标题】:Create bulk topics & subscribers in google cloud在谷歌云中创建批量主题和订阅者
【发布时间】:2018-11-17 02:08:17
【问题描述】:

我正在寻找使用脚本或程序创建批量主题和订阅者的过程。我有所有主题和订阅者在脚本中创建命令。

如何执行脚本?

【问题讨论】:

    标签: gcloud google-cloud-pubsub


    【解决方案1】:

    通常有 3 种与 Google Cloud Platform 交互的方式。

    1. 网络用户界面 (http://console.cloud.google.com/)
    2. 直接使用 API (https://cloud.google.com/pubsub/docs/apis)
    3. 使用 Cloud SDK 命令行工具,尤其是 gcloud (https://cloud.google.com/sdk/gcloud/)

    网络用户界面通常不适合批量/自动操作,但后两者可以很好地工作。使用 API 取决于您喜欢的语言,所以我将举一个使用 gcloudbash 的示例(假设您已经安装并配置了 gcloud):

    $ head -n 2 topics.txt
    topic-1
    topic-2
    $ while read topic; do gcloud pubsub topics create $topic; done < topics.txt
    

    订阅有点棘手,因为gcloud pubsub subscriptions create 需要一个--topic 标志以及订阅名称的位置参数,但想法非常相似。

    【讨论】:

    • 感谢 Zachary 的 cmets。我会使用 API 与使用 Java 语言的云进行交互。有关于 Java API 的说明吗?
    猜你喜欢
    • 2022-07-26
    • 2023-01-01
    • 2021-12-03
    • 2020-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-03
    • 2019-04-24
    相关资源
    最近更新 更多