⚠️ 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.
# 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 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'
agent_name (String) Name of the agent to attach the policy to. Changing this forces a new resource.policy_id (String) UUID of the policy to attach. Changing this forces a new resource.enabled (Boolean) Whether the policy attachment is enabled. Defaults to true.