terraform-provider-stackgen

sg_agent_policy_attachment (Resource)

⚠️ Experimental — This resource is part of the Guild platform and may change in future releases.

Attaches a governance policy to an agent. The policy’s Rego rules will be evaluated before the agent executes any tool call.

Example Usage

# Attach a policy to an agent by name and policy UUID.
resource "sg_agent" "example" {
  name = "governed-agent"
}

resource "sg_policy" "example" {
  name        = "example-policy"
  description = "Sample policy for attachment."
  type        = "tool_call"
  rego_source = "package guild.policy\nimport rego.v1\ndefault decision := \"allow\"\n"
}

resource "sg_agent_policy_attachment" "example" {
  agent_name = sg_agent.example.name
  policy_id  = sg_policy.example.id
  enabled    = true
}

Import

Import an existing sg_agent_policy_attachment using its agent name/policy ID:

terraform import sg_agent_policy_attachment.example 'my-first-agent/123e4567-e89b-12d3-a456-426614174000'

Schema

Required

Optional