A solutions team is building an automated file processing solution on Google Cloud. Every time a JPEG file is created in a Cloud Storage bucket named `raw-image-uploads`, a lightweight Node.js routine must run to create a thumbnail. The team chooses Cloud Functions (2nd gen) because of its native Eventarc integration and event-driven execution model. Which `gcloud` CLI command should the team run to correctly deploy this function triggered by file uploads?
- gcloud functions deploy thumbnail-generator --gen2 --runtime=nodejs20 --entry-point=createThumbnail --source=. --trigger-event-filters="type=google.cloud.storage.object.v1.finalized" --trigger-event-filters="bucket=raw-image-uploads" --region=us-central1Answer
- Bgcloud run deploy thumbnail-generator --source=. --port=8080 --trigger-bucket=gs://raw-image-uploads --region=us-central1
- Cgcloud functions deploy thumbnail-generator --gen2 --runtime=nodejs20 --entry-point=createThumbnail --source=. --trigger-http --allow-unauthenticated --region=us-central1
- Dgcloud functions deploy thumbnail-generator --gen2 --runtime=nodejs20 --entry-point=createThumbnail --source=. --trigger-event-filters="type=google.cloud.storage.object.v1.finalized" --project=my-org-root-policy
Answer
The command starting with `gcloud functions deploy thumbnail-generator --gen2` using `--trigger-event-filters` for `google.cloud.storage.object.v1.finalized` and specifying the `bucket=raw-image-uploads` filter is correct.
Deploying a 2nd gen Cloud Function triggered by Cloud Storage requires using the `gcloud functions deploy` command with the `--gen2` flag and Eventarc event filters. The filter `type=google.cloud.storage.object.v1.finalized` combined with `bucket=raw-image-uploads` ensures that the function is invoked whenever a new file is uploaded to the specified bucket.
Step-by-Step Solution
Key Concept
Deploying Cloud Functions (2nd gen) with Cloud Storage Eventarc triggers