GenAI on AWS: The Big Picture
Generative & Agentic AI · GenAI on the Cloud · Basics · 16 min
Map any GenAI idea onto AWS's three layers and the six-stage project lifecycle, and choose between Amazon Q, Bedrock, SageMaker and self-hosting.
A three-storey building. The ground floor is the power plant (chips and servers), the middle floor is a model library with a front desk (Bedrock), and the top floor is a finished shop you just walk into (Amazon Q).
The idea in everyday words
Getting dinner. You can eat at a restaurant (Amazon Q: finished product), order from a meal-kit service and cook it your way (Bedrock: pick a model, add your own ingredients), or rent a commercial kitchen and buy raw produce (SageMaker or EC2: full control, full responsibility). Most nights the meal kit is the sweet spot.
The three layers of the AWS GenAI stack
Bottom: infrastructure (for people who train or host models themselves)
- Amazon EC2 GPU instances (NVIDIA-based P and G families) for training and inference.
- AWS Trainium chips (Trn instances) built for training, and AWS Inferentia chips (Inf instances) built for cheap inference. Both use the AWS Neuron SDK.
- Amazon SageMaker AI: managed notebooks, training jobs, JumpStart (a hub of ready-to-deploy models) and hosted endpoints. SageMaker HyperPod for very large training clusters.
Middle: models and tools (where most teams build)
- Amazon Bedrock: one serverless API to many foundation models (big pretrained models) from different providers: Anthropic Claude, Amazon Nova (text and multimodal), Amazon Titan (including Titan Text Embeddings), Meta Llama, Mistral AI, Cohere, AI21 Labs, Stability AI and more. The catalog changes often: check the Bedrock model list.
- Built-in tools: Knowledge Bases (managed RAG), Agents (tool-using workflows), Guardrails (safety filters), model evaluation, model customization (fine-tuning) and batch inference.
Top: applications (no ML work at all)
- Amazon Q Business: an assistant for employees over company data (wikis, S3, SharePoint and more), respecting document permissions.
- Amazon Q Developer: a coding assistant in your IDE and the AWS console.
The key idea: start as high in the stack as your needs allow. Each step down gives more control and more work.
The GenAI project lifecycle
Every GenAI project goes through the same six stages. Skipping one is how projects fail.
| Stage | Question | On AWS |
|---|---|---|
| 1. Scope | What exact task? How will we measure success? Latency and cost limits? | a requirements doc and a test set |
| 2. Select | Which existing model is good enough? | Bedrock playground, Bedrock model evaluation, JumpStart |
| 3. Adapt | How do we make it fit our task? | prompting → RAG (Knowledge Bases) → fine-tuning (Bedrock customization or SageMaker) |
| 4. Evaluate | Is it good enough on OUR examples? | Bedrock evaluations (human or LLM-as-judge), your own test set |
| 5. Deploy | How do we serve it reliably and cheaply? | Bedrock on-demand, batch, or provisioned throughput; SageMaker endpoints |
| 6. Integrate & monitor | How does the app call it, and how do we know it still works? | Lambda, API Gateway, CloudWatch, invocation logging, Guardrails |
Adapt is a ladder: climb only as high as you must. Prompt engineering costs minutes. RAG costs days and keeps answers current. Fine-tuning costs data, money and retraining every time the base model changes. Evaluate loops back to Adapt until the test set passes.
Bedrock vs SageMaker vs self-hosting
| Amazon Bedrock | SageMaker AI | Self-host on EC2 / EKS | |
|---|---|---|---|
| You manage | prompts and data | model, training, endpoint sizing | everything: servers, drivers, scaling, patching |
| Models | providers' catalog (+ import some custom weights) | any open model, or your own | anything |
| Pricing | per token (on-demand), batch discounts, or provisioned throughput | per instance-hour while running | per instance-hour + your engineering time |
| Best when | you want to ship fast with top models | you need custom training or a model not on Bedrock | special hardware, networking or serving stacks (vLLM, TGI) |
How to think about it:
- Default to Bedrock: no servers, pay for what you use, many models behind one API. Your prompts and outputs are not used to train the providers' models.
- Move to SageMaker when you have a concrete reason: you must own the weights, fully fine-tune, or run a model Bedrock does not offer.
- Go to raw EC2/EKS when you need control even SageMaker does not give you, and you have the team to run it.
- Volume matters. Per-token pricing wins at low or spiky traffic. A dedicated endpoint can win at very high, steady traffic. Do the maths with the AWS pricing pages, not guesses.
Equivalents: Google Cloud Vertex AI (Model Garden, Gemini) and Azure AI Foundry (Azure OpenAI) play the same roles.
How the pieces connect in a real app
A typical "chat with our docs" app on AWS:
- The browser calls Amazon API Gateway.
- API Gateway triggers an AWS Lambda function (your code).
- Lambda calls Bedrock Knowledge Bases to retrieve relevant chunks from documents stored in Amazon S3 (embedded with a Titan or Cohere embeddings model into a vector store such as Amazon OpenSearch Serverless).
- Lambda sends the question + chunks to a model through the Bedrock Converse API, with a Guardrail attached.
- IAM roles control who can call which model; VPC endpoints keep traffic private; CloudWatch tracks latency, errors and tokens.
# Map lifecycle stages to the AWS services you would reach for.
plan = {
"scope": "test set of 200 real questions",
"select": "Bedrock playground: compare 3 models",
"adapt": "system prompt + Bedrock Knowledge Bases (RAG)",
"evaluate": "Bedrock model evaluation, LLM-as-judge",
"deploy": "Bedrock on-demand + Guardrails",
"monitor": "CloudWatch metrics + invocation logs",
}
for i, (stage, service) in enumerate(plan.items(), 1):
print(i, stage.ljust(9), "->", service)
Step by step
- Scope:
Support bot for 500 help articles. Success = 90% of 200 real past questions answered correctly, under 3 seconds.
- Pick the layer:
Needs our own documents and a custom UI → not a ready-made app. No need to own weights → Bedrock, not SageMaker.
- Select:
Compare a small fast model and a stronger one in the Bedrock playground on 20 sample questions. The small one is close enough and cheaper.
- Adapt:
System prompt first (78% correct). Add RAG with Knowledge Bases over the S3 docs (93% correct). Stop climbing: no fine-tuning.
- Evaluate:
Run all 200 questions. Two failures traced to an outdated article: fix the data, re-run.
- Deploy & monitor:
Lambda + API Gateway calling Bedrock with a Guardrail. CloudWatch alarms on latency and errors; re-run the eval set before every prompt change.
Code example
# Per-token vs always-on endpoint: where is the break-even?
# Prices below are MADE-UP placeholders. Use the AWS pricing pages for real numbers.
price_per_1k_tokens = 0.002 # pretend on-demand price (input + output blended)
endpoint_per_hour = 1.50 # pretend instance price for a self-hosted endpoint
endpoint_per_day = endpoint_per_hour * 24
for tokens_per_day in [100_000, 2_000_000, 18_000_000, 50_000_000]:
per_token_cost = tokens_per_day / 1000 * price_per_1k_tokens
cheaper = "per-token" if per_token_cost < endpoint_per_day else "endpoint"
print(f"{tokens_per_day:>11,} tokens/day: per-token ${per_token_cost:7.2f} vs endpoint ${endpoint_per_day:.2f} -> {cheaper}")
print("break-even ~", int(endpoint_per_day / price_per_1k_tokens * 1000), "tokens/day")Interview tips
Name the three layers (infrastructure, models and tools, applications) and one AWS service in each.
Walk through the GenAI lifecycle and say which stage most projects underinvest in (scoping and evaluation).
"Bedrock or SageMaker?" Bedrock for managed access to many foundation models with per-token pricing; SageMaker when you need custom training, your own weights or a model not on Bedrock.
Explain the adapt ladder: prompting, then RAG, then fine-tuning, and why you climb only as needed.
Know Trainium (training) vs Inferentia (inference), and that both use the Neuron SDK.
Challenge: Pick the Right Layer
Write choose_platform(req) that recommends where to build a GenAI feature on AWS.
req is a dict that may contain these true/false flags (a missing flag means false):
| flag | meaning |
|---|---|
ready_made_app |
a finished assistant is acceptable, no custom code |
control_hardware |
must control servers, drivers or the serving stack |
custom_training |
must train or fully fine-tune and own the weights |
Check the rules in this order; the first match wins:
ready_made_app→{"service": "Amazon Q", "layer": "applications"}control_hardware→{"service": "EC2", "layer": "infrastructure"}custom_training→{"service": "SageMaker", "layer": "infrastructure"}- otherwise →
{"service": "Bedrock", "layer": "models and tools"}
Example: choose_platform({}) → {"service": "Bedrock", "layer": "models and tools"}
Solve it in the browser with tests, hints and an AI coach.
Practice problems
- What is Amazon Bedrock? (AWS docs)
- Generative AI on AWS (overview)
- Generative AI with Large Language Models (DeepLearning.AI + AWS course)
- Amazon Bedrock workshop (aws-samples)
More in GenAI on the Cloud
Previous: Embeddings & Vector Search · Next: Amazon Bedrock & the Converse API