Bird
Raised Fist0
GCPcloud~5 mins

Event triggered functions in GCP - Cheat Sheet & Quick Revision

Choose your learning style10 modes available
Recall & Review
beginner
What is an event triggered function in Google Cloud?
An event triggered function runs automatically when a specific event happens, like a file upload or a message arrival. It reacts to changes without needing manual start.
Click to reveal answer
beginner
Name two common event sources for Google Cloud Functions.
1. Cloud Storage (e.g., file upload)
2. Pub/Sub (message arrival)
These trigger functions to run when events happen.
Click to reveal answer
beginner
How does an event triggered function differ from an HTTP triggered function?
Event triggered functions run automatically on events like file changes or messages. HTTP triggered functions run only when someone sends an HTTP request.
Click to reveal answer
beginner
What is a practical example of using an event triggered function?
Automatically resizing images when a new photo is uploaded to Cloud Storage. The upload event triggers the function to process the image.
Click to reveal answer
beginner
Why are event triggered functions useful in cloud architecture?
They allow automation and real-time response without manual intervention, saving time and resources by reacting only when needed.
Click to reveal answer
Which of these can trigger a Google Cloud event triggered function?
AA user clicking a button on a website
BA manual command in the terminal
CA new file uploaded to Cloud Storage
DA scheduled timer only
What type of event source is Pub/Sub in Google Cloud Functions?
AFile storage event source
BMessage queue event source
CHTTP request event source
DDatabase change event source
How does a Cloud Function know when to run if it is event triggered?
AIt runs only when manually started
BIt runs every hour automatically
CIt waits for a user to press a button
DIt listens for specific events configured during setup
Which is NOT a benefit of event triggered functions?
AManual start required every time
BEnables real-time automation
CSaves resources by running only when needed
DAutomatic response to events
What happens if an event triggered function fails during execution?
AIt can be retried automatically depending on configuration
BIt never runs again
CIt sends an email to all users
DIt shuts down the entire cloud project
Explain how event triggered functions work in Google Cloud and give an example use case.
Think about what happens when a file is uploaded or a message arrives.
You got /3 concepts.
    Describe the benefits of using event triggered functions in cloud applications.
    Consider how automation saves time and resources.
    You got /3 concepts.

      Practice

      (1/5)
      1. What is the main purpose of an event triggered function in Google Cloud Functions?
      easy
      A. To store data permanently in the cloud
      B. To manually start a function from the console
      C. To schedule functions to run at fixed times
      D. To automatically run code when a specific event occurs

      Solution

      1. Step 1: Understand event triggered functions

        Event triggered functions run automatically when a specific event happens, like a file upload or database change.
      2. Step 2: Compare options with the definition

        Only To automatically run code when a specific event occurs describes automatic running on events. Options B and C describe manual or scheduled runs, and D is unrelated.
      3. Final Answer:

        To automatically run code when a specific event occurs -> Option D
      4. Quick Check:

        Event triggered function = automatic run on event [OK]
      Hint: Event triggered means automatic run on event [OK]
      Common Mistakes:
      • Confusing event triggered with scheduled functions
      • Thinking manual start is event triggered
      • Mixing storage with function triggers
      2. Which of the following is the correct way to specify a Cloud Function triggered by a Cloud Storage event in deployment?
      easy
      A. gcloud functions deploy myFunc --trigger-resource my-bucket --trigger-event google.storage.object.finalize
      B. gcloud functions deploy myFunc --trigger-topic myTopic
      C. gcloud functions deploy myFunc --trigger-http
      D. gcloud functions deploy myFunc --trigger-schedule "every 5 minutes"

      Solution

      1. Step 1: Identify Cloud Storage event trigger syntax

        Cloud Storage events use --trigger-resource for the bucket and --trigger-event for the event type like object finalize.
      2. Step 2: Match options with correct syntax

        gcloud functions deploy myFunc --trigger-resource my-bucket --trigger-event google.storage.object.finalize correctly uses --trigger-resource and --trigger-event for Cloud Storage. Others are for HTTP, Pub/Sub, or scheduled triggers.
      3. Final Answer:

        gcloud functions deploy myFunc --trigger-resource my-bucket --trigger-event google.storage.object.finalize -> Option A
      4. Quick Check:

        Cloud Storage trigger = resource + event flags [OK]
      Hint: Storage triggers need resource and event flags [OK]
      Common Mistakes:
      • Using --trigger-http for storage events
      • Confusing Pub/Sub topic triggers with storage
      • Using schedule flags for event triggers
      3. Consider this Cloud Function triggered by a Pub/Sub topic named 'updates'. What will happen when a message is published to 'updates'?
      exports.processUpdate = (event, context) => {
        const message = Buffer.from(event.data, 'base64').toString();
        console.log(`Received message: ${message}`);
      };
      medium
      A. The function ignores the message and does nothing
      B. The function throws an error due to missing parameters
      C. The function logs the decoded message content
      D. The function logs the raw base64 message without decoding

      Solution

      1. Step 1: Understand event data decoding

        The function decodes the base64 event.data to a string and logs it.
      2. Step 2: Check function behavior on message publish

        When a message is published, the function runs and logs the decoded message content.
      3. Final Answer:

        The function logs the decoded message content -> Option C
      4. Quick Check:

        Pub/Sub event data decoded and logged [OK]
      Hint: Pub/Sub data is base64 decoded before use [OK]
      Common Mistakes:
      • Forgetting to decode base64 data
      • Assuming function errors without checking code
      • Thinking function ignores messages
      4. You deployed a Cloud Function triggered by Firestore document creation, but it never runs. Which of these is the most likely cause?
      medium
      A. The function is missing the correct Firestore trigger path
      B. The function code has a syntax error preventing deployment
      C. The Cloud Function is set to trigger on HTTP instead of Firestore
      D. The Firestore database is empty

      Solution

      1. Step 1: Check trigger configuration

        If the trigger path is incorrect, the function won't run on document creation events.
      2. Step 2: Eliminate other causes

        Syntax errors prevent deployment (not silent failure). HTTP trigger won't respond to Firestore events. Firestore being empty doesn't stop triggers on new documents.
      3. Final Answer:

        The function is missing the correct Firestore trigger path -> Option A
      4. Quick Check:

        Wrong trigger path = no function run [OK]
      Hint: Check trigger path matches Firestore event exactly [OK]
      Common Mistakes:
      • Assuming empty Firestore blocks triggers
      • Confusing HTTP triggers with event triggers
      • Ignoring trigger path correctness
      5. You want to create a Cloud Function that triggers when a new file is uploaded to any folder inside a Cloud Storage bucket named 'photos'. Which trigger configuration is correct?
      hard
      A. Use --trigger-resource photos and --trigger-event google.storage.object.metadataUpdate
      B. Use --trigger-resource photos and --trigger-event google.storage.object.finalize
      C. Use --trigger-resource photos and --trigger-event google.storage.object.archive
      D. Use --trigger-resource photos/* and --trigger-event google.storage.object.delete

      Solution

      1. Step 1: Identify correct event for new file upload

        The event google.storage.object.finalize triggers when a new object is created or overwritten.
      2. Step 2: Confirm resource and event usage

        The resource is the bucket name 'photos'. Wildcards like 'photos/*' are not valid for --trigger-resource.
      3. Final Answer:

        Use --trigger-resource photos and --trigger-event google.storage.object.finalize -> Option B
      4. Quick Check:

        New file upload = finalize event on bucket resource [OK]
      Hint: Use bucket name and finalize event for new uploads [OK]
      Common Mistakes:
      • Using delete or archive events instead of finalize
      • Trying to use wildcards in trigger-resource
      • Using metadataUpdate event which triggers on metadata changes
      Recommended

      Ready to prove it?

      Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

      10 questions~5 mineasy hard