← Back to AWS
Lesson 2 · AWS Fundamentals

What is AWS?

AWS is Amazon’s cloud. It has hundreds of services, but a normal website uses only about a dozen of them. You meet those dozen, use seven of them with the same few lines of Python, and learn why your data sometimes seems to disappear - it is in another region.

Beginner30 min

What you will be able to do

  • Explain what AWS is and how you pay for it
  • Name the dozen services behind a typical web application
  • Use the same boto3 pattern for any AWS service
  • Tell regional services from global ones
  • Find the cause when "my resources disappeared"

The idea, in plain English

AWS - Amazon Web Services - is Amazon’s cloud: the provider we rent from in this course. Its first big services, S3 (storage) and EC2 (servers), launched in 2006; today it has hundreds of services, and industry reports put it first in cloud market share. Microsoft Azure and Google Cloud offer the same ideas under other names, so most of what you learn here moves with you.

Hundreds of services sounds frightening, but a normal web application uses about a dozen: something to run code, a database, file storage, a queue, monitoring, and access control. And every service is used the same way - an API you call with the same SDK - so the twelfth service is much easier than the first.

We count the services ourselves, map the dozen that matter, and build a tiny shop backend on seven of them. As in Lesson 1, every AWS call goes to moto, a fake AWS inside the program - no account, no bill. boto3 1.44.4, moto 5.2.5, Python 3.13.12.

Worked example: A small online shop’s backend - photos, orders, a queue, notifications, a secret, a metric and an app role - built on seven AWS services against moto, and a report job that looked in the wrong region.

Words you will see in this lesson

A few AWS words.

Small dictionary
AWSAmazon Web Services - Amazon’s cloud.
ServiceOne AWS product with its own API, like S3 (files) or DynamoDB (a database).
RegionA part of the world where AWS has data centres, like ap-south-1 (Mumbai). Lessons 3-4.
Regional serviceLives in one region - you must say which.
Global serviceThe same everywhere, no region: IAM, Route 53, CloudFront.
SDKA library for calling AWS from code - boto3 for Python (Lesson 9).
ARNAmazon Resource Name - the unique "address" of a thing in AWS, like arn:aws:iam::123456789012:role/shop-app.

An everyday example: a giant hardware store

  • AWS is like a hardware store with 400 aisles. Nobody uses every aisle.
  • To build a house you need about a dozen things: bricks, cement, pipes, wires, a door, a lock.
  • A web app also needs about a dozen: somewhere to run code, a database, file storage, a queue, a lock (access control), and a meter to watch it.
  • Every aisle has the same checkout - one account, one bill, one way to pay. In AWS that is one SDK and one API style.
  • And the store has branches in many cities (regions). Your things are in the branch where you bought them - not in every branch.

Example 1 - how big is AWS?

Instead of quoting a number from a website, count the services yourself. count_services.py reads boto3’s built-in list of AWS APIs - offline, no account:

  • get_available_services() lists every service boto3 can call.
  • get_available_regions(service) lists the regions where a service runs.
  • Some services return no regions at all - they are global.
Example 1 - count_services.py
import boto3 session = boto3.session.Session() services = session.get_available_services() # read from botocore's built-in API models, offline print("AWS services boto3 can call:", len(services)) print("first ten:", services[:10]) for service in ["ec2", "s3", "dynamodb", "lambda", "iam", "route53", "cloudfront"]: regions = session.get_available_regions(service) print(f" {service:<11} regions: {len(regions):>2}" + (" <- global service" if not regions else ""))
Output
AWS services boto3 can call: 439 first ten: ['accessanalyzer', 'account', 'account-access', 'account-access-runtime', 'acm', 'acm-pca', 'agent-registry', 'agent-registry-control', 'aiops', 'amp'] ec2 regions: 34 s3 regions: 34 dynamodb regions: 34 lambda regions: 34 iam regions: 0 <- global service route53 regions: 0 <- global service cloudfront regions: 0 <- global service

Reading the count

  • 439 services. The list grows every year - your boto3 version may show a different number.
  • EC2, S3, DynamoDB and Lambda each run in 34 regions: you choose one of them for every resource.
  • IAM, Route 53 and CloudFront show 0 regions: they are global services. One user list, one DNS, one CDN for the whole account.
  • You will not learn 439 services, and you do not need to. The next section is the short list.

The dozen services behind a typical web app

This course is built around these. The lesson numbers show where each one is taught:

