The Portkey Terraform provider enables you to manage Portkey resources through the Admin API using infrastructure as code.
Features
- Workspaces: Create, update, and manage workspaces for organizing teams and projects
- Workspace members: Assign users to workspaces with specific roles
- User invitations: Send invitations to users with organization and workspace access
- Users: Query and manage existing users in your organization
Requirements
- Terraform >= 1.0
- A Portkey account with Admin API access
Installation
Add the provider to your Terraform configuration:
terraform {
required_providers {
portkey = {
source = "portkey-ai/portkey"
version = "~> 0.1"
}
}
}
Authentication
The provider requires a Portkey Admin API key. Set it via environment variable (recommended):
export PORTKEY_API_KEY="your-admin-api-key"
Or in the provider configuration:
provider "portkey" {
api_key = "your-admin-api-key"
}
Admin API keys provide broad access to your organization. Store them securely and never commit them to version control.
Quick start
terraform {
required_providers {
portkey = {
source = "portkey-ai/portkey"
}
}
}
provider "portkey" {
# API key read from PORTKEY_API_KEY environment variable
}
# Create a workspace
resource "portkey_workspace" "production" {
name = "Production"
description = "Production environment workspace"
}
# Invite a user with workspace access
resource "portkey_user_invite" "engineer" {
email = "engineer@example.com"
role = "member"
workspaces = [
{
id = portkey_workspace.production.id
role = "admin"
}
]
scopes = [
"logs.view",
"configs.read",
"virtual_keys.read"
]
}
Self-hosted deployments
For self-hosted Portkey deployments, configure the base URL:
provider "portkey" {
api_key = var.portkey_api_key
base_url = "https://your-portkey-instance.com/v1"
}
Resources and data sources
For complete documentation on available resources, data sources, and their arguments, see the Terraform provider repository.
| Resource | Description |
|---|
portkey_workspace | Manage workspaces |
portkey_workspace_member | Manage workspace membership |
portkey_user_invite | Send user invitations |
| Data Source | Description |
|---|
portkey_workspace | Fetch a single workspace |
portkey_workspaces | Fetch all workspaces |
portkey_user | Fetch a single user |
portkey_users | Fetch all users |
Support