{
  "id": "terraform-7",
  "title": "Pub/Sub Outbound Events / Signal - Config",
  "description": "Create an Outbound Events configuration with a Pub/Sub provider.",
  "category": "Outbound Events",
  "lastUpdated": "2026-04-28",
  "terraformProviderDocs": [
    "https://registry.terraform.io/providers/indykite/indykite/latest/docs/resources/event_sink"
  ],
  "relatedGuides": [
    "/guides/guide-terraform",
    "/guides/guide-outbound-events"
  ],
  "commonErrors": [
    {
      "code": "ALREADY_EXISTS",
      "message": "Only one event sink per project",
      "solution": "Delete the existing event sink before creating a new one, or import it into Terraform state"
    },
    {
      "code": "INVALID_ARGUMENT",
      "message": "Invalid Pub/Sub configuration",
      "solution": "Verify GCP Service Account API key, permissions are correct"
    }
  ],
  "summary": "Outbound Events (Signals) push real-time notifications to external systems when changes occur in your IndyKite environment.\nThis configuration sets up event streaming to Pub/Sub for configuration changes:\n1. Define Pub/Sub as the event provider.\n2. Route configuration change events to a Pub/Sub topic.\n3. Receive messages when any configuration is created, read, updated, or deleted.",
  "usecase": "Scenario: You need to audit or react to configuration changes in your IndyKite project.\nEach time a configuration node is modified (create, read, update, delete), an event is sent to your Pub/Sub topic. This enables:\n- Audit logging of all configuration changes.\n- Triggering downstream workflows when configurations are updated.\n- Real-time monitoring of your IndyKite environment.\nNote: Only one Outbound Events configuration can be active per project.",
  "requirements": "- ServiceAccount credentials created in the IndyKite Hub for your organization.\n- IndyKite Terraform provider 0.49.0 or later, the release the example pins in required_providers; the Terraform guide lists the version each feature first appeared in.\n- A GCP Service Account with a valid API Key with IAM permission roles/pubsub.editor (or roles/pubsub.publisher + roles/pubsub.viewer).\n- A Pub/Sub topic created in your GCP Project.\n- A subscription for the topic",
  "steps": "1. Securely provide GCP Service Account credentials to the Terraform configuration via a credentials file.\n    2. Apply the Terraform configuration to create the Outbound Events setup.\n3. Perform any CRUD action on a configuration node in your project.\n4. Verify that event messages appear in your Pub/Sub topic subscription.",
  "code": [
    {
      "filename": "main.tf",
      "code": "\nterraform {\n  required_providers {\n    indykite = {\n      source  = \"indykite/indykite\"\n      version = \">= 0.49.0\" # or a later release\n    }\n  }\n}\n\n# indykite provider integrates IndyKite platform with Terraform scripting.\n# Provider for now does not support any parameters and all is set within service account credential file.\nprovider \"indykite\" {}\n\nresource \"indykite_event_sink\" \"outbound_events\" {\n  name               = \"outbound-events\"\n  display_name       = \"Outbound Events\"\n  project_id         = \"gid:AAAAAmluZHlraURlgAABDwAAAAA\" # your project GID\n  include_cdc_events = false\n  providers {\n    provider_name = \"pubsub-provider\"\n    pubsub {\n      project_id       = \"pub-sub-gcp-project-id\"\n      topic_name       = \"topic-name-in-pub-sub\"\n      credentials_json = var.pubsub_credentials_json\n    }\n  }\n  routes {\n    provider_id     = \"pubsub-provider\"\n    stop_processing = true\n    keys_values_filter {\n      event_type = \"indykite.audit.config.*\"\n    }\n    route_display_name = \"Configuration Audit Events\"  }\n}\n\nresource \"indykite_authorization_policy\" \"policy_drive_car\" {\n  name         = \"terraform-policy-drive-car\"\n  display_name = \"Terraform policy drive car\"\n  description  = \"Policy person drive car\"\n  json = jsonencode({\n    meta = {\n      policy_version = \"2.0-kbac\"\n    },\n    subject = {\n      type = \"Person\"\n    },\n    actions = [\"CAN_DRIVE\"],\n    resource = {\n      type = \"Car\"\n    },\n    condition = {\n      cypher = \"MATCH (subject)-[:DRIVES]->(resource:Car)\"\n    }\n  })\n  project_id = \"gid:AAAAAmluZHlraURlgAABDwAAAAA\" # your project GID\n  status     = \"active\"\n}\n\n# the service account key file of the account that may publish to the topic\nvariable \"pubsub_credentials_json\" {\n  type      = string\n  sensitive = true\n}\n"
    }
  ],
  "links": {
    "html": "/terraform/terraform-7",
    "markdown": "/terraform/terraform-7.md",
    "terraformRegistry": "https://registry.terraform.io/providers/indykite/indykite/latest/docs"
  }
}