A web app on AWS
Route 53DNS - turns shop.example.com into an address. Global. Lesson 74.
CloudFrontA CDN - serves files from a city near the user. Global. Lessons 6, 211.
Load balancerSpreads requests over several servers. Lessons 75-77.
EC2 / ECS / LambdaRun your code: a server, a container, or a single function. Lessons 31, 146, 42.
RDS / DynamoDBDatabases: SQL (PostgreSQL, MySQL) or key-value. Lessons 78, 87, 98.
S3File storage: photos, uploads, backups, static sites. Lesson 44.
ElastiCacheA fast in-memory cache (Redis). Lesson 96.
SQS / SNSA queue for work to do later / notifications to many listeners. Lessons 121, 122, 124.
IAMWho may do what. Global. Lesson 15.
Secrets ManagerPasswords and keys, kept out of your code. Lesson 27.
CloudWatchLogs, metrics and alarms. Lesson 132.
VPCYour private network inside AWS. Lesson 62.

Example 2 - seven services, one pattern

shop_on_aws.py builds a small part of a shop backend on seven of those services:

  • The helper aws(service) is the whole pattern: boto3.client(name, region_name=REGION). Every service starts the same way.
  • S3 stores a product photo. DynamoDB saves an order. SQS queues the receipt email for later. SNS notifies the kitchen. Secrets Manager keeps the database password. CloudWatch records a business number. IAM creates the role the app will run as.
  • Each block is "create something, then use it" - one or two calls.
  • All calls go to moto, and the credentials are fake: nothing is created on a real account. With a real account, the same code creates real (and billed) resources.
Example 2 - shop_on_aws.py
import json import os import boto3 from moto import mock_aws os.environ.update(AWS_ACCESS_KEY_ID="testing", AWS_SECRET_ACCESS_KEY="testing") # moto only REGION = "ap-south-1" # Mumbai @mock_aws def main(): aws = lambda service: boto3.client(service, region_name=REGION) # the same pattern for every service # S3 - files: a product photo aws("s3").create_bucket(Bucket="lakshmi-shop-photos", CreateBucketConfiguration={"LocationConstraint": REGION}) aws("s3").put_object(Bucket="lakshmi-shop-photos", Key="cakes/black-forest.jpg", Body=b"...jpeg bytes...") print("S3 stored ", aws("s3").list_objects_v2(Bucket="lakshmi-shop-photos")["Contents"][0]["Key"]) # DynamoDB - a database: one order aws("dynamodb").create_table(TableName="orders", BillingMode="PAY_PER_REQUEST", KeySchema=[{"AttributeName": "order_id", "KeyType": "HASH"}], AttributeDefinitions=[{"AttributeName": "order_id", "AttributeType": "S"}]) aws("dynamodb").put_item(TableName="orders", Item={"order_id": {"S": "A-1001"}, "total": {"N": "650"}}) print("DynamoDB saved ", aws("dynamodb").get_item(TableName="orders", Key={"order_id": {"S": "A-1001"}})["Item"]) # SQS - a queue: work to do later (send the receipt email) queue = aws("sqs").create_queue(QueueName="receipt-emails")["QueueUrl"] aws("sqs").send_message(QueueUrl=queue, MessageBody=json.dumps({"order_id": "A-1001"})) waiting = aws("sqs").get_queue_attributes(QueueUrl=queue, AttributeNames=["ApproximateNumberOfMessages"]) print("SQS queued ", waiting["Attributes"]["ApproximateNumberOfMessages"], "message") # SNS - notifications: tell the kitchen topic = aws("sns").create_topic(Name="new-orders")["TopicArn"] print("SNS sent ", aws("sns").publish(TopicArn=topic, Message="New order A-1001")["MessageId"][:8] + "...") # Secrets Manager - the database password, kept out of the code aws("secretsmanager").create_secret(Name="shop/db-password", SecretString="s3cret-from-vault") print("Secrets Manager kept ", aws("secretsmanager").describe_secret(SecretId="shop/db-password")["Name"]) # CloudWatch - monitoring: a business number aws("cloudwatch").put_metric_data(Namespace="Shop", MetricData=[{"MetricName": "Orders", "Value": 1}]) print("CloudWatch metric ", aws("cloudwatch").list_metrics(Namespace="Shop")["Metrics"][0]["MetricName"]) # IAM - who may do what (global: no region) aws("iam").create_role(RoleName="shop-app", AssumeRolePolicyDocument=json.dumps({ "Version": "2012-10-17", "Statement": [{"Effect": "Allow", "Principal": {"Service": "ec2.amazonaws.com"}, "Action": "sts:AssumeRole"}]})) print("IAM role ", aws("iam").get_role(RoleName="shop-app")["Role"]["Arn"]) main()
Output
S3 stored cakes/black-forest.jpg DynamoDB saved {'order_id': {'S': 'A-1001'}, 'total': {'N': '650'}} SQS queued 1 message SNS sent 25d3d2bd... Secrets Manager kept shop/db-password CloudWatch metric Orders IAM role arn:aws:iam::123456789012:role/shop-app

