Skip to main content

AWS Infrastructure Deployment

This section guides you through deploying the AWS infrastructure foundation required for AI/Run CodeMie using Terraform automation.

Existing Infrastructure

If you already have a provisioned EKS cluster with all required AWS services (networking, storage, databases, etc.), you can skip this section and proceed directly to Components Deployment.

Overview

The Terraform deployment is organized into three distinct phases, each with its own set of resources and purpose:

  1. IAM Deployer Role - Privileged role for executing Terraform operations
  2. Terraform State Backend - Infrastructure for storing Terraform state files securely
  3. Core Platform Infrastructure - Main AWS resources for running AI/Run CodeMie
Important

The deployment uses a registered domain name in AWS Route 53, which allows Terraform to automatically create SSL/TLS certificates via AWS Certificate Manager for the Application Load Balancer (ALB) and Network Load Balancer (NLB).

Phase 1: IAM Deployer Role

The IAM deployer role is created first to provide necessary permissions for all subsequent infrastructure operations.

ResourcePurpose
IAM RoleDeployer role with permissions to create and manage AWS resources
IAM PoliciesGranular permission policies for EKS, networking, storage, databases
Trust PoliciesTrust relationships allowing specific principals to assume the role
IAM Role Purpose

The IAM deployer role enables:

  • Least Privilege: Scoped permissions for infrastructure operations only
  • Separation of Duties: Dedicated role for infrastructure deployment
  • Auditability: CloudTrail logging of all actions performed by the role
  • Consistency: Same permissions across different deployment environments

Phase 2: Terraform State Backend

The state backend is deployed to provide secure, centralized storage for Terraform state files.

ResourcePurpose
S3 BucketStorage for Terraform state files with versioning enabled
DynamoDB TableState locking mechanism to prevent concurrent modifications
Bucket PoliciesAccess control policies for state file security
EncryptionServer-side encryption for state files at rest
State Backend Purpose

The Terraform state backend enables:

  • Team Collaboration: Multiple engineers can work on infrastructure simultaneously
  • State Locking: Prevents concurrent modifications that could corrupt state
  • Versioning: Maintains history of infrastructure changes
  • Security: State files contain sensitive data and require secure storage

Phase 3: Core Platform Infrastructure

The core platform infrastructure provisions all AWS resources needed to run AI/Run CodeMie. This is the main deployment phase and following AWS resources will be deployed:

Compute & Orchestration

ResourcePurpose
EKS ClusterManaged Kubernetes cluster for running AI/Run CodeMie workloads
Managed Node GroupsAuto-scaling node groups for application workloads
Launch TemplatesEC2 instance configurations for node groups

Networking

ResourcePurpose
VPCIsolated virtual network for AI/Run CodeMie resources
Public SubnetsSubnets for load balancers and NAT gateways
Private SubnetsSubnets for EKS nodes and pods (application workloads)
Database SubnetsIsolated subnets for RDS PostgreSQL instances
Internet GatewayEnables internet connectivity for public subnets
NAT GatewayProvides consistent outbound public IP for private subnet resources
Route TablesControls routing between subnets and internet
Application Load BalancerDistributes incoming HTTPS traffic to application services
Network Load BalancerHandles TCP traffic for NATS messaging system
Route 53 DNS RecordsAutomated DNS record creation for CodeMie services
Network Security GroupsFirewall rules controlling traffic flow

Data & Storage

ResourcePurpose
RDS PostgreSQLManaged database service for CodeMie application data
RDS Subnet GroupDatabase subnet group for multi-AZ deployment
S3 BucketPersistent storage for CodeMie application data and artifacts
EBS VolumesBlock storage for Kubernetes persistent volumes

Security & Identity

ResourcePurpose
AWS Certificate ManagerAutomated SSL/TLS certificates for ALB and NLB
KMS KeyEncryption key for S3 bucket and other encrypted resources
IAM Roles for EKSService roles for EKS cluster and node groups
IAM Roles for WorkloadsIRSA (IAM Roles for Service Accounts) for pod-level permissions
Security GroupsNetwork access control lists for EKS, RDS, load balancers
Secrets ManagerOptional secret storage for database credentials

Optional Features

ResourcePurpose
Internal ALBPrivate load balancer for internal-only access
Private DNS Hosted ZonePrivate Route 53 zone for internal service discovery
VPC EndpointsPrivate connectivity to AWS services (S3, ECR, etc.)

Next Steps

Proceed to the next step to deploy the infrastructure:

Deployment Method Selection
  • Scripted Deployment: Handles prerequisites, validation, and orchestration automatically (recommended for most users)
  • Manual Deployment: Provides full control over Terraform operations for advanced customization