Terraform Data Sources
Data sources allow you to query existing Kubiya Control Plane resources and use their attributes in your Terraform configurations.Why Use Data Sources?
- Reference Existing Resources: Look up resources created outside Terraform
- Cross-Stack References: Reference resources from other Terraform configurations
- Dynamic Configuration: Build configurations based on existing infrastructure
- Read-Only Access: Query resources without managing them
Available Data Sources
All managed resources have corresponding data sources:controlplane_environment- Look up a single environment by IDcontrolplane_project- Look up a single project by IDcontrolplane_team- Look up a single team by IDcontrolplane_agent- Look up a single agent by IDcontrolplane_skill- Look up a single skill by IDcontrolplane_policy- Look up a single policy by IDcontrolplane_job- Look up a single job by IDcontrolplane_jobs- List all jobscontrolplane_worker_queue- Look up a single worker queue by IDcontrolplane_worker_queues- List all worker queues in an environment
Data Source Arguments
All data sources require the resourceid:
Data Source Examples
controlplane_environment
Look up an existing environment by ID:id- Environment IDname- Environment namedisplay_name- Display namedescription- Environment descriptiontags- List of tagsconfiguration- Environment configuration (JSON)execution_environment- Execution settings (JSON)created_at- Creation timestampupdated_at- Last update timestamp
controlplane_project
Look up an existing project:id- Project IDname- Project namekey- Project keydescription- Project descriptiongoals- Project goalsvisibility- Visibility settingmetadata- Project metadata (JSON)created_at- Creation timestampupdated_at- Last update timestamp
controlplane_team
Look up an existing team:id- Team IDname- Team namedescription- Team descriptionruntime- Runtime type (default or claude_code)configuration- Team configuration (JSON)capabilities- List of capabilitiescreated_at- Creation timestampupdated_at- Last update timestamp
controlplane_agent
Look up an existing agent:id- Agent IDname- Agent namedescription- Agent descriptionmodel_id- LLM modelruntime- Runtime typeteam_id- Team IDllm_config- LLM configuration (JSON)configuration- Agent configuration (JSON)capabilities- List of capabilitiesstatus- Agent statuscreated_at- Creation timestampupdated_at- Last update timestamp
controlplane_skill
Look up an existing skill:id- Skill IDname- Skill namedescription- Skill descriptiontype- Skill type (shell, file_system, docker, custom)enabled- Whether skill is enabledconfiguration- Skill configuration (JSON)created_at- Creation timestampupdated_at- Last update timestamp
controlplane_policy
Look up an existing policy:id- Policy IDname- Policy namedescription- Policy descriptionenabled- Whether policy is enabledpolicy_content- OPA Rego policy contenttags- List of tagscreated_at- Creation timestampupdated_at- Last update timestamp
controlplane_job
Look up an existing job:id- Job IDname- Job namedescription- Job descriptionenabled- Whether job is enabledstatus- Job statustrigger_type- Trigger type (cron, webhook, manual)cron_schedule- Cron expressioncron_timezone- Timezone for cron schedulewebhook_url- Full webhook URL (for webhook triggers)planning_mode- Planning modeentity_type- Entity type (agent, team, workflow)entity_id- Entity IDprompt_template- Prompt templatesystem_prompt- System promptexecutor_type- Executor routing typeworker_queue_name- Worker queue nameenvironment_name- Environment namecreated_at- Creation timestampupdated_at- Last update timestamp
controlplane_jobs
List all jobs in the control plane:jobs- List of all jobs, each with the same attributes ascontrolplane_jobdata source
controlplane_worker_queue
Look up an existing worker queue:id- Worker Queue IDenvironment_id- Environment IDname- Worker queue namedisplay_name- Display namedescription- Queue descriptionstatus- Worker queue statusmax_workers- Maximum workers allowedheartbeat_interval- Seconds between heartbeatstags- List of tagssettings- Additional settings as mapcreated_at- Creation timestampupdated_at- Last update timestampactive_workers- Number of active workerstask_queue_name- Task queue name for Temporal
controlplane_worker_queues
List all worker queues in an environment:environment_id- Environment ID (input)queues- List of worker queues, each with the same attributes ascontrolplane_worker_queuedata source
Common Use Cases
Use Case 1: Cross-Stack References
Reference resources from a different Terraform state:Use Case 2: Dynamic Agent Creation
Create agents based on existing team configuration:Use Case 3: Configuration Validation
Validate that resources exist before creating dependencies:Use Case 4: Import Existing Resources
Find existing resources to import into Terraform:Use Case 5: Clone Configurations
Clone existing resources with modifications:Working with JSON Attributes
Many data source attributes return JSON strings. Usejsondecode() to parse them:
Best Practices
1. Use Variables for IDs
Don’t hardcode resource IDs:2. Validate Data Source Results
Check that required data exists:3. Document Data Source Usage
Add clear comments:4. Use Outputs for Debugging
Output data source attributes for troubleshooting:Error Handling
If a data source can’t find a resource:- Verify the resource ID is correct
- Check that the resource exists in your control plane
- Verify your API key has read permissions
- Ensure you’re connected to the correct control plane (hosted vs self-hosted)
Next Steps
- Resources Documentation - Create and manage resources
- Modules - Use pre-built modules for common patterns
- Examples - Complete end-to-end examples
- Provider Configuration - Configuration options