AWS: Zero to Hero — Week 11: Where AI Actually Lives in AWS
Week 11 of learning AWS from zero, with Claude as my research partner. Where AI actually lives in AWS: pre-built services vs Bedrock vs SageMaker, and why SageMaker bills by the instance-hour. Hands-on: a budget alert, a first Bedrock call with token counts, temperature compared, a least-privilege Lambda that calls a model, and Comprehend, Translate, Polly and Rekognition.
Series: AWS: Zero to Hero (14 articles)
- …
- 11AWS: Zero to Hero — Week 11: Where AI Actually Lives in AWS This article
Ten weeks in, and this is the week the series turns to the question that started it: how are cloud and AI actually related, and what does AWS give you to build with? The honest first answer is that "AI on AWS" isn't one product. It's a stack of quite different services that people constantly confuse, because the marketing names overlap. So this week is mostly about drawing the lines, and then actually calling a few of these services to see how different they feel.
The Deep Dive
The stack, from the bottom up
It helps to think of AWS's AI offerings as layers, each one hiding more complexity than the one below:
- Infrastructure. The raw hardware for training and running models: GPU instances (the "accelerated computing" family from Week 4) and AWS's own AI chips, Trainium for training and Inferentia for inference. These come from the same Annapurna Labs silicon team behind Nitro (Week 2) and Graviton. Most people never touch this layer directly.
- Platform. The services where you build with models: SageMaker AI if you want to build, train, and host models yourself, and Amazon Bedrock if you want to use existing foundation models through an API.
- Task-specific AI services. Pre-built APIs for one well-defined job each, with no model knowledge required: Rekognition for images, Comprehend for text analysis, Transcribe for speech-to-text, Textract for document extraction, Polly for text-to-speech, Translate for translation.
- Finished applications. Products built on top of all of this, like Amazon Q and the Kiro coding environment, which you use rather than build with.
Everything else this week is about choosing between the middle two rows, because that's where beginners get stuck.
Pre-built AI services: the "I just need this one thing" tier
These are the oldest and simplest. You send an image, a piece of text, or an audio file; you get a structured answer back. There's no model to choose, train, or host.
- Rekognition — labels, faces, text, and moderation in images and video.
- Comprehend — sentiment, entities, key phrases, and language detection in text.
- Transcribe — speech to text.
- Textract — pulling text, tables, and forms out of scanned documents.
- Polly — text to lifelike speech.
- Translate — translation between languages.
If your problem is "detect the sentiment of this review" or "extract the fields from this invoice," a pre-built service is almost always the right answer: cheaper, faster to ship, and nothing to maintain. Reaching for a large language model for a task a purpose-built API already does well is a common and expensive mistake.
Amazon Bedrock: foundation models through one API
Bedrock is the model-access layer for generative AI. It gives you foundation models from many providers (Amazon's own Nova family, Anthropic, Meta, Mistral, and others, well over a hundred models in total) behind one consistent API, with no servers or GPUs for you to manage. A few things worth understanding properly:
- It's serverless and pay-per-token. You're billed for the tokens you send in and the tokens the model sends back, priced separately and quoted per million tokens. There is no idle cost: if you're not calling it, you're not paying. That's the opposite billing shape from SageMaker, covered below.
- The Converse API is a single, unified way to talk to chat-style models. Swap the model ID and the same code works against a different model, which is the practical meaning of Bedrock's "no lock-in to one model" pitch.
- On-demand vs. provisioned throughput. On-demand is pay-per-token with no commitment, ideal for getting started and for spiky traffic. Provisioned throughput reserves dedicated capacity by the hour, which makes sense for steady, high-volume workloads.
- Cross-region inference profiles. For many models you don't call the model directly; you call an inference profile that can route your request to capacity in several regions. You'll see this as a prefix on the model ID:
us.,eu., orapac.. It's a classic first-call stumbling block, and we'll hit it in the lab.
- It plugs into everything you've already learned. Access is controlled by IAM (Week 3), calls show up in CloudTrail (Week 10), and you can reach it privately through a VPC interface endpoint (Week 6). AWS also states that Bedrock doesn't use your prompts and outputs to train its models, which matters a great deal to anyone handling sensitive data.
- Model access. AWS has moved toward automatic access for most serverless models, but some providers still ask for a one-time form, and availability differs by region. If a call fails with an access error, check that model's status in the Bedrock console.
Bedrock also carries the building blocks for retrieval-augmented generation (knowledge bases), safety filtering (guardrails), and agents (including Bedrock AgentCore). Those are next week's material.
SageMaker: when you want to own the model
SageMaker is where you go when Bedrock's catalog isn't enough: you want to train a model on your own data, fine-tune an open model with full control, or host a model that isn't on Bedrock. You choose the instances, and you manage more of the stack.
The naming has shifted, so it's worth knowing: SageMaker AI is the machine-learning service (training, tuning, hosting), while SageMaker Unified Studio is a broader single environment that brings data, analytics, and AI work together. Older tutorials use "SageMaker" for the ML service only.
The key difference from Bedrock is the billing model. SageMaker bills by the instance-hour: notebooks, training jobs, and especially real-time inference endpoints bill for every hour they exist, whether or not anyone is calling them. An always-on endpoint left running is the AI version of Week 6's NAT Gateway and Week 8's EKS cluster: it costs money by the hour, silently, until you delete it.
So which one, when
- A well-defined task like OCR, sentiment, translation, or speech? Use a pre-built AI service.
- Generative text, chat, summarization, image generation, or agents? Start with Bedrock.
- Need to train or heavily customize a model, or run one Bedrock doesn't offer? Use SageMaker AI.
At very high, steady volume, dedicated capacity can eventually beat per-token pricing, which is why large teams often use both. But for learning, and for most early products, per-token on-demand is cheaper and simpler.
Cost Reality Check for This Week
This is a good week for the wallet, with one deliberate omission. Bedrock has no idle cost and charges per token; the cheapest models (Amazon Nova Lite is in the region of $0.06 per million input tokens) make a handful of test calls cost fractions of a cent. The pre-built services charge per call, characters, or image, and the lab makes only a few; I'm not quoting exact per-service rates, so check the pricing pages if you plan to run them in volume. If your account is on the newer credit-based Free Tier, all of it draws a negligible amount from that balance.
What I deliberately left out: a SageMaker hands-on. Setting up a Studio domain creates persistent storage that keeps billing, and the interesting SageMaker experiments (a real-time endpoint, a training job) cost real money by the hour. I'd rather explain the cost shape than have you pay to discover it, so SageMaker stays conceptual this week.
Hands-On
Step 0 — Set a spending guardrail first
Before experimenting with anything AI-related, put a budget alert in place. This doesn't cap your spending, it emails you when you cross a threshold. (Setting up a cost budget is also one of the tasks that earns the extra credits on newer accounts.)
ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
cat > budget.json <<'JSON'{ "BudgetName": "zth-monthly", "BudgetLimit": {"Amount": "5", "Unit": "USD"}, "TimeUnit": "MONTHLY", "BudgetType": "COST"}JSON
cat > notifications.json <<'JSON'[{ "Notification": { "NotificationType": "ACTUAL", "ComparisonOperator": "GREATER_THAN", "Threshold": 80, "ThresholdType": "PERCENTAGE" }, "Subscribers": [{"SubscriptionType": "EMAIL", "Address": "<your-email-address>"}]}]JSON
aws budgets create-budget --account-id $ACCOUNT_ID \ --budget file://budget.json \ --notifications-with-subscribers file://notifications.jsonPart 1 — Your first Bedrock call
Pick the inference-profile prefix for your region:
us. for US regions, eu. for Europe, apac. for Asia-Pacific (including Mumbai and Hyderabad). I'll use apac. below.MODEL_ID=apac.amazon.nova-lite-v1:0
aws bedrock-runtime converse \ --model-id $MODEL_ID \ --messages '[{"role":"user","content":[{"text":"Explain what an S3 bucket is in two sentences."}]}]' \ --inference-config '{"maxTokens":200,"temperature":0.3}' \ --query 'output.message.content[0].text' --output textIf you get an error saying on-demand throughput isn't supported for the model ID, it means you used a bare model ID where an inference profile is needed; make sure the
apac. / us. / eu. prefix matches your region. If you get an access error, your identity probably lacks Bedrock permissions, which is the next step.Now look at the part that determines your bill:
aws bedrock-runtime converse \ --model-id $MODEL_ID \ --messages '[{"role":"user","content":[{"text":"Explain what an S3 bucket is in two sentences."}]}]' \ --inference-config '{"maxTokens":200}' \ --query 'usage'That returns the input, output, and total token counts for the call. Multiply them by the model's per-million-token price and you have the exact cost of what you just did. This is the unit of billing for the whole service.
Part 2 — Least-privilege access to Bedrock (Week 3, applied)
If your CLI identity already has broad permissions this step is optional. If not, here's a policy scoped to one model, which is the right way to do it. Note it names both the inference profile and the underlying foundation model, because the profile can route across regions:
cat > bedrock-policy.json <<JSON{ "Version": "2012-10-17", "Statement": [{ "Effect": "Allow", "Action": ["bedrock:InvokeModel", "bedrock:InvokeModelWithResponseStream"], "Resource": [ "arn:aws:bedrock:*::foundation-model/amazon.nova-lite-v1:0", "arn:aws:bedrock:*:$ACCOUNT_ID:inference-profile/$MODEL_ID" ] }]}JSON
aws iam put-user-policy --user-name <your-iam-user> \ --policy-name zth-bedrock-nova-lite \ --policy-document file://bedrock-policy.jsonPart 3 — Temperature, made visible
Run the same prompt three times at two settings and compare:
for T in 0 1; do echo "--- temperature $T ---" for i in 1 2 3; do aws bedrock-runtime converse --model-id $MODEL_ID \ --messages '[{"role":"user","content":[{"text":"Give me a one-line slogan for a cloud learning blog."}]}]' \ --inference-config "{\"maxTokens\":50,\"temperature\":$T}" \ --query 'output.message.content[0].text' --output text donedoneAt temperature 0 the three answers should be nearly identical; at 1 they should vary noticeably. That's the control you'll reach for when you want consistency versus creativity.
Part 4 — Bedrock inside a Lambda function (Week 7, applied)
This is what "integrating AI into an app" actually looks like: a serverless function that calls the model, which any other part of your system can then invoke.
cat > trust-ai.json <<'JSON'{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"Service":"lambda.amazonaws.com"},"Action":"sts:AssumeRole"}]}JSON
aws iam create-role --role-name ZthAiLambdaRole \ --assume-role-policy-document file://trust-ai.jsonaws iam attach-role-policy --role-name ZthAiLambdaRole \ --policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
cat > lambda-bedrock-policy.json <<JSON{ "Version": "2012-10-17", "Statement": [{ "Effect": "Allow", "Action": ["bedrock:InvokeModel"], "Resource": [ "arn:aws:bedrock:*::foundation-model/amazon.nova-lite-v1:0", "arn:aws:bedrock:*:$ACCOUNT_ID:inference-profile/$MODEL_ID" ] }]}JSONaws iam put-role-policy --role-name ZthAiLambdaRole \ --policy-name zth-bedrock-invoke --policy-document file://lambda-bedrock-policy.json
ROLE_ARN=$(aws iam get-role --role-name ZthAiLambdaRole --query 'Role.Arn' --output text)sleep 10cat > ask.py <<'PY'import boto3, os
client = boto3.client("bedrock-runtime")
def handler(event, context): prompt = event.get("prompt", "Say hello.") resp = client.converse( modelId=os.environ["MODEL_ID"], messages=[{"role": "user", "content": [{"text": prompt}]}], inferenceConfig={"maxTokens": 200}, ) return { "answer": resp["output"]["message"]["content"][0]["text"], "usage": resp["usage"], }PYzip ask.zip ask.py
aws lambda create-function --function-name zth-ask \ --runtime python3.13 --role $ROLE_ARN --handler ask.handler \ --zip-file fileb://ask.zip --timeout 30 \ --environment "Variables={MODEL_ID=$MODEL_ID}"
aws lambda invoke --function-name zth-ask \ --cli-binary-format raw-in-base64-out \ --payload '{"prompt":"In one sentence, why do serverless functions scale to zero?"}' out.jsoncat out.jsonThe role only has permission for this one model, the function only does one thing, and the whole call is visible in CloudTrail (Week 10). Least privilege, serverless, and audited, with AI as just another API call.
Part 5 — The pre-built services, for contrast
These need no model choice, no prompt, and no token math. Feel how different they are from Bedrock:
# Comprehend: sentiment and entitiesaws comprehend detect-sentiment --language-code en \ --text "The new dashboard is fantastic, but the login page keeps crashing."
aws comprehend detect-entities --language-code en \ --text "Amazon launched the Nitro System in Seattle in 2017."
# Translate: try any language code you likeaws translate translate-text \ --source-language-code en --target-language-code hi \ --text "Cloud computing lets you pay only for what you use." \ --query TranslatedText --output text
# Polly: text to speech, saved as an audio fileaws polly synthesize-speech --output-format mp3 --voice-id Joanna \ --text "Hello from the AWS Zero to Hero series." hello.mp3
# Rekognition: labels for any JPEG or PNG on your machineaws rekognition detect-labels --image-bytes fileb://photo.jpg \ --max-labels 5 --query 'Labels[].[Name,Confidence]' --output tableCompare the experience. Comprehend returns a structured sentiment breakdown, not prose. Rekognition returns labels with confidence scores. None of these can chat, summarize, or reason; each does one job and does it cheaply and predictably. Knowing when not to reach for a large language model is half of using this stack well.
Cleanup
Bedrock has nothing to delete, which is the point. Remove the lab resources:
aws lambda delete-function --function-name zth-askaws iam delete-role-policy --role-name ZthAiLambdaRole --policy-name zth-bedrock-invokeaws iam detach-role-policy --role-name ZthAiLambdaRole \ --policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRoleaws iam delete-role --role-name ZthAiLambdaRoleaws iam delete-user-policy --user-name <your-iam-user> --policy-name zth-bedrock-nova-literm -f hello.mp3 out.jsonI'd keep the budget alert from Step 0. It costs nothing and it's the one piece of this lab worth leaving in place.
My Take
This week made one thing clear: AI on AWS is not just about using powerful models, but knowing which service to use and when. Bedrock makes getting started with generative AI surprisingly simple, while SageMaker offers deeper control at a higher operational cost. My biggest takeaway is that choosing the right tool, understanding its pricing, and applying least-privilege access matter just as much as the AI itself.
Next week — Part 12: Generative AI on AWS in depth — RAG with Bedrock knowledge bases, guardrails, and agents, including Bedrock AgentCore.
Series: AWS: Zero to Hero (14 articles)
- …
- 11AWS: Zero to Hero — Week 11: Where AI Actually Lives in AWS This article
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article