---
title: "AWS Deployment"
description: "Deploy TraceRTM on Amazon Web Services"
keywords: [aws, amazon, ecs, rds, deployment]
---

# AWS Deployment

Deploy TraceRTM on Amazon Web Services (AWS).

## Architecture

### Recommended Setup

```
Application Load Balancer
    ↓
ECS Fargate (API)
    ↓
RDS PostgreSQL (Database)
    ↓
ElastiCache Redis (Cache)
```

## ECS Deployment

### Task Definition

```json
{
  "family": "tracertm-api",
  "networkMode": "awsvpc",
  "requiresCompatibilities": ["FARGATE"],
  "cpu": "1024",
  "memory": "2048",
  "containerDefinitions": [{
    "name": "api",
    "image": "tracertm:2.4.0",
    "portMappings": [{
      "containerPort": 8000,
      "protocol": "tcp"
    }],
    "environment": [
      {"name": "DATABASE_URL", "value": "..."},
      {"name": "REDIS_URL", "value": "..."}
    ],
    "logConfiguration": {
      "logDriver": "awslogs",
      "options": {
        "awslogs-group": "/ecs/tracertm-api",
        "awslogs-region": "us-east-1",
        "awslogs-stream-prefix": "ecs"
      }
    }
  }]
}
```

### ECS Service

```bash
# Create ECS service
aws ecs create-service \
  --cluster tracertm-cluster \
  --service-name tracertm-api \
  --task-definition tracertm-api \
  --desired-count 3 \
  --launch-type FARGATE \
  --network-configuration "awsvpcConfiguration={subnets=[subnet-123],securityGroups=[sg-123],assignPublicIp=ENABLED}"
```

## RDS Database

### Create RDS Instance

```bash
aws rds create-db-instance \
  --db-instance-identifier tracertm-db \
  --db-instance-class db.t3.medium \
  --engine postgres \
  --engine-version 14.9 \
  --master-username postgres \
  --master-user-password YourPassword123 \
  --allocated-storage 100 \
  --storage-type gp3 \
  --vpc-security-group-ids sg-123 \
  --db-subnet-group-name tracertm-db-subnet-group \
  --backup-retention-period 7 \
  --multi-az
```

### Connection String

```bash
DATABASE_URL=postgresql://postgres:password@tracertm-db.region.rds.amazonaws.com:5432/tracertm
```

## ElastiCache Redis

### Create Redis Cluster

```bash
aws elasticache create-cache-cluster \
  --cache-cluster-id tracertm-redis \
  --cache-node-type cache.t3.micro \
  --engine redis \
  --num-cache-nodes 1 \
  --vpc-security-group-ids sg-123
```

## Application Load Balancer

### Create ALB

```bash
aws elbv2 create-load-balancer \
  --name tracertm-alb \
  --subnets subnet-123 subnet-456 \
  --security-groups sg-123
```

### Target Group

```bash
aws elbv2 create-target-group \
  --name tracertm-targets \
  --protocol HTTP \
  --port 8000 \
  --vpc-id vpc-123 \
  --health-check-path /health
```

## Environment Variables

### Secrets Manager

```bash
# Store secrets
aws secretsmanager create-secret \
  --name tracertm/secrets \
  --secret-string '{"database_url":"...","secret_key":"..."}'
```

### Use in ECS

```json
{
  "secrets": [
    {
      "name": "DATABASE_URL",
      "valueFrom": "arn:aws:secretsmanager:region:account:secret:tracertm/secrets:database_url::"
    }
  ]
}
```

## Monitoring

### CloudWatch

- **Logs**: ECS logs to CloudWatch Logs
- **Metrics**: ECS metrics, RDS metrics
- **Alarms**: Set up alarms for errors, latency

## Related Documentation

- [Cloud Platforms](./03-cloud-platforms) - Cloud overview
- [Docker Deployment](./01-docker-deployment) - Docker setup
