terraform-provider-stackgen

sg_knowledge_source (Resource)

⚠️ Experimental — Manages a syncable external knowledge source inside a sg_knowledge_base. Sources use a sg_guild_integration for credentials and sync configured folder or file targets into the knowledge base.

The Guild API does not support in-place updates; changing input fields forces replacement. Import with the server-assigned id (UUID).

Example Usage

# When to use: Sync an external system (Confluence, Drive, …) into a knowledge
# base so agents can retrieve runbooks/docs without manual URL uploads.
# Prefer sg_knowledge_document for one-off PDF/URL ingest.
#
# Prerequisites: sg_knowledge_base; sg_guild_integration with credentials for
# the source provider. Changing inputs forces replacement (API has no update).
#
# Related: sg_knowledge_base, sg_knowledge_document, sg_guild_integration,
# sg_agent.knowledge (enable memory on agents that should use the base).
resource "sg_knowledge_base" "runbooks" {
  name        = "team-runbooks"
  description = "Synced SOPs and wiki pages for incident response."
}

resource "sg_guild_integration" "confluence" {
  name        = "example-confluence"
  description = "Confluence MCP / knowledge sync credentials."
  type        = "confluence"
  enabled     = true
  # secret_ref_ids = [sg_secret.confluence.id]
}

resource "sg_knowledge_source" "confluence_space" {
  name              = "ops-wiki"
  knowledge_base_id = sg_knowledge_base.runbooks.id
  integration_name  = sg_guild_integration.confluence.name
  type              = "confluence"
  knowledge_type    = "RUNBOOK"

  targets = [
    {
      target_type  = "space"
      input        = "OPS"
      display_name = "Operations space"
    },
    {
      target_type = "page_tree"
      input       = "123456789" # provider page ID
    },
  ]
}

Import

Import an existing sg_knowledge_source using its knowledge source UUID:

terraform import sg_knowledge_source.example '123e4567-e89b-12d3-a456-426614174000'

Operational notes

Create the knowledge base and referenced Guild integration first; the integration supplies access to the external source. Changing source inputs requires replacement.

Schema

Required

Optional

Read-Only

Nested Schema for targets

Required:

Optional:

Read-Only: