Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: provider support jwt authentication #5

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ bin/

dist/
terraform-provider-litellm
.vscode
provider.json
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,7 @@ test: ## Run tests
release: ## Release the provider
@echo "Releasing version ${NEXT_VERSION}"
git tag -a ${NEXT_VERSION} -m "Release ${NEXT_VERSION}"
git push origin ${NEXT_VERSION}
git push origin ${NEXT_VERSION}

doc:
tfplugindocs generate
40 changes: 38 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The **LiteLLM Proxy Terraform Provider** allows you to manage models in your Lit
With this provider, you can automate the creation, updating, and deletion of AI models, enabling seamless integration
of AI model management into your infrastructure as code workflow.

## Example Usage
## Example Usage with api key authentication

```terraform
terraform {
Expand All @@ -32,10 +32,46 @@ provider "litellm" {
}
```

## Example usage with jwt authentication

```terraform
terraform {
required_providers {
litellm = {
source = "registry.terraform.io/gzamboni/litellm"
version = "0.2.0"
}
}
}

provider "litellm" {
api_base_url = "https://your-litellm-instance.com" # or omit to use LITELLM_API_BASE_URL

jwt_token_endpoint = "https://my-identity-provider/token" # or omit to use LITELLM_JWT_TOKEN_ENDPOINT
jwt_request_header = {
"Content-Type": "application/json" # Only application/json and application/x-www-form-urlencoded are supported for now
}
jwt_request_payload = {
client_id = "my-idp-client-id"
client_secret = "my-idp-client-secret"
scope = "my-litellm-admin-scope"
grant_type = "client_credentials"
}
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `api_base_url` (String) The base URL for the LiteLLM API (e.g., '<https://your-litellm-instance.com>').
- `api_base_url` (String) The base URL for the LiteLLM API (e.g., 'https://your-litellm-instance.com').

### Optional

- `api_token` (String) The API token (bearer token) for accessing the LiteLLM API.
- `jwt_request_header` (Map of String) IdP Headers to put in the request to get the token. You should also set `jwt_token_endpoint` and `jwt_request_payload`.
- `jwt_request_payload` (Map of String) IdP Headers to put in the request to get the token. You should also set `jwt_token_endpoint` and `jwt_request_header`.
- `jwt_token_attribute` (String) Describe in which attribute is the token in the HTTP Response from the IdP to get the token.
- `jwt_token_endpoint` (String) IdP Token endpoint. Use this parameter if authenticating with a jwt auth token. You should also set `jwt_request_header` and `jwt_request_payload`.

7 changes: 2 additions & 5 deletions docs/resources/model.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ By using `litellm_model`, you can seamlessly incorporate AI capabilities into yo
maintaining consistency and version control through Terraform's declarative configurations.

## Example Usage

```terraform
resource "litellm_model" "example" {
model_name = "example-model"
Expand All @@ -41,7 +40,6 @@ resource "litellm_model" "example" {
}
}
```

<!-- schema generated by tfplugindocs -->
## Schema

Expand All @@ -58,11 +56,10 @@ resource "litellm_model" "example" {

- `id` (String) The ID of the model.

## Import

Import is supported using the following syntax:
## Import

```shell
#!/bin/sh
terraform import litellm_model.example_model existing-model-name
```
```
23 changes: 23 additions & 0 deletions examples/provider/provider_jwt.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
terraform {
required_providers {
litellm = {
source = "registry.terraform.io/gzamboni/litellm"
version = "0.2.0"
}
}
}

provider "litellm" {
api_base_url = "https://your-litellm-instance.com" # or omit to use LITELLM_API_BASE_URL

jwt_token_endpoint = "https://my-identity-provider/token" # or omit to use LITELLM_JWT_TOKEN_ENDPOINT
jwt_request_header = {
"Content-Type": "application/json" # Only application/json and application/x-www-form-urlencoded are supported for now
}
jwt_request_payload = {
client_id = "my-idp-client-id"
client_secret = "my-idp-client-secret"
scope = "my-litellm-admin-scope"
grant_type = "client_credentials"
}
}
32 changes: 15 additions & 17 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,52 @@ module github.com/gzamboni/terraform-provider-litellm
go 1.23.1

require (
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0
github.com/jarcoal/httpmock v1.3.1
github.com/stretchr/testify v1.9.0
)

require (
github.com/agext/levenshtein v1.2.3 // indirect
github.com/agext/levenshtein v1.2.2 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
github.com/hashicorp/go-hclog v1.6.3 // indirect
github.com/hashicorp/go-plugin v1.6.1 // indirect
github.com/hashicorp/go-plugin v1.6.2 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
github.com/hashicorp/hcl/v2 v2.22.0 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-plugin-go v0.24.0 // indirect
github.com/hashicorp/terraform-plugin-go v0.25.0 // indirect
github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect
github.com/hashicorp/terraform-registry-address v0.2.3 // indirect
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/oklog/run v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/zclconf/go-cty v1.15.0 // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/text v0.18.0 // indirect
golang.org/x/tools v0.25.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.19.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
google.golang.org/grpc v1.66.2 // indirect
google.golang.org/protobuf v1.34.2 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/grpc v1.67.1 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading