1
votes

I am trying my hands on google deployment manager.

I have created a YAML file where I am creating a topic and a push subscription for the topic.

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:

When I run the command

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

I get the following error

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"}}'

Now If I run the command

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

it works. Does this means that the operations are not sequential and system is trying to create subscription before the topic is created.

Also I am still not able to set the ExpirationPeriod to Never. If some one knows then do let me know.

Thanks!!!

1

1 Answers

1
votes

Well I solved the first issue by using the references in YAML file, so the changed file looks like

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: {}