Terraform for Agentic AI Infrastructure: Deploy Multi-Agent Systems on AWS
Deploy agentic AI and multi-agent systems with Terraform on AWS. Provision SQS queues, Lambda functions, Step Functions orchestration
DevOps
Provision AI-native developer platforms with Terraform: sandboxes, CI/CD runners, model-serving environments, secrets, VPCs, and preview environments.
AI-native development platforms are one of the strongest 2026 trends — engineering organizations are moving from "AI-assisted" to "AI-first" toolchains, where code, tests, infrastructure, and review are all generated and validated by AI agents inside opinionated developer platforms. Terraform is the control plane that makes those platforms repeatable.
This guide shows how to provision the foundation of an AI-native developer platform on AWS with Terraform.
| Capability | AWS service | Terraform module |
|---|---|---|
| Developer sandboxes | EKS namespaces, IAM Roles for Service Accounts | aws_eks_cluster, kubernetes_namespace |
| CI/CD runners | EC2 Spot, ECS, GitHub Actions runners on EKS | aws_launch_template, helm_release |
| Model serving | SageMaker endpoints, Bedrock, EKS + KServe | aws_sagemaker_endpoint |
| Secrets | AWS Secrets Manager + IRSA | aws_secretsmanager_secret |
| Artifact registry | ECR, S3, CodeArtifact | aws_ecr_repository |
| Preview envs | Per-PR namespaces + Route53 wildcards | kubernetes_namespace, aws_route53_record |
module "platform_cluster" {
source = "terraform-aws-modules/eks/aws"
version = "~> 20.0"
cluster_name = "ai-platform"
cluster_version = "1.31"
vpc_id = module.vpc.vpc_id
subnet_ids = module.vpc.private_subnets
enable_irsa = true
eks_managed_node_groups = {
general = {
instance_types = ["m7i.2xlarge"]
min_size = 3
desired_size = 6
max_size = 24
}
gpu = {
instance_types = ["g5.2xlarge"]
min_size = 0
desired_size = 0
max_size = 8
labels = { workload = "gpu" }
taints = [{
key = "nvidia.com/gpu"
value = "true"
effect = "NO_SCHEDULE"
}]
}
}
}variable "developers" {
type = set(string)
}
resource "kubernetes_namespace" "sandbox" {
for_each = var.developers
metadata {
name = "sandbox-${each.key}"
labels = {
"platform.io/owner" = each.key
"platform.io/type" = "sandbox"
}
}
}
resource "kubernetes_resource_quota" "sandbox" {
for_each = var.developers
metadata {
name = "quota"
namespace = kubernetes_namespace.sandbox[each.key].metadata[0].name
}
spec {
hard = {
"requests.cpu" = "8"
"requests.memory" = "32Gi"
"requests.nvidia.com/gpu" = "1"
"limits.cpu" = "16"
"limits.memory" = "64Gi"
"pods" = "50"
}
}
}resource "aws_route53_zone" "preview" {
name = "preview.platform.example.com"
}
resource "aws_acm_certificate" "preview" {
domain_name = "preview.platform.example.com"
subject_alternative_names = ["*.preview.platform.example.com"]
validation_method = "DNS"
}A GitHub Actions workflow then runs terraform apply -var "pr_number=$PR" to spin up a namespace and Route53 record per pull request, and terraform destroy on close.
data "aws_iam_policy_document" "secrets_read" {
statement {
actions = ["secretsmanager:GetSecretValue"]
resources = [aws_secretsmanager_secret.openai_key.arn]
}
}
module "secrets_irsa" {
source = "terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks"
version = "~> 5.0"
role_name = "platform-secrets"
role_policy_arns = {
read = aws_iam_policy.secrets_read.arn
}
oidc_providers = {
main = {
provider_arn = module.platform_cluster.oidc_provider_arn
namespace_service_accounts = ["platform:secrets-reader"]
}
}
}owner, cost-center, and pr-number so finance can attribute spend.terraform destroy.Deploy agentic AI and multi-agent systems with Terraform on AWS. Provision SQS queues, Lambda functions, Step Functions orchestration
Optimize AI infrastructure costs with Terraform. Deploy right-sized inference endpoints, auto-scale based on token throughput, use Spot instances
Secure AI workloads with Terraform. Deploy Bedrock guardrails, model access IAM policies, prompt injection detection
Provision AI supercomputing infrastructure with Terraform. Deploy GPU clusters with p5.48xlarge, EFA networking, FSx Lustre storage