⚠️ 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).
# 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 an existing sg_knowledge_source using its knowledge source UUID:
terraform import sg_knowledge_source.example '123e4567-e89b-12d3-a456-426614174000'
Create the knowledge base and referenced Guild integration first; the integration supplies access to the external source. Changing source inputs requires replacement.
integration_name (String) Existing sg_guild_integration name used for credentials. Changing forces replacement.knowledge_base_id (String) UUID of the parent sg_knowledge_base. Changing forces replacement.name (String) Human-readable source name (1–120 characters). Changing forces replacement.targets (Attributes List) External locations to sync. At least one target is required. (see below for nested schema)type (String) Provider-specific syncable source type (integration-specific identifier). Changing forces replacement.knowledge_type (String) Content classification: KNOWLEDGE or RUNBOOK. Defaults to KNOWLEDGE when omitted.added_count (Number) Documents added during the latest sync.created_at (String) Creation timestamp (RFC 3339).document_count (Number) Number of active documents derived from this source.failed_count (Number) Resources or targets that failed during the latest sync.id (String) Server-assigned knowledge source UUID. Import with: terraform import sg_knowledge_source.example ‘last_sync_started_at (String) Time when the latest sync attempt started (RFC 3339).last_synced_at (String) Time when the latest sync attempt finished (RFC 3339).latest_error (String) Latest source-level sync error, if any.latest_warning (String) Latest source-level sync warning, if any.removed_count (Number) Documents removed during the latest sync.skipped_count (Number) Resources skipped during the latest sync.status (String) Lifecycle or sync status (idle, syncing, ready, failed).updated_at (String) Last update timestamp (RFC 3339).updated_count (Number) Documents updated during the latest sync.targetsRequired:
input (String) Provider-normalized target ID or setup input (path, file ID, etc.).target_type (String) Provider-defined target kind (e.g. folder, file, page, page_tree, space). Must match a value supported by the source provider.Optional:
display_name (String) Human-readable target name from provider metadata when available.Read-Only:
created_at (String) Target creation timestamp (RFC 3339).document_count (Number) Number of active documents derived from this target.external_id (String) Provider-normalized target identifier.latest_error (String) Latest target-level sync error, if any.latest_warning (String) Latest target-level sync warning, if any.status (String) Target sync status (idle, syncing, ready, failed).target_id (String) Server-assigned target UUID.updated_at (String) Target last update timestamp (RFC 3339).