The kubiya_agent
resource allows you to create and manage AI agents in the Kubiya platform. Agents are intelligent assistants that can perform various tasks, integrate with external systems, and execute workflows.
Agents are the core building blocks of your Kubiya automation. They can be configured with specific tools, integrations, and access controls to match your organization’s needs.
Prerequisites
Before using this resource, ensure you have:
A Kubiya account with API access
An API key (generated from Kubiya dashboard under Admin → Kubiya API Keys)
At least one runner configured (or use “kubiya-hosted” for cloud execution)
Quick Start
Basic Agent
Agent with Access Control
DevOps Agent
resource "kubiya_agent" "basic_agent" {
name = "my-basic-agent"
runner = "kubiya-hosted"
description = "A basic AI assistant for general tasks"
instructions = "You are a helpful AI assistant. Provide clear and concise responses to user queries."
}
Configuration Examples
Task-Based Agent Agent with Conversation Starters Custom Docker Image Configure an agent with predefined tasks that users can execute: resource "kubiya_agent" "ops_agent" {
name = "operations-agent"
runner = "kubiya-hosted"
description = "Operations management agent"
instructions = "You are an operations agent that helps with infrastructure management tasks."
tasks = [
{
name = "check-cluster-health"
prompt = "Check the health status of all Kubernetes clusters and report any issues"
description = "Performs comprehensive health checks on K8s clusters"
},
{
name = "scale-deployment"
prompt = "Scale the specified deployment to the requested number of replicas"
description = "Scales Kubernetes deployments"
},
{
name = "backup-database"
prompt = "Create a backup of the specified database and store it in S3"
description = "Performs database backup operations"
}
]
integrations = [ "kubernetes" , "aws" ]
}
Advanced Configurations
Agent with Workflow Execution
Configure an agent that can execute complex, multi-step workflows: resource "kubiya_source" "deployment_workflow" {
name = "deployment-workflows"
workflows = jsonencode ([
{
name = "blue-green-deployment"
description = "Perform blue-green deployment"
steps = [
{
name = "prepare-green-env"
description = "Prepare green environment"
executor = {
type = "command"
config = {
command = "kubectl apply -f green-deployment.yaml"
}
}
},
{
name = "health-check"
description = "Check green environment health"
depends = [ "prepare-green-env" ]
executor = {
type = "command"
config = {
command = "kubectl wait --for=condition=ready pod -l version=green --timeout=300s"
}
}
},
{
name = "switch-traffic"
description = "Switch traffic to green environment"
depends = [ "health-check" ]
executor = {
type = "command"
config = {
command = "kubectl patch service myapp -p '{ \" spec \" :{ \" selector \" :{ \" version \" : \" green \" }}}'"
}
}
}
]
}
])
runner = "kubiya-hosted"
}
resource "kubiya_agent" "deployment_agent" {
name = "deployment-automation"
runner = "kubiya-hosted"
description = "Automated deployment agent"
instructions = <<- EOT
You are a deployment automation agent. You can:
1. Execute blue-green deployments
2. Perform rollbacks if needed
3. Monitor deployment status
Always verify the target environment before deploying.
EOT
sources = [ kubiya_source . deployment_workflow . id ]
integrations = [ "kubernetes" , "slack_integration" ]
}
Arguments Reference
Required Arguments
The name of the agent. Must be unique within your organization.
The runner to use for agent execution. Use “kubiya-hosted” for cloud execution or specify your own runner name.
A detailed description of the agent’s purpose and capabilities.
System instructions that define the agent’s behavior and capabilities. These instructions guide how the agent responds to user queries and executes tasks.
Optional Arguments
The LLM model to use for the agent. Available options:
gpt-4o
- GPT-4 Optimized (recommended)
gpt-4
- GPT-4
gpt-3.5-turbo
- GPT-3.5 Turbo
azure/gpt-4
- Azure OpenAI GPT-4
image
string
default: "ghcr.io/kubiyabot/kubiya-agent:stable"
Docker image for the agent runtime environment. Use custom images for specialized functionality.
Enable debug mode for detailed logging and troubleshooting.
List of integration names the agent can access. Must match exactly with configured integrations in your Kubiya account.
List of user emails who can access the agent. If not specified, the agent is accessible to all organization members.
List of group names that can access the agent. Use for team-based access control.
List of source IDs for knowledge bases and workflows that the agent can utilize.
List of tool source URLs or IDs. These provide the agent with additional capabilities and tools.
List of secret names the agent can access for secure operations.
Map of environment variables available to the agent during execution.
List of predefined tasks that users can execute. Each task object contains: Task identifier used for execution.
The prompt that will be executed when the task is triggered.
Human-readable description of what the task does.
List of conversation starters for improved user experience. Each starter object contains: Display name for the conversation starter.
Command that will be executed when the starter is selected.
List of reference links that provide additional context or documentation for the agent.
Attributes Reference
In addition to all arguments above, the following attributes are exported:
The unique identifier of the agent.
The email of the user who created the agent.
The timestamp when the agent was created.
Import
Agents can be imported using their ID:
Import Command
Import Block
terraform import kubiya_agent.example < agent-i d >
Best Practices
Security
Store sensitive information in secrets, not in environment variables
Use specific access controls with users and groups
Regularly audit agent permissions and access patterns
Performance
Choose the appropriate model for your use case (balance cost vs capability)
Use custom Docker images for specialized environments
Enable debug mode only when troubleshooting
Maintenance
Use descriptive names that indicate the agent’s purpose
Include comprehensive instructions to ensure consistent behavior
Store Terraform configurations in version control
Test agents in non-production runners first
User Experience
Provide clear conversation starters for common tasks
Use groups for team-based access rather than individual users
Include helpful links and documentation references
Compatibility
Requirements:
Kubiya Terraform Provider version >= 1.0.0
Terraform >= 1.0
Some features may require specific Kubiya platform tier (Enterprise features)
Important Considerations:
Custom Docker images must be accessible from the runner environment
Integration names must match exactly with configured integrations in your Kubiya account
Debug mode should not be used in production environments
Troubleshooting
Check if the runner is active and accessible
Verify that all required integrations are properly configured
Enable debug mode to get detailed logs
Ensure the agent has proper access permissions
Integration Access Issues
Verify integration names match exactly with your Kubiya account configuration
Check that the agent’s groups/users have access to the integrations
Ensure integrations are properly authenticated and active
Custom Docker Image Issues
Ensure the image is accessible from the runner environment
Check that required dependencies are installed in the image
Verify environment variables are properly configured
Test the image independently before using with the agent