无法为主题创建订阅

时间:2019-07-02 13:55:10

标签: google-cloud-platform google-deployment-manager

我正在尝试使用Google Deployment Manager。

我已经创建了一个YAML文件,用于创建主题和该主题的推送订阅。

resources:
  - name: pubsub-topic
    type: gcp-types/pubsub-v1:projects.topics
    properties:
      topic: "topic-01"
  - name: pubsub-sub
    type: gcp-types/pubsub-v1:projects.subscriptions
    properties:
      subscription: "gcf-01"
      topic: "projects/my-project/topics/topic-01"
      pushConfig: 
        pushEndpoint: "https://us-central1-my-project.cloudfunctions.net/helloWorld/"
      ackDeadlineSeconds: 600
      expirationPeriod:

当我运行命令

cloud deployment-manager deployments create google-pub-sub --config C:\Development\GCP\DeploymentManager.yaml

我收到以下错误

  

部署的指纹为xxxxxxxxxxxxx ==正在等待   用于创建   [operation-xxxxxxxx-xxxxxx-xxxx-xxxx] ...失败。   错误:(gcloud.deployment-manager.deployments.create)中的错误   操作[operation-xxxxx-xxxx-xxxx-xxxx]:   错误:   -代码:RESOURCE_ERROR位置:/ deployments / google-pub-sub / resources / pubsub-sub消息:   '{“ ResourceType”:“ gcp-types / pubsub-v1:projects.subscriptions”,“ ResourceErrorCode”:“ 404”,“ ResourceErrorMessage”:{“ code”:404,“ message”:“ Resource       找不到(resource = topic-01)。“,”状态“:” NOT_FOUND“,”详细信息“:[],” statusMessage“:”未找到       找到”,“ requestPath”:“ https://pubsub.googleapis.com/v1/projects/my-project/subscriptions/gcf-01”,“ httpMethod”:“ PUT”}}'

现在,如果我运行命令

gcloud deployment-manager deployments update google-pub-sub --config C:\Development\GCP\DeploymentManager.yaml

有效。这是否意味着操作不是顺序的,并且系统正在尝试在创建主题之前创建订阅。

我仍然无法将ExpirationPeriod设置为Never。如果有人知道,那就让我知道。

谢谢!

1 个答案:

答案 0 :(得分:0)

我通过使用YAML文件中的引用解决了第一个问题,所以更改后的文件看起来像

resources:
  - name: pubsub-topic
    type: gcp-types/pubsub-v1:projects.topics
    properties:
      topic: "topic-01"
  - name: pubsub-sub
    type: gcp-types/pubsub-v1:projects.subscriptions
    properties:
      subscription: "gcf-01"
      topic: $(ref.pubsub-topic.name)
      pushConfig: 
        pushEndpoint: "https://us-central1-my-project.cloudfunctions.net/helloWorld/"
      ackDeadlineSeconds: 600
      expirationPolicy: {}