简体   繁体   中英

How to specify pubsub topic when deploying event arc triggered 2nd gen cloud function using gcloud command

I want to deploy cloud function that is triggerred by pubsub eventarc trigger using gcloud command line, but I haven't found a way to specify the pubsub topic with the gcloud command.

I have tried executing gcloud command like this:

gcloud functions deploy <function_name> \
--gen2 \
--source=. \
--trigger-event-filters=type=google.cloud.pubsub.topic.v1.messagePublished \
--trigger-location=asia-southeast2 \
--trigger-service-account=<service_account> \
--runtime=python310 \
--entry-point=hello_pubsub \
--project=<project_id> \
--region=asia-southeast2

But I got this error:

gcloud.functions.deploy) INVALID_ARGUMENT: Pubsub topic must be set for events with type google.cloud.pubsub.topic.v1.messagePublished.

I have checked GCP documentation eventarc cloud function documentation , but they do not mention on how to specify the pubsub topic.

My objective is to call this gcloud command from the cloud build pipeline to automatically deploy the cloud function.

Thank You

You can use --trigger-topic to specify the topic.

gcloud functions deploy <function_name> \
--gen2 \
--source=. \
--trigger-topic=topic_name
....

The --trigger-event-filters can be used to filter out events based on any other attributes. Checkout the linked documentation for more information.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM