0
0
GCPcloud~10 mins

Event triggered functions in GCP - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the trigger type for a Cloud Function that runs when a file is uploaded to a Cloud Storage bucket.

GCP
trigger = [1]
Drag options to blanks, or click blank then click option'
A"google.storage.object.finalize"
B"pubsub"
C"http"
D"schedule"
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing 'http' which triggers on HTTP requests, not storage events.
Choosing 'pubsub' which is for message topics, not storage.
2fill in blank
medium

Complete the code to specify the resource (bucket name) that triggers the Cloud Function.

GCP
resource = "projects/_/buckets/[1]"
Drag options to blanks, or click blank then click option'
Amy-topic
Bmy-bucket
Cmy-function
Dmy-schedule
Attempts:
3 left
💡 Hint
Common Mistakes
Using a Pub/Sub topic name instead of a bucket name.
Using the function name as the resource.
3fill in blank
hard

Fix the error in the function signature to correctly receive the event data and context in a Cloud Function triggered by a storage event.

GCP
def hello_[1](event, context):
    print(f"File {event['name']} uploaded.")
Drag options to blanks, or click blank then click option'
Arequest
Bdata
Cevent
Dstorage_event
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'request' which is for HTTP triggers.
Using 'storage_event' or 'data' which are not standard parameter names.
4fill in blank
hard

Fill both blanks to complete the deployment command for a Cloud Function triggered by a Pub/Sub topic.

GCP
gcloud functions deploy my-function --trigger-[1] [2] --runtime python312
Drag options to blanks, or click blank then click option'
Atopic
Bbucket
Cmy-topic
Dmy-bucket
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'bucket' instead of 'topic' for the trigger flag.
Using a bucket name instead of a topic name.
5fill in blank
hard

Fill all three blanks to complete the event trigger configuration in a Cloud Function deployment YAML for a storage event.

GCP
eventTrigger:
  eventType: [1]
  resource: projects/_/buckets/[2]
  failurePolicy:
    [3]: {}
Drag options to blanks, or click blank then click option'
Agoogle.storage.object.delete
Bmy-bucket
Cretry
Dgoogle.pubsub.topic.publish
Attempts:
3 left
💡 Hint
Common Mistakes
Using a Pub/Sub event type for a storage trigger.
Omitting the failurePolicy or using incorrect keys.