google-cloud-platformgcloudevent-arc

gcloud cli command create eventarc errors


I tried to create eventarc trigger with gcloud cli, in order to specify path patterns. Following the documentation. https://cloud.google.com/sdk/gcloud/reference/eventarc/triggers/create#--destination-run-service https://cloud.google.com/eventarc/docs/path-patterns#valid_patterns

and some online steps https://atamel.dev/posts/2022/03-02_path_patterns_eventarc/

However i received error as below:

ERROR: (gcloud.eventarc.triggers.create) Error parsing [trigger].
The [trigger] resource is not properly specified.
Failed to find attribute [location]. The attribute can be set in the following ways: 
- provide the argument `trigger` on the command line with a fully specified name
- provide the argument `--location` on the command line
- set the property `eventarc/location`

My command as below:

gcloud eventarc triggers create bq-trigger-test --destination-run-service=bigquery-upload \
--destination-run-region=asia-southeast1 --event-filters="type=google.cloud.storage.object.v1.finalized" \
--event-filters="bucket=bucket-name" \
--event-filters-path-pattern="bucket=/projects/_/buckets/bucket-name/objects/**/filename.json"

I saw this issue but it should have been resolved: https://github.com/GoogleCloudPlatform/python-docs-samples/issues/5057 https://github.com/GoogleCloudPlatform/python-docs-samples/pull/5348

Anyone facing the same? Or able to identify any issue from my command above?

thanks


Solution

  • I figured out why.

    I have indicated the right name for the trigger in fact, but i need to provide --location. I mistakenly thought that I have provided the region but it was indicating the cloud run service ones instead. i need to tell eventarc the location of the triggers to create in.

    Also a few other errors from my command - event-filters-path-pattern does not support all types.

    So my final form of command that work is:

    gcloud eventarc triggers create bq-trigger-test --location=asia-southeast1 \
    --destination-run-service=bigquery-upload --destination-run-region=asia-southeast1 \
    --event-filters="type=google.cloud.audit.log.v1.written" \
    --event-filters="serviceName=storage.googleapis.com" \
    --event-filters="methodName=storage.objects.create" \
    --event-filters-path-pattern="resourceName=/projects/_/buckets/bucket-name/objects/**/file-name.json" \
    --service-account=abcde.iam.gserviceaccount.com