Infrastructure
This provisions the cloud infrastructure Confident AI runs on: an EKS cluster, an RDS PostgreSQL database, S3 buckets, and the keyless IAM wiring (EKS Pod Identity). When it finishes you will have a running cluster and a set of outputs to feed into the Helm chart on the next page.
The region comes from your AWS provider and profile, there is no region variable. Set the region and two availability zones once:
Create the network (optional)
Skip this if you already have a VPC with two private subnets in different AZs that reach the internet through a NAT gateway. Use your existing IDs in the next step.
This builds a VPC with two public and two private subnets across two availability zones, plus a NAT gateway. EKS and RDS run in the private subnets; the public subnets carry the NAT gateway and any internet-facing load balancer. Run the blocks in order, each one feeds IDs into the next.
Create the VPC and turn on DNS so the cluster and database can resolve private hostnames:
Attach an internet gateway. The public subnets route to it for internet access:
Create two public and two private subnets, one of each per availability zone:
ClickHouse runs cleanly on the IPv4-only EKS cluster this module builds: the chart pins the operator’s pods to listen on IPv4 (0.0.0.0), so there is no address-family error and no dual-stack setup is required. A dual-stack VPC alone would not change this, the nodes stay IPv4-only unless the cluster itself is created dual-stack.
Tag the subnets so a load balancer controller can discover them later:
Create a NAT gateway in the first public subnet. The private nodes reach the internet through it for outbound pulls, with no inbound exposure:
Route the public subnets to the internet gateway:
Route the private subnets through the NAT gateway:
Print the VPC and private subnet IDs to paste into the Terraform config:
Mirror the code sandbox image (required)
Code-based and transformer metrics run in a sandboxed Lambda, which runs the confident-code-sandbox-aws image. Lambda only runs container images from an ECR in the same account, so mirror the public image into your own ECR.
Create the ECR repository and log Docker in to it:
Pull the public image and push it to your ECR. The last line prints the image URI for the Terraform config:
Write the Terraform config
Create a main.tf that references the published module, then fill in the values from the previous two steps. What each variable does:
- Network:
confident_vpc_idandconfident_private_subnet_idscome from the network step (or use your own VPC). - Naming:
confident_environmentandconfident_environment_codestamp theprodnaming convention onto every resource. - Access:
confident_public_eksexposes the cluster API to your machine; set itfalsefor a private-only endpoint. - Durability:
confident_rds_deletion_protectionguards the database against accidental deletion. - Managed services:
confident_create_secrets_managerandconfident_managed_redis_enabledturn on the recommended secret store and Redis, andconfident_database_ingress_cidrslets the nodes reach Redis (use your VPC CIDR). - Code executor:
confident_code_executor_lambda_image_uriis the ECR image URI printed by the mirror step.
Prefer to work inside the repo? Clone terraform-aws-confident-ai and put the same variables in a terraform.tfvars file instead of a module block.
Configure remote state (optional)
Skip this to use local state. For a team or a real environment, keep state in an S3 bucket.
Connect to the cluster
EKS ships no default storage class, and ClickHouse and Redis need disks. Create a gp3 default once:
Read the outputs
The Helm chart on the next page needs these values. terraform output helm_values prints a ready-to-paste snippet, or read them individually. The comment on each line is the Helm value it feeds:
Because the app uses EKS Pod Identity, its ServiceAccount needs no annotation, Terraform already linked the IAM role to it.
Managed secrets and Redis (recommended)
The module block above provisions both. The Deploy page installs the External Secrets Operator and wires them into the chart:
- Secrets Manager + External Secrets Operator (
confident_create_secrets_manager = true): Terraform creates an empty secret and grants ESO read access through Pod Identity. - ElastiCache for Redis (
confident_managed_redis_enabled = true): managed Redis instead of the in-cluster one.confident_database_ingress_cidrsopens port 6379 to your VPC so the nodes can reach it.terraform output -raw redis_urlgives the value forredis.externalUrl.
Prefer a simpler footprint? Set both to false to hold secrets in a Kubernetes Secret and run Redis in the cluster. See Simpler option on the Deploy page.
Inputs reference
The variables you are most likely to set. For the complete, always-current list, see the module inputs on the Terraform Registry.
Required
Commonly set (optional, with production defaults)
The region comes from your AWS provider, there is no region variable.