litellm/terraform/provider/docs/resources/key_block.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.6 KiB

litellm_key_block Resource

Manages the blocked state of an existing LiteLLM API key. Creating this resource blocks the key; destroying it unblocks the key.

If the key is unblocked outside of Terraform (or deleted), the resource is removed from state and Terraform plans to re-block it on the next apply.

Example Usage

resource "litellm_key" "example" {
  models = ["gpt-4"]
}

resource "litellm_key_block" "example" {
  key = litellm_key.example.key
}

Argument Reference

The following arguments are supported:

  • key - (Required, Forces new resource, Sensitive) The API key to block, as the raw sk- value or its SHA-256 token hash. The provider normalizes raw values to the hash before talking to the API, so the plaintext key never appears in request URLs, the resource ID, or plan output.

Attribute Reference

In addition to the arguments above, the following attributes are exported:

  • id - The SHA-256 token hash of the key.
  • blocked - Whether the key is currently blocked. Always true while this resource exists.

If the same key is also managed by a litellm_key resource, that resource's blocked attribute will show drift while the block is active; either set blocked there instead of using this resource, or add lifecycle { ignore_changes = [blocked] } to the litellm_key.

Import

Key blocks can be imported using the key's SHA-256 token hash (shown as the key's ID in litellm_key state and in /key/info):

terraform import litellm_key_block.example 88362cbb875f4b48b4b5b56b2ea45f66465e27d55a189816bd54e5643e5410eb