Reading the output

  • Every service answered in its own way, but every call looked the same: client, method, parameters.
  • DynamoDB shows its data with type letters: "S" for string, "N" for number - the total 650 is stored as text "650" with type N.
  • The IAM role’s ARN has an account number (moto’s fake 123456789012) but NO region between the colons - IAM is global.
  • Real systems are made of exactly these pieces, connected. Later modules teach each piece properly.

Trap 1: "my resources disappeared"

wrong_region.py: the order service writes orders in Mumbai. A report job, written later, creates its client without a region - so it uses the region set on the machine, here us-east-1:

  • Before: the report job saw no tables at all and crashed with ResourceNotFoundException. The orders were not lost - they were in another region.
  • After: with region_name="ap-south-1" set on purpose, it found the table and all 3 orders.
  • The same happens in the web console: switch to the wrong region and your servers, tables and queues seem gone. It is the most common beginner panic on AWS.
  • Fix: put the region in one setting your whole app uses, never rely on a machine default, and check the region first when something is "missing". Regions in depth: Lesson 4.
wrong_region.py
import os import boto3 from moto import mock_aws os.environ.update(AWS_ACCESS_KEY_ID="testing", AWS_SECRET_ACCESS_KEY="testing") # moto only def save_order(db, order_id): db.put_item(TableName="orders", Item={"order_id": {"S": order_id}}) @mock_aws def run(reader_region): # The order service: written with Mumbai in the code writer = boto3.client("dynamodb", region_name="ap-south-1") writer.create_table(TableName="orders", BillingMode="PAY_PER_REQUEST", KeySchema=[{"AttributeName": "order_id", "KeyType": "HASH"}], AttributeDefinitions=[{"AttributeName": "order_id", "AttributeType": "S"}]) for n in range(1, 4): save_order(writer, f"A-100{n}") # The report job: written later, by someone else reader = boto3.client("dynamodb", region_name=reader_region) tables = reader.list_tables()["TableNames"] print(f"report job in {reader.meta.region_name:<11} sees tables: {tables}", end=" ") try: count = reader.scan(TableName="orders")["Count"] print(f"-> {count} orders") except reader.exceptions.ResourceNotFoundException as error: print("->", error.response["Error"]["Code"]) os.environ["AWS_DEFAULT_REGION"] = "us-east-1" # the region set on this machine print("before:", end=" "); run(reader_region=None) # region comes from the machine print("after: ", end=" "); run(reader_region="ap-south-1") # region set on purpose, like the writer
Output
before: report job in us-east-1 sees tables: [] -> ResourceNotFoundException after: report job in ap-south-1 sees tables: ['orders'] -> 3 orders

Trap 2: no region at all

no_region.py creates two clients with no region anywhere - not in the code, not in the environment, and with this machine’s AWS config file switched off. It makes no calls:

  • DynamoDB refused at once: NoRegionError: You must specify a region. A regional service cannot guess where your data is.
  • IAM worked, with the region aws-global. A global service does not need one.
  • So code that "works on my laptop" can fail on a server whose config has no region. Set it explicitly.
no_region.py
import os import boto3 os.environ.update(AWS_ACCESS_KEY_ID="testing", AWS_SECRET_ACCESS_KEY="testing") for name in ["AWS_DEFAULT_REGION", "AWS_REGION", "AWS_CONFIG_FILE"]: os.environ.pop(name, None) os.environ["AWS_CONFIG_FILE"] = "/dev/null" # ignore this machine's ~/.aws/config for service in ["dynamodb", "iam"]: try: client = boto3.client(service) print(f"{service:<9} no region given -> client created, region = {client.meta.region_name}") except Exception as error: print(f"{service:<9} no region given -> {type(error).__name__}: {error}")
Output
dynamodb no region given -> NoRegionError: You must specify a region. iam no region given -> client created, region = aws-global

Four ways to use AWS

