无法为主题创建订阅

Unable to create subscription for topic

我正在尝试 google 部署管理器。

我创建了一个 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

我收到以下错误

The fingerprint of the deployment is xxxxxxxxxxxxx== Waiting for create [operation-xxxxxxxx-xxxxxx-xxxx-xxxx]...failed. ERROR: (gcloud.deployment-manager.deployments.create) Error in Operation [operation-xxxxx-xxxx-xxxx-xxxx]: errors: - code: RESOURCE_ERROR location: /deployments/google-pub-sub/resources/pubsub-sub message: '{"ResourceType":"gcp-types/pubsub-v1:projects.subscriptions","ResourceErrorCode":"404","ResourceErrorMessage":{"code":404,"message":"Resource not found (resource=topic-01).","status":"NOT_FOUND","details":[],"statusMessage":"Not Found","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。如果有人知道,请告诉我。

谢谢!!!

好吧,我通过使用 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: {}