Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Identify your original project (e.g., skysharma-gcp) and the TARGET project I want publishes to go to is , your target project you want to publish (e.g., skysharma-gcp-2). Know , your Pub/Sub topic (e.g., root), and subscription (e.g., root-sub).

  2. Give your original service account permissions in the target project as per Cloud Pub/Sub Documentation. let me recreate the steps from that doc:

    1. Update the subscription policy:

      • Retrieve the current policy (Change change yours accordingly.):

        Code Block
        gcloud pubsub subscriptions get-iam-policy projects/skysharma-gcp-2/subscriptions/root-sub --format json > ~/Temp/subscription_policy.json
      • Edit subscription_policy.json to add your service account with the role roles/pubsub.editor. This gives my ORIGINAL the original service account access to this subscription in the NEW new project, . The updated subscription_policy.json would looks look like belowthis:

        • Code Block
             {
               "etag": "BwUjMhCsNvY=",
               "bindings": [
                 {
                   "role": "roles/pubsub.admin",
                   "members": [
                     "user:user-1@gmail.com"
                   ]
                 },
                 {
                   "role": "roles/pubsub.editor",
                   "members": [
                     "serviceAccount:skysharma-gcp-svc-acct@skysharma-gcp.iam.gserviceaccount.com"
                 }
               ]
             }
      • Apply the updated policy (Change change yours accordingly.):

        Code Block
        gcloud pubsub subscriptions set-iam-policy projects/skysharma-gcp-2/subscriptions/root-sub ~/Temp/subscription_policy.json
    2. Update the topic policy:

      • Retrieve the current policy (Change change yours accordingly.):

        Code Block
        gcloud pubsub topics get-iam-policy projects/skysharma-gcp-2/topics/root --format json > ~/Temp/topic_policy.json

      • Edit topic_policy.json similar to the subscription policy step to add the bindings item to allow my the current service account access to this topic, . The updated topic_policy.json would looks look like belowthis:

        • Code Block
             {
               "etag": "BwUjMhCsNvY=",
               "bindings": [
                 {
                   "role": "roles/pubsub.editor",
                   "members": [
                      "user:user-1@gmail.com",
                      "serviceAccount:skysharma-gcp-svc-acct@skysharma-gcp.iam.gserviceaccount.com"
                   ]
                 }
               ]
             }
      • Apply the updated policy (Change change yours accordingly.):

        Code Block
        gcloud pubsub topics set-iam-policy projects/skysharma-gcp-2/topics/root ~/Temp/topic_policy.json
  3. Have the API keys for your registry ready.

  4. Use the curl command to send a POST request to the changePubSubProject endpoint. This API changes the target project for your Pub/Sub topics.

    Code Block
    curl 'https://us-central1.clearblade.com/api/v/1/code/{SystemKey}/changePubSubProject' \ -X POST \ -d '{"project": "skysharma-gcp-2"}' \ -H 'ClearBlade-UserToken: {Token}'

    • Replace {SystemKey} and {Token} with your specific values.

    • If your URL is different (e.g., europe-west1.clearblade.com), adjust accordingly.

  5. Send a test MQTT message from your device into the registry. Verify the message appears in the target project’s Pub/Sub subscription.

Additional notes

  • The capability to change the target project is available as a new API endpoint using your registry API key.

  • Currently, this process has no UI; it's only available via API.

  • To validate, send a test message and check if it appears in the target project.