paulserban.eu

Writing Edition

Paul Serban

Writing, snippets & book notes

Cheat sheet - Post

AWS Fundamentals: Mental Models for Regions, Shared Responsibility, IAM, and Cost

← Back to AWS Basics: Introduction to Amazon Web Services

AWS is an on-demand catalog of cloud infrastructure services rented via API/console, where the platform is deliberately permissive - it won't stop you from building something insecure, fragile, or expensive.

Overview

Key Concepts

Regions and Availability Zones

Core Service Categories

Networking: VPC, Subnets, Security Groups

IAM and the Shared Responsibility Reality

Pricing Model

Trade-offs / Caveats

Example in Practice

Minimal S3 upload using boto3, illustrating least-privilege credential use and explicit server-side encryption - note that this code being "correct" doesn't make the setup safe if the IAM principal running it holds s3:* on *:

import boto3
from botocore.exceptions import ClientError

def upload_file(bucket: str, key: str, filename: str) -> None:
    s3 = boto3.client("s3")
    try:
        s3.upload_file(
            Filename=filename,
            Bucket=bucket,
            Key=key,
            ExtraArgs={"ServerSideEncryption": "AES256"},  # SSE-S3; use SSE-KMS for stricter control
        )
    except ClientError as e:
        raise RuntimeError(f"S3 upload failed: {e}") from e

The safe version of this pattern scopes IAM permissions to a single bucket (often a specific key prefix), denies public access at the bucket level unless a distribution use case explicitly requires it (serve via CloudFront instead), and logs the action through CloudTrail for audit.

Related topics