attach existing subscription to google pub sub topic

Found the solution in google:
gcloud functions add-event-trigger FUNCTION_NAME --trigger-resource TOPIC_NAME --trigger-event google.pubsub.topic.publish --subscription SUBSCRIPTION_NAME

But its showing Invalid choice: ‘add-event-trigger’

gcloud functions deploy FUNCTION_NAME --trigger-resource TOPIC_NAME --trigger-event google.pubsub.topic.publish --subscription SUBSCRIPTION_NAME

Its giving error: unrecognized arguments: --subscription

4 Likes

Hi @anindita ,

SUBSCRIPTION_NAME is not necessary in this context because Pub/Sub triggers are set up based on a topic, not a specific subscription.

You can see all flags on Google documentation → https://cloud.google.com/sdk/gcloud/reference/functions/deploy

2 Likes

Hi @MaxImbrox
Thanks for your response.
My requirement is

“to attach existing subscription of a topic to a new Cloud function in GCP”
that means in my case I have to keep subscription as mandatory and that is the requirement here.
Can you please share some insight on it?

2 Likes