Ravindra BagaleCourses & study guides मराठी Track your progress

What Is Amazon Bedrock? Generative AI APIs on AWS Explained

Bedrock lets your app talk to foundation models (Claude, Llama, Titan and others) over AWS APIs. You do not train a giant GPU farm first. Perfect for chat, summarise and classify — with strict token cost discipline.

What you'll learn in this chapter

  • What Bedrock is
  • Model access and regions
  • Pricing mental model (tokens)
  • Guardrails and IAM
  • Cost warnings for student labs

1. Everyday example

Why do we need this?

A Swiggy support bot must turn a long complaint into a short category + reply draft. Building that model from scratch is years of work. Calling a foundation model with a good prompt can be a weekend.

What is it?

Amazon Bedrock is a fully managed service to use foundation models via API (and tools like Knowledge Bases / Agents). Providers include Amazon and third parties, depending on region and account enablement.

One InvokeModel callYour appIAM roleBedrock APIap-south-1 or supported regionFoundation modelreturns text/embeddingYou storeresult in DynamoDB / S3
No endpoint cluster for you to patch for the base model.

2. Model access

Why do we need this?

Not every model is on in every account/region by default.

What is it?

  1. Console → Bedrock → Model access / Model catalog — request access for the models you need.
  2. Check the model is available in your region (Mumbai support grows over time — verify live).
  3. Call with AWS SDK (bedrock-runtime) using an IAM role that allows bedrock:InvokeModel on specific model ARNs.

3. Tokens and money

You usually pay per input token and per output token. Long prompts + long answers + many test loops = surprise bills. Set budgets and alarms.

Lab discipline

Before any Bedrock lab: enable only one cheap model, set an AWS Budget alert (for example $5), keep max_tokens small, and never put Bedrock calls in an unbounded loop. If your org blocks Bedrock, skip the live call — reading this chapter is enough for the quiz.

4. Safety extras

  • Guardrails: filter topics/PII patterns before/after the model.
  • Least-privilege IAM on model IDs — not *.
  • Do not send secrets or customer passwords in prompts.
  • Log prompts carefully — they may contain personal data.

5. Bedrock vs SageMaker (again)

GoalPrefer
Chat, summarise, embed with a managed FMBedrock
Train a custom tabular/CV model on your labelled dataSageMaker
Fine-tune / customise some FMs on Bedrock where offeredBedrock customisation features
Full training loop + custom containersSageMaker

6. Interview angles

Q. Do you manage GPUs for base FM calls?

No — Bedrock hosts the model.

Q. Main API family?

bedrock-runtime InvokeModel / Converse APIs.

Q. How billed?

Primarily tokens (plus optional extras).

Q. Guardrails?

Managed filters around model I/O.

Q. SageMaker instead?

When you must train/host your own model deeply.

Try at home

  1. Read current Bedrock pricing page for one model — note input vs output rates.
  2. Draft an IAM policy that allows InvokeModel on a single model ARN only.

In short

  1. Bedrock = foundation model APIs on AWS.
  2. Enable model access; use bedrock-runtime.
  3. Tokens cost money — budgets and small max_tokens.
  4. Prefer Bedrock for generative APIs; SageMaker for custom training.

Practice Tasks

About this scenario

Solapur Chaddar House is a home textiles business in Solapur. Vikas Kamble looks after its IT and cloud work. They count money in INR and run their AWS resources in the ap-south-1 Region. In the tasks below you do real jobs for them using what this lesson teaches. All names, account IDs, IP addresses and numbers are made up for practice.

0 / 10

Easy List Bedrock models

Why: See which foundation models are offered in your Region.

What to do: List the foundation models available in Amazon Bedrock.

How:
  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Easy List SageMaker endpoints

Why: Endpoints cost money every hour; list them to find forgotten ones.

What to do: List SageMaker endpoints.

How:
  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Easy How many addresses in a /16?

Why: Picking a VPC size needs this count.

What to do: Solapur Chaddar House plans the VPC 10.86.0.0/16. How many IP addresses does it hold in total?

How:
  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. Click Check answer.

Easy Port for SSH

Why: Security group rules need the right port.

What to do: Which TCP port must the security group open for SSH?

How:
  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. Click Check answer.

Easy Show where you are

Why: Before you copy or delete anything, you must know which folder you are in.

What to do: Vikas Kamble logged in to the Solapur Chaddar House server and is not sure which folder the terminal is in. Print the current folder path.

How:
  1. Find the Linux command that does this job.
  2. Add the options (like -r or -h) the task needs.
  3. Add the file names, folders or users in the right order.
  4. Use sudo if the job changes system files or users. Click Check answer.

