Guide · Deploy
Private LLM on AWS: a reference architecture
Run an open-weight model with vLLM on GPU instances inside your own AWS account, behind one load balancer, with weights in S3 and no long-lived keys. Covers path choice, instance sizing, Terraform, autoscaling, rollout and India regions.
- Step 1: Request in. Your apps and agents call one HTTPS endpoint with the OpenAI SDK. The load balancer in the public subnet is the only thing in the account that faces the internet.
- Step 2: TLS ends at the edge. The Application Load Balancer terminates TLS and forwards only to the gateway in the private subnet. Model servers have no public IP address at all.
- Step 3: The gateway checks the caller. Each team or agent gets its own key and quota. The gateway records who called what and how many tokens it used, then routes to the right model. It doesn't keep prompts unless you ask it to.
- Step 4: Inference on GPUs. vLLM runs on GPU instances in an Auto Scaling group across availability zones, batching requests and streaming tokens back. Scaling follows queue depth, not CPU, and can drop to a floor overnight.
- Step 5: Weights stay inside AWS. Instances pull a pinned, versioned copy of the weights from S3 through a gateway VPC endpoint, so there's no internet route. The bucket is KMS-encrypted and versioned, which makes rollback a pointer change.
- Step 6: No keys on disk. API keys live in Secrets Manager, storage is encrypted with KMS, and every service uses an IAM role instead of long-lived credentials.
- Step 7: Watch latency, errors and spend. CloudWatch collects metrics and logs and raises alarms on latency, error rate, GPU memory and spend. You see a problem before your users do.
This guide walks through the diagram above: an open-weight model served by vLLM on GPU instances in your own AWS account. Only the Application Load Balancer faces the internet. Weights, prompts and logs stay in your VPC.
Reference architecture diagrams tend to hide the decisions that matter, so this guide spends its words on those: which AWS service to run the model on, which GPU to rent, how to keep the gateway from becoming your weakest link, and how to scale, roll out and pay less. Prices and versions were checked on 23 November 2026.
Pick a path first
There are four reasonable ways to serve an open-weight model on AWS. The diagram shows the first.
| Path | What you operate | Scale to zero | India regions | Pick it when |
|---|---|---|---|---|
| EC2 GPU Auto Scaling group + ALB (the diagram) | AMI, launch template, vLLM container | Only on a schedule; cold start means boot plus weight load | Mumbai and Hyderabad | One to a few models, a small team, full control |
| Amazon EKS | Cluster, Karpenter, vLLM, a gateway | Possible, with a pod autoscaler that allows zero | Mumbai and Hyderabad | You already run Kubernetes or serve many models |
| SageMaker AI real-time endpoints | Model package and endpoint config | Only with inference components | Check instance availability per region | You want managed endpoints and AWS-maintained serving containers (check which engines your version includes) |
| Bedrock Custom Model Import | Uploaded weights only | Managed by AWS | Not available | Your architecture is supported and US or EU hosting is acceptable |
A few details that change the decision:
- EKS. AWS's own Guidance for Scalable Model Inference and Agentic AI on Amazon EKS uses Karpenter to provision GPU nodes, vLLM to serve, LiteLLM as the gateway, ELB plus AWS WAF at the edge, and Amazon Managed Prometheus and Grafana for metrics. It is a good template if you already operate Kubernetes. It is a lot of moving parts if you don't.
- SageMaker AI. Endpoints scale to zero only when you use inference components. Scale-out from zero is triggered by the
NoCapacityInvocationFailuresmetric, so requests that arrive at zero fail until capacity returns. Your clients need retries. - Bedrock Custom Model Import. It runs only in us-east-1, us-east-2, us-west-2 and eu-central-1, and only for listed architectures (Llama 2 and 3.x, Mistral, Mixtral, Qwen2 to Qwen3, GPT-OSS and a few others). Text weights must be under 200 GB in Hugging Face safetensors format. Llama 4, Gemma 4, Qwen3.5 and DeepSeek V4 were not on the list when we checked, so confirm before you plan around it.
Choose the instance
Size by memory first. Weights take roughly parameters times bytes per parameter (2 bytes at BF16, 1 at FP8), and the KV cache needs room on top. A 7 to 9B model in BF16 fits one 24 GB GPU; 27 to 35B models at FP8 fit a 48 GB L40S.
| Instance | GPU | us-east-1 | Mumbai (ap-south-1) | Hyderabad (ap-south-2) |
|---|---|---|---|---|
| g6.xlarge | 1× L4, 24 GB | $0.805 | $0.966 | Offered |
| g6e.xlarge | 1× L40S, 48 GB | $1.861 | $2.235 | Offered |
| g5.xlarge | 1× A10G, 24 GB | $1.006 | $1.208 | Not offered |
| p4d.24xlarge | 8× A100, 40 GB each | $21.958 | $26.344 | Not offered |
| p5.48xlarge | 8× H100, 80 GB each | $55.04 | $66.048 | Not offered |
On-demand Linux, USD per hour, before tax. Mumbai prices come from the AWS price list published 21 Nov 2026; us-east-1 prices from the AWS price list and Vantage. Hyderabad availability is from EC2 instance types by Region; check Hyderabad prices in the console.
Start with g6 (L4) and move to g6e (L40S) when the model or the context length outgrows 24 GB. Use g5 only if you need its capacity: the A10G is an Ampere part, and vLLM's FP8 W8A8 path needs Ada or Hopper. On Ampere, W8A8 can silently fall back to weight-only W8A16 unless you set VLLM_STRICT_QUANT_SCHEME=1. Keep p4d and p5 for 70B-class models at full precision and anything larger, and expect to need quota increases or reserved capacity for them.
Walk through the diagram
Steps 1 and 2: VPC, load balancer, TLS and WAF
Build one VPC with a public and a private subnet in at least two availability zones. The ALB goes in the public subnets. The gateway and the GPU instances go in the private subnets with no public IP.
Decide early whether the private subnets get a NAT gateway. Without one, nothing in them can reach the internet, which is what you want after the LiteLLM incident below. It means copying the vLLM image into a private Amazon ECR repository and adding VPC endpoints. ECR needs the ecr.api and ecr.dkr interface endpoints plus the S3 gateway endpoint, because image layers are stored in S3. Add interface endpoints for CloudWatch, CloudWatch Logs, Secrets Manager and KMS as you use them.
Terminate TLS on the ALB with an ACM certificate. Two defaults bite LLM traffic:
- The ALB idle timeout defaults to 60 seconds (valid range 1 to 4,000). Streaming responses keep the connection busy, but a long non-streaming generation can be cut off. Raise it.
- The AWS WAF core rule set includes
SizeRestrictions_BODY, which blocks request bodies over 8 KB. A RAG prompt passes that easily.
WAF and long prompts
Set SizeRestrictions_BODY to Count, or scope it away from your completion paths, before you go live. Also note that WAF body inspection on an ALB is fixed at the first 8 KB, so body rules never see most of a long prompt. Use WAF for rate-based rules and obvious abuse, and enforce keys and quotas in the gateway.
Step 3: the gateway, stated honestly
The gateway issues a key per team or agent, enforces quotas, meters tokens and routes by model name. LiteLLM is the common choice and is the gateway in AWS's EKS guidance. It also had a bad 2026:
- In March, a suspected compromise of its publishing pipeline; in April, CVE-2026-42208, a pre-auth SQL injection exploited about 36 hours after it appeared in the GitHub Advisory Database.
- On 21 October 2026, the official v1.107.0 release shipped credential-stealing malware on PyPI, Docker Hub and GHCR, including the
latest,main-latestandmain-stabletags: for about an hour and three quarters on PyPI and up to about two and a half hours on Docker Hub. LiteLLM's guidance: assume exfiltration on any host that installed it, rotate every key and role it could reach, and pin to 1.106.2 or another release published before the incident.
If you run LiteLLM, pin the image by digest, never deploy latest, and verify signatures. Releases from v1.111.0-dev.3 use keyless cosign:
cosign verify \
--certificate-identity https://github.com/BerriAI/project-releaser/.github/workflows/release.yml@refs/heads/main \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
ghcr.io/berriai/litellm:<release-tag>Then isolate it. Give it its own security group that can reach only the model servers and the VPC endpoints, its own IAM role that can read only its own secrets, and no route to the internet. The alternative is a small proxy you own: a key lookup, per-key token counters and routing on the model field is not much code, and it shrinks your supply chain.
The gateway reaches the GPU instances through an internal ALB (not drawn) with one target group per model version. That internal ALB is also what makes the canary rollout below possible.
Step 4: vLLM on GPU instances
Use the Deep Learning Base OSS Nvidia Driver GPU AMI (Ubuntu 24.04). It ships the NVIDIA driver, CUDA and the NVIDIA Container Toolkit, recent releases also include Docker CE and the CloudWatch agent (check the release notes for the AMI you pin), and it mounts local NVMe at /opt/dlami/nvme. Resolve the current AMI ID once, then pin it, so a new AMI never reaches production unreviewed:
aws ssm get-parameter --region ap-south-1 \
--name /aws/service/deeplearning/ami/x86_64/base-oss-nvidia-driver-gpu-ubuntu-24.04/latest/ami-id \
--query "Parameter.Value" --output textCopy vllm/vllm-openai:v0.34.0 into ECR and reference it by digest. vLLM v0.28 and later fix two 2026 CVEs (CVE-2026-27893, CVE-2026-90553) that let a malicious model repo run code even with --trust-remote-code off. Still load only safetensors from a revision you pinned and checksummed. The user data pulls weights from S3 and starts the container:
#!/bin/bash
set -euo pipefail
MODEL_DIR=/opt/dlami/nvme/model
aws s3 sync "${model_prefix}" "$MODEL_DIR" --region "${region}" --only-show-errors
aws ecr get-login-password --region "${region}" \
| docker login --username AWS --password-stdin "${registry}"
docker run -d --name vllm --restart unless-stopped \
--gpus all --ipc=host -p 8000:8000 \
-v "$MODEL_DIR":/model:ro \
"${image}" \
--model /model --served-model-name "${model_name}" \
--max-model-len 16384The ${...} values are filled by Terraform's templatefile. Leave --gpu-memory-utilization unset: the v0.34.0 release notes say most deployments should now remove it, because the extensible KV cache sizes itself. Set it only if another process shares the GPU. vLLM's --api-key flag only protects the OpenAI-style API routes such as /v1, other paths such as /invocations stay open, and its docs warn against relying on it alone, so security groups are the real control. The ALB target group health check should hit /health.
resource "aws_launch_template" "vllm" {
name_prefix = "vllm-"
image_id = var.dlami_id # pinned, resolved from the SSM parameter above
instance_type = "g6.xlarge"
vpc_security_group_ids = [aws_security_group.vllm.id]
iam_instance_profile {
name = aws_iam_instance_profile.vllm.name
}
metadata_options {
http_tokens = "required"
http_put_response_hop_limit = 1
}
user_data = base64encode(templatefile("${path.module}/vllm-user-data.sh", {
model_prefix = var.model_prefix # e.g. s3://bucket/model/revision/
region = var.region
registry = var.ecr_registry
image = var.vllm_image # ECR URI pinned by @sha256 digest
model_name = var.model_name
}))
}
resource "aws_autoscaling_group" "vllm_blue" {
name = "vllm-blue"
vpc_zone_identifier = var.private_subnet_ids
min_size = 1
max_size = 4
target_group_arns = [aws_lb_target_group.vllm_blue.arn]
health_check_type = "ELB"
health_check_grace_period = 900
default_instance_warmup = 900
launch_template {
id = aws_launch_template.vllm.id
version = aws_launch_template.vllm.latest_version
}
}IMDSv2 with a hop limit of 1 means the container cannot fetch the instance role's credentials; only the host can. The long grace period covers boot, the S3 sync and model load.
Step 5: weights stay inside AWS
Store each model revision under its own immutable prefix (model name, revision, plus a SHA-256 manifest), in a versioned bucket encrypted with your own KMS key. Instances reach it through a gateway endpoint, which costs nothing extra and needs no internet route:
resource "aws_vpc_endpoint" "s3" {
vpc_id = aws_vpc.main.id
service_name = "com.amazonaws.${var.region}.s3"
vpc_endpoint_type = "Gateway"
route_table_ids = aws_route_table.private[*].id
}
resource "aws_s3_bucket_versioning" "weights" {
bucket = aws_s3_bucket.weights.id
versioning_configuration {
status = "Enabled"
}
}
resource "aws_s3_bucket_server_side_encryption_configuration" "weights" {
bucket = aws_s3_bucket.weights.id
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "aws:kms"
kms_master_key_id = aws_kms_key.weights.arn
}
bucket_key_enabled = true
}
}Add a public access block and a bucket policy that denies reads unless aws:SourceVpce matches your endpoint. Rolling back weights is then a variable change: point model_prefix at the previous revision.
Step 6: no keys on disk
Every component gets an IAM role and nothing else. The GPU instance role can read one bucket prefix, decrypt with one KMS key, pull from one ECR repository and publish metrics. The gateway role can read its own entries in Secrets Manager and nothing in S3. Upstream provider keys, if the gateway also fronts hosted APIs, live in Secrets Manager and rotate on a schedule. Nobody holds an access key.
Step 7: watch latency, errors and spend
Create CloudWatch alarms on:
- ALB
TargetResponseTime,HTTPCode_Target_5XX_CountandUnHealthyHostCount. - GPU memory and utilization from the CloudWatch agent's
nvidia_gpusection (nvidia_smi_memory_used,nvidia_smi_utilization_gpu). - The vLLM queue metric described next.
- Spend, through AWS Budgets alerts.
vLLM's own Prometheus metrics, such as vllm:time_to_first_token_seconds and vllm:kv_cache_usage_perc, are worth a dashboard. Amazon Managed Prometheus and Grafana are the optional upgrade when CloudWatch feels thin.
Autoscale on queue depth, not CPU
A GPU server can be saturated while its CPU idles, so CPU-based scaling reacts late or never. Scale on vllm:num_requests_waiting, the number of requests queued inside vLLM. Publish it from each instance every minute:
#!/bin/bash
# Run every minute from a systemd timer. ASG_NAME and REGION are set in user data.
WAITING=$(curl -s localhost:8000/metrics \
| awk '/^vllm:num_requests_waiting[{]/ { s += $2 } END { print s + 0 }')
aws cloudwatch put-metric-data --region "$REGION" --namespace LLM/vLLM \
--metric-name RequestsWaiting --unit Count --value "$WAITING" \
--dimensions AutoScalingGroupName="$ASG_NAME"Then track the per-instance average:
resource "aws_autoscaling_policy" "queue_depth" {
name = "vllm-queue-depth"
autoscaling_group_name = aws_autoscaling_group.vllm_blue.name
policy_type = "TargetTrackingScaling"
estimated_instance_warmup = 900
target_tracking_configuration {
target_value = 4 # tune from a load test
customized_metric_specification {
namespace = "LLM/vLLM"
metric_name = "RequestsWaiting"
statistic = "Average"
metric_dimension {
name = "AutoScalingGroupName"
value = aws_autoscaling_group.vllm_blue.name
}
}
}
}A group at zero instances publishes no metric, so this policy cannot wake it. Use scheduled actions (aws_autoscaling_schedule with a recurrence cron and time_zone) to drop to a floor overnight and come back before working hours. If you need true on-demand scale from zero, SageMaker inference components are the AWS-native answer.
Roll out with a canary, roll back with a weight
Ship a new model revision or vLLM version as a second Auto Scaling group (green) with its own target group. On the internal ALB listener, split traffic by weight:
default_action {
type = "forward"
forward {
target_group {
arn = aws_lb_target_group.vllm_blue.arn
weight = 95
}
target_group {
arn = aws_lb_target_group.vllm_green.arn
weight = 5
}
}
}Move from 5 to 25 to 100 percent while watching the step 7 alarms and your eval set's scores. Rollback is setting green's weight back to 0, which takes effect without restarting anything. Keep blue running until green has carried full traffic for a day. For routine AMI or driver patches inside one group, an instance refresh with auto_rollback and an alarm specification does the same job with less ceremony.
Cost controls
- Commit only to the floor. Savings Plans are one- or three-year commitments; Compute Savings Plans apply across instance families and regions. Cover the instances that run around the clock and leave peaks on demand.
- Schedule the idle hours. An internal tool used in office hours does not need GPUs at 3 a.m.
- Right-size before you scale out. Try the smaller GPU with FP8 (on L4 or L40S) or a 4-bit quant before moving up a tier, and cap
--max-model-lenat what your prompts actually need.
Cost
One g6.xlarge running all month (730 hours) is about $588 in us-east-1 and $705 in Mumbai at on-demand rates. A g6e.xlarge is about $1,359 and $1,632. Idle GPU hours are the line to watch.
India regions
Mumbai (ap-south-1) lists G5, G6, G6e, P4d, P5, P5en and more, so it covers every size in this guide. Hyderabad (ap-south-2) lists only G6, G6e, P6-B200, P6-B300 and Trainium2 among accelerated instances: fine for L4 and L40S, but no G5, P4d or P5. Listed is not the same as obtainable, and default GPU quotas start low, so request quota before you need it.
Mumbai on-demand runs about 20 percent above us-east-1 for the instances in the table. If data must stay in India, the EC2 and EKS paths in either region keep weights, prompts and logs in-country. Bedrock Custom Model Import cannot, because it is not offered in any Indian region.
Sources
- vLLM documentation
- vLLM: Using Docker
- vLLM: vllm serve CLI reference
- vLLM: Online serving (health endpoint)
- vLLM: Production metrics
- vLLM: Quantization
- vLLM GitHub releases
- Docker Hub: vllm/vllm-openai tags
- NVD: CVE-2026-27893
- Red Hat: CVE-2026-90553
- LiteLLM: Oct 21, 2026 release v1.107.0 compromised
- Cloud Security Alliance: LiteLLM pre-auth SQLi exploited in 36 hours (CVE-2026-42208)
- AWS: Guidance for Scalable Model Inference and Agentic AI on Amazon EKS
- AWS: SageMaker AI, scale an endpoint to zero instances
- AWS: Bedrock Custom Model Import
- AWS: Amazon EC2 instance types by Region
- AWS price list: EC2 on-demand Linux, Asia Pacific (Mumbai)
- AWS price list: EC2 on-demand Linux, US East (N. Virginia)
- Vantage: g6.xlarge, g6e.xlarge, g5.xlarge, p4d.24xlarge, p5.48xlarge
- AWS: Deep Learning Base OSS Nvidia Driver GPU AMI (Ubuntu 24.04)
- vLLM: v0.34.0 release notes
- AWS: Amazon ECR interface VPC endpoints
- AWS: Edit attributes for your Application Load Balancer
- AWS WAF: Baseline managed rule groups
- AWS: Collect NVIDIA GPU metrics with the CloudWatch agent
- AWS CLI: cloudwatch put-metric-data
- AWS: What are Savings Plans?
- Terraform AWS provider: aws_vpc_endpoint
- Terraform AWS provider: aws_s3_bucket_versioning
- Terraform AWS provider: aws_s3_bucket_server_side_encryption_configuration
- Terraform AWS provider: aws_launch_template
- Terraform AWS provider: aws_autoscaling_group
- Terraform AWS provider: aws_autoscaling_policy
- Terraform AWS provider: aws_autoscaling_schedule
- Terraform AWS provider: aws_lb_listener