0

I can create a new pub/sub topic in my templates and a new service account.

I can see how to give that service account project wide pub/sub access: https://cloud.google.com/deployment-manager/docs/configuration/set-access-control-resources

Also that example seems to be using a different resource type, this is my template:

resources:
  - name: "mytopic"
    type: gcp-types/pubsub-v1:projects.topics
    #type: pubsub-v1ubsub.v1.topic
    properties:
      topic: "mytopic"
      labels:
        my-lable: mytopic

I'm using gcp-types/pubsub-v1:projects.topics when I switch to pubsub-v1ubsub.v1.topic I get:

- code: RESOURCE_NOT_FOUND
  message: The type [pubsub-v1ubsub.v1.topic] was not found.

If I try to add accessControl to gcp-types/pubsub-v1:projects.topics I get:

- code: RESOURCE_ERROR
  location: /deployments/mydeployment/resources/mytopic
  message: '{"ResourceType":"gcp-types/pubsub-v1:projects.topics","ResourceErrorCode":"404","ResourceErrorMessage":{"statusMessage":"Not
    Found","requestPath":"https://pubsub.googleapis.com/v1/:setIamPolicy","httpMethod":"POST"}}

I want to create a new topic, new service account, and give that service account access to that specific topic only.

Is this possible in deployment manager?

This is the full template with accessControl:

resources:
  - name: "mytopic"
    type: gcp-types/pubsub-v1:projects.topics
    #type: pubsub-v1ubsub.v1.topic
    properties:
      topic: "mytopic"
      labels:
        label: "sdfsdfsdf"
    accessControl:
      gcpIamPolicy:
        bindings:
        - role: roles/pubsub.editor
          members:
          - "serviceAccount:[email protected]"
        - role: roles/pubsub.publisher
          members:
          - "serviceAccount:[email protected]"

Edit

I think I got this working but now I have a question about dependencies. Do I need to declare the acl resource is dependant on the pub/sub resource? Or is this unnecessary? If I don't include it it works, but I want to confirm that it won't ever fail and try to deploy the acl first or something.

(Google could do with adding a complete example to their docs - it would go a long way to make them much more accessible).

resources:
  - name: "mytopic"
    type: gcp-types/pubsub-v1:projects.topics
    properties:
      topic: "mytopic"

  - name: "mytopic-permissions"
    type: pubsub.v1.topic
    properties:
      topic: "mytopic"
    accessControl:
      gcpIamPolicy:
        bindings:
        - role: roles/pubsub.editor
          members:
          - "serviceAccount:[email protected]"
        - role: roles/pubsub.publisher
          members:
          - "serviceAccount:[email protected]"
    # Do I need this? If I don't have it, deploys still seem to work
    metadata:
      dependsOn:
      - "mytopic"
8
  • I'm not seeing the puzzle. If I read here .. cloud.google.com/deployment-manager/docs/configuration/… ... it seems that in the example, they are creating a new topic and then ON THAT TOPIC are giving certain users, certain roles for JUST that topic rather than all topics. Are you seeing something different or have a different understanding?
    – Kolban
    Commented Oct 21, 2019 at 18:07
  • perhaps i misread that then. Where do I see the topic permissions in the UI? Is it visible there or only with gcloud? also when trying that example i get this error ` message: '{"ResourceType":"gcp-types/pubsub-v1:projects.topics","ResourceErrorCode":"404","ResourceErrorMessage":{"statusMessage":"Not Found","requestPath":"pubsub.googleapis.com/v1/…"}}'`
    – red888
    Commented Oct 21, 2019 at 19:29
  • Go to Cloud Console. Got to Pub/Sub. Go to list of topics. See existing topic. On right hand row of table, see "3 dots". Click. Click View Permissions.
    – Kolban
    Commented Oct 21, 2019 at 19:51
  • Can you show your full deployment manager file with your accessControl definition? Commented Oct 21, 2019 at 20:09
  • added the full template
    – red888
    Commented Oct 21, 2019 at 20:29

0