Every one of them calls the same APIs underneath:

  • The web console - click through pages; good for learning and looking around (Lesson 7).
  • The AWS CLI - commands in a terminal; good for scripts (Lesson 8).
  • An SDK - code in your app, like boto3 in this lesson (Lesson 9).
  • Infrastructure as code - describe everything in files and let a tool create it, so it can be reviewed and repeated.
  • Whatever you click in the console, there is an API call behind it - which is why everything in AWS can be automated.

AWS basics at a glance

Any service

One pattern.

boto3.client("dynamodb", region_name="ap-south-1")
List services

Offline, from boto3.

boto3.session.Session().get_available_services()
Regions of a service

Empty list = global.

session.get_available_regions("iam")  # []
Which region am I in?

Check first when things are "missing".

client.meta.region_name
ARN

A resource’s unique name.

arn:aws:iam::123456789012:role/shop-app

Try it yourself

The code does not change. Swap the content string and the program does something else entirely.

Find a service

“Print every service name in count_services.py that contains "lambda" or "s3". How many are there?”

Global or not?

“Add "sts", "organizations" and "sqs" to the region check. Which are global?”

An eighth service

“Add a CloudWatch Logs log group ("logs" client) to shop_on_aws.py and write one log line.”

Two regions

“In wrong_region.py, create an "orders" table in both regions with different orders. What does each report job see?”

What usually goes wrong

Trying to learn every service

439 services exist; a normal web app uses about a dozen. Learn those well.

Relying on the machine’s default region

The report job used us-east-1 and saw 0 tables - the orders were in ap-south-1.

Panicking when resources "disappear"

Check the region first - in code (client.meta.region_name) and in the console.

Forgetting that some services are global

IAM, Route 53 and CloudFront have no region; everything else needs one.

Best practices

  • Choose one region for your app and set it in one place.
  • Use the same client pattern for every service.
  • Practise with moto before using a real account.
  • Learn the dozen core services before exploring the rest.

Practice

Write these yourself before opening anything. Getting them wrong first is most of how this sticks.

1.

Change wrong_region.py so the region comes from ONE place: a SETTINGS dictionary (or an environment variable SHOP_REGION) that both the order service and the report job read. Then show that changing that one value moves both of them together.

Show hint

REGION = os.environ.get("SHOP_REGION", "ap-south-1"), and pass region_name=REGION to every client.

Coding challenge

Map an app you know to AWS

Pick a web app you use (a food delivery app, a college portal, a blog) and design which of the dozen services it would use.

It should
  • List the app’s main features (login, search, photos, orders, notifications...).
  • For each feature, name the AWS service from the table above and one sentence why.
  • Mark which services are global and which need a region - and choose the region.
  • Name one place where a wrong-region bug could happen in your design.

Key points

  • AWS is Amazon’s cloud - boto3 knows 439 services.
  • A typical web app uses about a dozen: compute, database, storage, queue, access, monitoring, network.
  • Every service is used the same way: boto3.client(service, region_name=...).
  • Most services are regional (34 regions); IAM, Route 53 and CloudFront are global.
  • Resources in another region are invisible: 0 tables in us-east-1, 3 orders in ap-south-1.

Quick check before you move on

How many services did boto3 list?
439.
In how many regions does EC2 run, according to boto3?
34.
What did the report job in us-east-1 see?
No tables - it raised ResourceNotFoundException.
What happened when a DynamoDB client was created with no region?
NoRegionError: You must specify a region.
Which region did the IAM client get with no region given?
aws-global.

Interview questions

What is AWS and what are its core services?

Amazon’s cloud platform. Core services: EC2, Lambda and ECS for compute; S3 for object storage; RDS and DynamoDB for databases; VPC for networking; IAM for access; CloudWatch for monitoring; SQS and SNS for messaging; Route 53 and CloudFront for DNS and content delivery.

What is the difference between a regional and a global AWS service?

Regional services (EC2, S3, DynamoDB...) keep resources in the region you choose; global services (IAM, Route 53, CloudFront) are account-wide with no region.

How do you call AWS from application code?

With an SDK such as boto3: create a client for a service and region, then call its API methods; credentials come from the environment, a profile, or an IAM role.

Quiz

  1. 1.

    Why did the IAM role’s ARN have no region?

  2. 2.

    Why can learning one AWS service make the next one easier?

  3. 3.

    Your servers are missing in the console. What do you check first?

  4. 4.

    Which services would a typical web app use for files, a queue, and access control?

Comments

Sign in to leave a comment. Your name and photo come from Google; nothing else is shared.

Loading comments...