Skip to Content

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.

ExampleDescriptionUse Case
0_detailsFull-featured configuration with all optionsProduction setup with workload templates, nodeclasses, and complete configuration
1_read-only_accessAgent-only installationTesting or monitoring without making optimization changes
2_basic_rebalanceBasic rebalance enabledSimple cost optimization with workload rebalancing
3_nodeclass_nodepool_rebalanceCustom nodeclass and nodepoolAdvanced node management with custom configurations

Quick Start

  1. Install and configure prerequisites:

    # Configure AWS credentials aws configure # Verify access aws sts get-caller-identity
  2. 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 }
  3. Initialize and apply:

    terraform init terraform plan terraform apply

Refer to the example configurations above for complete working examples.

Additional Resources

Last updated on