Ensure that at least one event trigger was configured in your function

Events are things that happen within your cloud environment that you might want to take action on. These might be changes to data in a database, files added to a storage system, or a new virtual machine instance being created. Creating a response to an event is done with a trigger. A trigger is a declaration that you are interested in a certain event or set of events. Binding a function to a trigger allows you to capture and act on events.

Risk Level: Low
Cloud Entity: Google Cloud Function
CloudGuard Rule ID: D9.GCP.MON.01
Covered by Spectral: Yes
Category: Compute

GSL LOGIC

CloudFunction should have trigger.eventTrigger

REMEDIATION

Cloud Functions supports the following event-based triggers:

  1. Cloud Pub/Sub Triggers - https://cloud.google.com/functions/docs/calling/pubsub
  2. Cloud Storage Triggers - https://cloud.google.com/functions/docs/calling/storage
  3. Direct Triggers - https://cloud.google.com/functions/docs/running/direct
  4. Cloud Firestore - https://cloud.google.com/functions/docs/calling/cloud-firestore
  5. Analytics for Firebase - https://cloud.google.com/functions/docs/calling/google-analytics-firebase
  6. Firebase Realtime Database - https://cloud.google.com/functions/docs/calling/realtime-database
  7. Firebase Authentication - https://cloud.google.com/functions/docs/calling/firebase-auth

When you create a function you need to choose one event type.

From Portal

  1. Go to the Cloud Functions Overview page. https://console.cloud.google.com/functions
  2. Click on 'create function'
  3. In Trigger section, choose a trigger.
  4. For each trigger fill the required information.
  5. Click save

From TF

resource "google_cloudfunctions_function" "test" {
+ event_trigger {}
}

From Command Line
In order to directly invoke a function,run:

gcloud functions deploy FUNCTION_NAME --entry-point ENTRY_POINT --trigger-topic TOPIC_NAME FLAGS

References

  1. https://cloud.google.com/functions/docs/concepts/events-triggers#events
  2. https://cloud.google.com/functions/docs/concepts/events-triggers#triggers
  3. https://cloud.google.com/functions/docs/calling

Google Cloud Function

Cloud Functions is a lightweight compute solution for developers to create single-purpose, stand-alone functions that respond to Cloud events without the need to manage a server or runtime environment.

Compliance Frameworks

  • CloudGuard GCP All Rules Ruleset
  • GCP CloudGuard Best Practices
  • GCP MITRE ATT&CK Framework v12.1
  • GCP NIST 800-53 Rev 5