Google Professional Cloud Developer Question 346
Select 3Google Cloud PlatformYou are developing a Google Cloud Function to process user-uploaded images. The function should automatically execute whenever a new file is uploaded to a specific Cloud Storage bucket. Which of the following steps are required to properly configure the trigger for this functionality?
- A
Set the trigger type to 'Cloud Storage' and configure the bucket name.
- B
Set the trigger event to 'google.storage.object.finalize'.
- C
Set the trigger type to 'Pub/Sub' and subscribe to the Cloud Storage bucket's topic.
- D
Deploy the function with the '--trigger-bucket' flag specifying the bucket name.
- E
Set the trigger event to 'google.storage.object.delete'.
Show answer and explanation
Correct answers: A, B, D
Explanation
To trigger a Google Cloud Function when a file is uploaded to a Cloud Storage bucket, you need to set the correct trigger type ('Cloud Storage'), specify the event type ('google.storage.object.finalize'), and deploy the function with the '--trigger-bucket' flag to associate it with the correct bucket. Other configurations, such as Pub/Sub or unrelated events, are not necessary for this specific scenario.
- A. Correct.
Correct. To invoke a Cloud Function when a file is uploaded, you must set the trigger type to 'Cloud Storage' and specify the bucket to monitor.
- B. Correct.
Correct. 'google.storage.object.finalize' is the event that triggers the function when a new or updated object is finalized in the bucket.
- C. Incorrect.
Incorrect. While Pub/Sub can be used with Cloud Storage, it is not necessary for this use case. You can directly configure the Cloud Function to listen to Cloud Storage events.
- D. Correct.
Correct. The '--trigger-bucket' flag is required during deployment to specify the bucket name for the trigger configuration.
- E. Incorrect.
Incorrect. 'google.storage.object.delete' is triggered when a file is deleted, not uploaded. This does not fulfill the requirements of the scenario.