litellm/terraform/provider/docs/resources/guardrail.md
Shivam Rawat 3653e5893f
feat(terraform): resource and data source parity with the community provider (#38158)
* feat(terraform): close key/team schema gaps, fix team read envelope, add import support

* feat(terraform): add fallback resource/data source and key/team block resources

* feat(terraform): add access group and unified access group resources and data sources

* feat(terraform): add guardrail and prompt resources and data sources

* feat(terraform): add agent and search tool resources and data sources

* feat(terraform): add user and budget resources and data sources

* feat(terraform): add tag and project resources and data sources

* docs(terraform): changelog and readme for parity additions

* feat(terraform): add data sources for keys, teams, models, organizations, and mcp servers

* fix(terraform): key update 400 on empty budget_duration, key info envelope, config-supplied key

* fix(terraform): hash raw keys to SHA-256 tokens in key lookup URLs and block resource IDs
2026-08-28 16:55:40 -07:00

1.9 KiB

litellm_guardrail Resource

Manages a guardrail in LiteLLM. Guardrails provide content filtering, PII detection, prompt injection protection, and more.

Example Usage

resource "litellm_guardrail" "bedrock_guard" {
  guardrail_name = "my-bedrock-guard"
  guardrail      = "bedrock"
  mode           = "pre_call"
  default_on     = true

  litellm_params = jsonencode({
    guardrailIdentifier = "ff6ujrregl1q"
    guardrailVersion    = "DRAFT"
  })

  guardrail_info = {
    description = "Bedrock content moderation guardrail"
  }
}

Multiple Modes

resource "litellm_guardrail" "pii_guard" {
  guardrail_name = "presidio-pii"
  guardrail      = "presidio"
  mode           = jsonencode(["pre_call", "post_call"])
}

Argument Reference

  • guardrail_name - (Required) Human-readable name for the guardrail.
  • guardrail - (Required) The guardrail integration type (e.g. bedrock, lakera, presidio, openai_moderation, hide_secrets).
  • mode - (Required) When to apply the guardrail. A single value (pre_call, post_call, during_call, logging_only) or a JSON array of values.
  • default_on - (Optional) Whether the guardrail is enabled by default for all requests.
  • litellm_params - (Optional, Sensitive) JSON string with additional provider-specific parameters merged into litellm_params (may contain API keys). The API masks these values, so the configured value stays authoritative in state.
  • guardrail_info - (Optional) Map of additional metadata for the guardrail.

Attribute Reference

  • id - The guardrail ID assigned by LiteLLM.
  • created_at - Timestamp when the guardrail was created.

Import

Guardrails can be imported using the guardrail ID:

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

Note: guardrail, mode, default_on and litellm_params are not returned unmasked by the API, so after import you must set them in configuration to match the server.