Easy Read-only access to one bucket

Why: Least privilege: give only the actions and the bucket the job needs.

What to do: Write an identity policy that lets the user read objects (s3:GetObject) only in bucket solapurchaddar-data.

How:
  1. Start with { "Version": "2012-10-17", "Statement": [ ... ] }.
  2. In each statement write Effect, Action and Resource.
  3. Give only what the task needs (least privilege).
  4. Use double quotes and commas correctly. Click Check answer.

Medium Detect labels in an image

Why: Rekognition names objects in a photo, e.g. to tag product images.

What to do: Detect labels in s3://solapurchaddar-media/shop/p1.jpg (Bucket=solapurchaddar-media, Name=shop/p1.jpg), max 10 labels.

How:
  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Medium Allow one Bedrock model

Why: Limit apps to the approved model so costs stay predictable.

What to do: Allow bedrock:InvokeModel on arn:aws:bedrock:ap-south-1::foundation-model/amazon.nova-lite-v1:0 only.

How:
  1. Start with { "Version": "2012-10-17", "Statement": [ ... ] }.
  2. In each statement write Effect, Action and Resource.
  3. Give only what the task needs (least privilege).
  4. Use double quotes and commas correctly. Click Check answer.

Medium Usable IPs in an AWS /24 subnet

Why: AWS keeps 5 addresses in every subnet.

What to do: How many addresses can Solapur Chaddar House use for servers in subnet 10.86.1.0/24 on AWS?

How:
  1. Write down the numbers the task gives you.
  2. Work it out step by step on paper.
  3. Type only the final answer in the box.
  4. Click Check answer.

Hard Ask a model a question

Why: Converse is one API shape for many models.

What to do: Call converse on model amazon.nova-lite-v1:0 with the messages in msgs.json.

How:
  1. Read the task and decide which AWS service it is about.
  2. Write aws, then the service name, then the operation (the action word).
  3. Add each needed flag (--name) followed by its value from the task.
  4. Flags can be in any order. Click Check answer.

Revision, comparison and interview cards

Revise this lesson in a few minutes. Save the cards on your phone or download them as PNG files. The QR code on each card opens this lesson.

Revision card: What is Amazon Bedrock?. Support bots need summarise and reply drafts in a weekend — not years to train a giant model. Amazon Bedrock lets apps call foundation models (Claude, Llama, Titan and more) through AWS APIs and IAM. Enable model access in console → call bedrock-runtime with an IAM role that allows InvokeModel on specific model IDs. A short prompt returns a completion; you store the result in DynamoDB or S3 if needed.
Revision card: What is Amazon Bedrock? · Download PNG · Open card page
Revision card: Tokens and cost discipline. Long prompts, long answers, and unbounded test loops create surprise bills. You usually pay per input token and per output token. Keep max_tokens small in labs; set AWS Budgets. Enable one cheap model, budget alert (e.g. $5), never put Bedrock in an infinite loop. Ten short test calls stay cheap; a loop of 100k-token dumps does not.
Revision card: Tokens and cost discipline · Download PNG · Open card page
Revision card: Guardrails and IAM. Prompts can leak PII; wildcard model access is too broad. Bedrock Guardrails filter topics/PII patterns. IAM should allow InvokeModel only on the model ARNs you need. Attach a policy with bedrock:InvokeModel on one model ARN; add a Guardrail in console for the app use case. A denied model ID fails closed; a Guardrail blocks a disallowed topic before it reaches users.
Revision card: Guardrails and IAM · Download PNG · Open card page
Comparison: Bedrock token pricing vs SageMaker instance hours. Bedrock token pricing: Pay per input/output tokens of each call. SageMaker instance hours: Pay for notebook/training/endpoint instance time.
Comparison: Bedrock token pricing vs SageMaker instance hours · Download PNG · Open card page
Interview card: Bedrock or SageMaker for a chatbot?. If a managed foundation model API is enough, Bedrock. If you must train a custom model on your labels, SageMaker. Chat/summarise is the classic Bedrock fit. InvokeModel on Claude/Llama-class models via Bedrock; keep tokens bounded.
Interview card: Bedrock or SageMaker for a chatbot? · Download PNG · Open card page
Interview card: Why can InvokeModel fail with access errors?. Model access may be off in the account/region, or IAM lacks bedrock:InvokeModel on that model ARN. Regions differ; always verify model availability where you call. Console Model access enable + IAM Allow InvokeModel on specific model ID.
Interview card: Why can InvokeModel fail with access errors? · Download PNG · Open card page

More cards: Ravi Sir's Cards.