Terraform
This guide explains how to use the CloudPilot AI Terraform Provider to manage Amazon EKS clusters with automated cost optimization. The provider enables seamless integration of CloudPilot AI’s optimization components into your infrastructure-as-code workflow.
Overview
The CloudPilot AI Terraform Provider allows you to:
- Automate the installation of agents and rebalancing components
- Autoscale EKS cluster nodes through CloudPilot AI integration
- Configure node settings for autoscaling environments
- Optimize workload costs through rebalancing and spot instance management
Prerequisites
Before using the Terraform Provider, ensure you have:
- Terraform - Version 1.0 or later
- AWS CLI - Configured with credentials that have EKS cluster management permissions
- kubectl - For cluster operations and component management
- CloudPilot AI API Key - See Get API Keys for setup instructions
If you don’t have an EKS cluster yet, refer to the example cluster setup .
Example Configurations
The following examples demonstrate different use cases for the Terraform Provider. Each example includes a complete main.tf file and detailed README.
| Example | Description | Use Case |
|---|---|---|
0_details | Full-featured configuration with all options | Production setup with workload templates, nodeclasses, and complete configuration |
1_read-only_access | Agent-only installation | Testing or monitoring without making optimization changes |
2_basic_rebalance | Basic rebalance enabled | Simple cost optimization with workload rebalancing |
3_nodeclass_nodepool_rebalance | Custom nodeclass and nodepool | Advanced node management with custom configurations |
Quick Start
-
Install and configure prerequisites:
# Configure AWS credentials aws configure # Verify access aws sts get-caller-identity -
Create a Terraform configuration file:
terraform { required_providers { cloudpilotai = { source = "cloudpilot-ai/cloudpilotai" } } } provider "cloudpilotai" { # ⚠️ Required api_key = "sk-xxx" } resource "cloudpilotai_eks_cluster" "example" { # ⚠️ Required cluster_name = "my-eks-cluster" # ⚠️ Required region = "us-west-2" # ⚠️ Required restore_node_number = 2 } -
Initialize and apply:
terraform init terraform plan terraform apply
Refer to the example configurations above for complete working examples.
Additional Resources
- Terraform Provider Registry - Full provider documentation
- GitHub Repository - Source code and examples
- GitHub Issues - Report issues or request features
- Slack Community - Get help from the community