Getting Started with Kubiya Terraform Provider
This guide will walk you through setting up and using the Kubiya Control Plane Terraform Provider to manage your AI agent infrastructure as code.
Prerequisites
Before you begin, ensure you have:
- Terraform >= 1.0 installed (Download)
- Kubiya Control Plane Access (hosted or self-hosted)
- API Key from your Kubiya Control Plane
Step 1: Obtain Your API Key
For Hosted Control Plane (SaaS)
- Navigate to https://compose.kubiya.ai
- Go to Settings → API Keys
- Click Generate New API Key
- Copy and securely store your API key
For Self-Hosted Control Plane
- Access your self-hosted control plane dashboard
- Navigate to Settings → API Keys
- Generate and copy your API key
- Note your control plane base URL (e.g.,
https://control-plane.your-company.com)
Set up your authentication credentials:
Hosted Control Plane
Self-Hosted Control Plane
For production environments, consider using a secrets management solution like HashiCorp Vault, AWS Secrets Manager, or Azure Key Vault instead of environment variables.
Step 3: Create Your First Configuration
Create a new directory for your Terraform configuration:
Create a file named main.tf:
Initialize your Terraform working directory:
Expected output:
Step 5: Plan Your Changes
Preview what Terraform will create:
Review the planned changes carefully. You should see:
- 1 environment to create
- 1 team to create
- 1 agent to create
Step 6: Apply Your Configuration
Create the resources:
Type yes when prompted to confirm.
Expected output:
Step 7: Verify Your Resources
Check the created resources:
You can also verify the resources in your Kubiya Control Plane dashboard.
Step 8: Make Changes
Update your configuration in main.tf. For example, change the agent description:
Apply the changes:
Using Data Sources
Look up existing resources using data sources. Create a file named data.tf:
Best Practices for Operators
1. Use Variables
Create variables.tf:
Create terraform.tfvars:
2. Use Remote State
Configure remote state storage in backend.tf:
3. Organize with Modules
Create reusable modules:
4. Use Workspaces
Manage multiple environments:
Cleanup
When you’re done experimenting, destroy the resources:
Type yes when prompted.
Be careful with terraform destroy in production environments. Consider using -target to destroy specific resources or implement lifecycle rules to prevent accidental deletion.
Troubleshooting
Authentication Errors
If you see authentication errors:
Provider Not Found
If Terraform can’t find the provider:
Resource Already Exists
If resources already exist:
Next Steps
Now that you have a basic configuration running:
- Configure Provider Options - Learn about advanced configuration
- Explore Resources - Detailed documentation for all resources
- Review Examples - End-to-end examples for operators
- Explore Modules - Use pre-built modules for common patterns
- Learn About Policies - Implement governance with OPA Rego
- Set Up Jobs - Automate workflows with scheduled jobs
Additional Resources