Skip to content

Commit 0ed4066

Browse files
author
Nicholas Cecere
committed
feat: Add credential and vector store resources with data sources
- Add new litellm_credential resource for managing secure authentication - Support for storing sensitive credential values (API keys, tokens, etc.) - Non-sensitive credential information storage - Model ID association for credentials - Secure handling of sensitive data with Terraform's sensitive attribute - Add new litellm_vector_store resource for managing vector stores - Support for multiple vector store providers (Pinecone, Weaviate, Chroma, Qdrant, etc.) - Integration with credential management for secure authentication - Configurable metadata and provider-specific parameters - Full CRUD operations for vector store lifecycle management - Add corresponding data sources for both resources - litellm_credential data source for cross-stack referencing - litellm_vector_store data source for monitoring and validation - Security-conscious design excluding sensitive values from data sources - Enhanced API response handling and error management - Comprehensive documentation and examples for all new resources - Updated provider configuration and version to 0.3.11
1 parent 28a810c commit 0ed4066

18 files changed

+1711
-324
lines changed

CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.3.11] - 2025-08-10
11+
12+
### Added
13+
- **New Resource**: `litellm_credential` - Manage credentials for secure authentication
14+
- Support for storing sensitive credential values (API keys, tokens, etc.)
15+
- Non-sensitive credential information storage
16+
- Model ID association for credentials
17+
- Secure handling of sensitive data with Terraform's sensitive attribute
18+
- **New Resource**: `litellm_vector_store` - Manage vector stores for embeddings and RAG
19+
- Support for multiple vector store providers (Pinecone, Weaviate, Chroma, Qdrant, etc.)
20+
- Integration with credential management for secure authentication
21+
- Configurable metadata and provider-specific parameters
22+
- Full CRUD operations for vector store lifecycle management
23+
- **New Data Source**: `litellm_credential` - Retrieve information about existing credentials
24+
- Read-only access to credential metadata (sensitive values excluded for security)
25+
- Support for model ID filtering
26+
- Cross-stack and cross-configuration referencing capabilities
27+
- **New Data Source**: `litellm_vector_store` - Retrieve information about existing vector stores
28+
- Complete vector store information retrieval
29+
- Support for monitoring, validation, and cross-referencing use cases
30+
- Metadata-based conditional logic support
31+
- Enhanced API response handling for credential and vector store operations
32+
- Comprehensive documentation and examples for new resources and data sources
33+
- Example Terraform configurations for common use cases
34+
35+
### Changed
36+
- Extended `utils.go` with specialized API response handlers for credentials and vector stores
37+
- Updated provider configuration to include new resources and data sources
38+
- Enhanced error handling for credential and vector store not found scenarios
39+
1040
## [0.3.10] - 2025-08-10
1141

1242
### Added

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ terraform {
2828
required_providers {
2929
litellm = {
3030
source = "ncecere/litellm"
31-
version = "~> 0.3.10"
31+
version = "~> 0.3.11"
3232
}
3333
}
3434
}
@@ -132,6 +132,13 @@ For full details on the <code>litellm_key</code> resource, see the [key resource
132132
- <code>litellm_team_member</code>: Manage team members. [Documentation](docs/resources/team_member.md)
133133
- <code>litellm_key</code>: Manage API keys. [Documentation](docs/resources/key.md)
134134
- <code>litellm_mcp_server</code>: Manage MCP (Model Context Protocol) servers. [Documentation](docs/resources/mcp_server.md)
135+
- <code>litellm_credential</code>: Manage credentials for secure authentication. [Documentation](docs/resources/credential.md)
136+
- <code>litellm_vector_store</code>: Manage vector stores for embeddings and RAG. [Documentation](docs/resources/vector_store.md)
137+
138+
### Available Data Sources
139+
140+
- <code>litellm_credential</code>: Retrieve information about existing credentials. [Documentation](docs/data-sources/credential.md)
141+
- <code>litellm_vector_store</code>: Retrieve information about existing vector stores. [Documentation](docs/data-sources/vector_store.md)
135142

136143
## Development
137144

docs/data-sources/credential.md

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "litellm_credential Data Source - terraform-provider-litellm"
4+
subcategory: ""
5+
description: |-
6+
Retrieves information about an existing LiteLLM credential.
7+
---
8+
9+
# litellm_credential (Data Source)
10+
11+
Retrieves information about an existing LiteLLM credential. This data source allows you to reference credentials that were created outside of Terraform or in other Terraform configurations.
12+
13+
## Example Usage
14+
15+
```terraform
16+
# Retrieve an existing credential by name
17+
data "litellm_credential" "existing_openai" {
18+
credential_name = "openai-production-key"
19+
}
20+
21+
# Use the credential in a model resource
22+
resource "litellm_model" "gpt4_with_existing_cred" {
23+
model_name = "gpt-4-with-existing-cred"
24+
custom_llm_provider = "openai"
25+
base_model = "gpt-4"
26+
tier = "paid"
27+
mode = "chat"
28+
29+
# Reference the existing credential's info
30+
additional_litellm_params = {
31+
credential_name = data.litellm_credential.existing_openai.credential_name
32+
}
33+
}
34+
```
35+
36+
## Example Usage with Model ID
37+
38+
```terraform
39+
# Retrieve a credential associated with a specific model
40+
data "litellm_credential" "model_specific_cred" {
41+
credential_name = "claude-api-key"
42+
model_id = "claude-3-sonnet"
43+
}
44+
45+
# Use in a vector store
46+
resource "litellm_vector_store" "knowledge_base" {
47+
vector_store_name = "claude-knowledge-base"
48+
custom_llm_provider = "anthropic"
49+
litellm_credential_name = data.litellm_credential.model_specific_cred.credential_name
50+
51+
vector_store_description = "Knowledge base using Claude credentials"
52+
}
53+
```
54+
55+
## Example Usage for Cross-Reference
56+
57+
```terraform
58+
# Get credential info to use in other resources
59+
data "litellm_credential" "shared_cred" {
60+
credential_name = "shared-api-key"
61+
}
62+
63+
# Create multiple resources using the same credential
64+
resource "litellm_vector_store" "store_1" {
65+
vector_store_name = "store-1"
66+
custom_llm_provider = "pinecone"
67+
litellm_credential_name = data.litellm_credential.shared_cred.credential_name
68+
69+
vector_store_description = "First store using shared credential"
70+
}
71+
72+
resource "litellm_vector_store" "store_2" {
73+
vector_store_name = "store-2"
74+
custom_llm_provider = "pinecone"
75+
litellm_credential_name = data.litellm_credential.shared_cred.credential_name
76+
77+
vector_store_description = "Second store using shared credential"
78+
}
79+
```
80+
81+
## Argument Reference
82+
83+
The following arguments are supported:
84+
85+
* `credential_name` - (Required) Name of the credential to retrieve.
86+
* `model_id` - (Optional) Model ID associated with this credential. Use this when the same credential name is used for different models.
87+
88+
## Attributes Reference
89+
90+
In addition to all arguments above, the following attributes are exported:
91+
92+
* `credential_info` - Map of additional non-sensitive information about the credential.
93+
94+
## Security Note
95+
96+
For security reasons, the `credential_values` (sensitive data like API keys) are not exposed through data sources. This prevents accidental exposure of sensitive information in Terraform plans and logs. If you need to access credential values, you should manage them through the resource directly or use external secret management systems.
97+
98+
## Common Use Cases
99+
100+
### 1. Cross-Stack References
101+
Use data sources to reference credentials created in other Terraform configurations or stacks:
102+
103+
```terraform
104+
data "litellm_credential" "shared_openai" {
105+
credential_name = "openai-shared-key"
106+
}
107+
108+
resource "litellm_model" "gpt4" {
109+
model_name = "gpt-4-cross-stack"
110+
custom_llm_provider = "openai"
111+
base_model = "gpt-4"
112+
113+
additional_litellm_params = {
114+
credential_reference = data.litellm_credential.shared_openai.credential_name
115+
}
116+
}
117+
```
118+
119+
### 2. Conditional Logic
120+
Use credential information for conditional resource creation:
121+
122+
```terraform
123+
data "litellm_credential" "optional_cred" {
124+
credential_name = var.credential_name
125+
}
126+
127+
resource "litellm_vector_store" "conditional_store" {
128+
count = length(data.litellm_credential.optional_cred.credential_info) > 0 ? 1 : 0
129+
130+
vector_store_name = "conditional-store"
131+
custom_llm_provider = "weaviate"
132+
litellm_credential_name = data.litellm_credential.optional_cred.credential_name
133+
}
134+
```
135+
136+
### 3. Validation and Verification
137+
Verify that required credentials exist before creating dependent resources:
138+
139+
```terraform
140+
data "litellm_credential" "required_cred" {
141+
credential_name = "production-api-key"
142+
}
143+
144+
# This will fail if the credential doesn't exist
145+
resource "litellm_model" "production_model" {
146+
model_name = "production-gpt-4"
147+
custom_llm_provider = "openai"
148+
base_model = "gpt-4"
149+
150+
additional_litellm_params = {
151+
credential_name = data.litellm_credential.required_cred.credential_name
152+
}
153+
}

0 commit comments

Comments
 (0)