Simple Storage Service (S3)
Amazon S3 (Simple Storage Service) 101
Amazon S3 – Core Concepts
- AWS’s primary storage offering
- Uses an object-based storage model (not file storage and not block storage)
- Data is stored as objects, which are kept inside buckets (containers)
- Well-suited for storing large volumes of data such as videos, audio files, images, text, and other unstructured content
- Cost-efficient
- Can be accessed through the console, CLI, APIs, and HTTP(S)
- Designed as a publicly accessible service with virtually unlimited storage and support for multiple users
- Many AWS services rely on S3 as their default source or destination for data
- Uses an object-based storage model (not file storage and not block storage)
- S3 operates as a global service with regional data placement and redundancy
- Bucket names must be unique across all AWS accounts globally
- Actual data is stored within a specific region
- Data is automatically replicated across multiple Availability Zones in that region
- Because S3 uses object storage:
- It is not a file system, so you cannot navigate it like traditional directories
- Use Amazon EFS or Amazon FSx for file-based storage
- It is not block storage, so it cannot be mounted like a drive (e.g.,
C:\or/mnt)- Use Amazon EBS for block-level storage
- It is not a file system, so you cannot navigate it like traditional directories
S3 Objects

- Objects are similar to files, though technically different in structure
- Key components:
- Key → the unique identifier for an object within a bucket
- Example:
koala.jpg - Functions similarly to a filename
- Example:
- Value → the actual data stored in the object
- Size can range from 0 bytes up to 5 TB
- 5 TB is the maximum allowed size per object (fixed limit)
- Additional attributes include:
- Version ID
- Metadata
- Access Control List (ACL)
- Subresources
- Key → the unique identifier for an object within a bucket
- Every object must reside within a bucket and cannot exist independently
S3 Buckets

- An S3 bucket acts as a container that holds objects
- Buckets are created in a specific region, which ensures data residency control
- Data remains in that region unless explicitly configured otherwise
- Each bucket can store an unlimited number of objects, making S3 highly scalable
- Buckets are created in a specific region, which ensures data residency control
- Bucket naming:
- Serves as a globally unique identifier
- Example:
koaladata
- Example:
- Must be unique across all AWS regions and accounts
- This is why bucket ARNs do not include a region
- Naming rules:
- Length must be between 3 and 63 characters
- Only lowercase letters and numbers allowed (no underscores)
- Must begin with a letter or number
- Cannot resemble an IP address format
- Serves as a globally unique identifier
- Structure:
- S3 uses a flat architecture
- There are no real folders or directories
- All objects exist at the same level within a bucket
- The AWS console may display folders, but these are just prefixes
- Example:
/images/file.jpgappears as a folder, but/images/is only part of the object key
- Example:
- S3 uses a flat architecture

- Prefixes are used for organizing and filtering objects
- Bucket limits:
- Default (soft limit): 10,000 buckets per account
- This can be increased by requesting AWS support
- Limits affect system design decisions
- For example, instead of creating one bucket per user, prefixes can be used within a single bucket
- Default (soft limit): 10,000 buckets per account
- Security:
- Buckets are private by default
- A built-in setting blocks all public access unless explicitly disabled
- Even if this block is turned off, the bucket is not automatically public—it still requires proper configuration
S3 Security (Bucket Policies & ACLs)
Providing Access to S3
- Even though S3 is accessible over the internet, it is secure by default
- Endpoints are publicly reachable from a networking perspective
- However, buckets and objects are not accessible unless permissions are explicitly granted
- S3 security mechanisms include:
- Bucket policies → resource-based policies attached directly to buckets
- Access Control Lists (ACLs) → older permission model
- Block Public Access settings → built-in safety mechanism
- IAM identity policies → attached to users, groups, or roles
- These can grant or restrict access to S3 resources
- The effective permissions result from the combined evaluation of all policies and settings
S3 Bucket Policies

- A bucket policy is a resource-based policy applied to an S3 bucket
- It defines which principals are allowed or denied access
- Limitation of identity-based policies:
- They can only be assigned to identities within your own AWS account
- Advantages of resource-based (bucket) policies:
- Can grant or deny access to external AWS accounts
- Can allow access to unauthenticated users (public access)
- Can restrict access based on conditions such as:
- IP address ranges
- MFA requirements
- Other criteria
- The
"Principal"field specifies who the policy applies to:- Example:
"Principal": "*"means anyone (anonymous access) - This field is not needed in identity policies since the principal is implied
- Example:
- Bucket policy examples are available here:
S3 bucket policy examples
When to Use Identity vs Resource Policies
- Use identity policies when:
- Managing permissions across multiple AWS services
- The resource does not support resource-based policies
- You prefer centralized IAM-based control
- Access is limited within a single account
- Use resource policies when:
- You want to manage permissions directly on the resource (e.g., S3 bucket)
- You need cross-account or public access
- In many cases, both policy types are used together depending on requirements
S3 Access Control Lists (ACLs)
- ACLs are an older method of managing permissions in S3
- They are attached as a subresource to either a bucket or an object
- Apply to:
- A single object, or
- All objects within a bucket
- Supported permission types:
READ→ allows read accessWRITE→ allows write accessREAD_ACP→ allows viewing the ACLWRITE_ACP→ allows modifying the ACLFULL_CONTROL→ grants all permissions
- Limitations:
- Cannot target specific groups of objects (e.g., by prefix)
- Offer only basic permission controls
- Lack the flexibility and granularity of IAM or bucket policies
- ACLs are considered outdated and should generally be avoided
S3 Block Public Access Setting

- These settings act as a protective layer at the bucket level
- When enabled, they prevent any public (anonymous) access
- Public access refers specifically to:
- Requests from unauthenticated or anonymous users
- Authenticated AWS identities are not impacted by this restriction
- When Block Public Access is enabled:
- It overrides any bucket policy that would otherwise allow public access
- This feature is enabled by default:
- Introduced to reduce accidental exposure of data
- Ensures that public access must be intentionally configured, not accidental
S3 Static Website Hosting & Billing
S3 Static HTTP Website Hosting
- Standard interaction with S3 objects is done through APIs, which provide both security and flexibility
- The AWS Console and CLI internally rely on these APIs
- S3 Static Website Hosting enables objects to be accessed using HTTP requests
- This allows an S3 bucket to function as a static website host
- Commonly used for sites like blogs or personal portfolios
- Setup process is straightforward:
- Enable static website hosting on the bucket and define index and error documents (HTML files)
- Index document → the default page returned when no specific object is requested
- Error document → displayed when errors occur (e.g., 404 Not Found)
- A website endpoint is automatically generated
- This endpoint allows HTTP-based access to the bucket contents
- AWS provides a default endpoint format
- To use a custom domain, you must register and configure your own DNS
- The Block Public Access setting must be disabled for browser access
- Without using Amazon CloudFront, access is limited to HTTP only (no HTTPS support)
- Configure a custom domain using Amazon Route 53
- Example workflow:
- Register a domain such as
example.org - Create an S3 bucket with the same name
- Configure DNS records to point to the bucket endpoint
- Register a domain such as
- This setup can later be integrated with CloudFront for HTTPS support
- Example workflow:
- Enable static website hosting on the bucket and define index and error documents (HTML files)
S3 Static Website Hosting – Use Cases

- Content Offloading
- Move large static files (e.g., images, videos) from compute services to S3
- Reduces load on services like EC2 and lowers costs
- Example: store images in S3 and return their URLs from an application
- Out-of-Band Failover Pages
- Host backup or maintenance pages separately from the main application
- Ensures availability even if the primary compute service fails
- Example: redirect traffic to an S3-hosted status page during downtime
- Static Website Hosting
- Ideal for simple, non-dynamic websites such as blogs or portfolio pages
S3 Billing
- S3 is known for being very cost-effective, even beyond the Free Tier
- It is widely used due to its low pricing and scalability
- Pricing components include:
- Storage usage
- Cost depends on the storage class and amount of data stored
- Data transfer out of S3
- Charges apply when data is sent out of S3 (via API or HTTP access)
- Uploading data into S3 is free of charge
- Storage usage
- Free Tier (first 12 months) typically includes:
- Up to 5 GB of standard storage
- Up to 20,000 GET requests per month
- Up to 2,000 PUT requests per month
- Even after exceeding the Free Tier, S3 remains relatively inexpensive
- However, monitoring usage and costs is still important
S3 Object Versioning & MFA Delete
S3 Object Versioning
- S3 supports keeping multiple versions of an object under the same key
- This feature is configured at the bucket level
- Each version is assigned a unique version ID (
id)- You can reference a specific version by including its ID in requests
- If no ID is provided, operations act on the latest (current) version
- All versions consume storage space, which increases cost
- Storing multiple versions of one object is equivalent to storing multiple separate objects of the same size
- Versioning states:
- Disabled, Enabled, or Suspended
- When disabled, objects have a version ID of
null - Once versioning is turned on, it cannot be turned off—only suspended
- Suspending versioning:
- Does not delete existing versions
- Older versions remain stored and continue to incur charges
- Methods to remove older versions:
- Manually iterate through objects and delete each version individually
- Download current versions, delete the bucket, recreate it, and then re-upload data
- Both approaches are time-consuming and may result in additional cost
S3 Operations With and Without Versioning
- Behavior of certain operations changes depending on whether versioning is disabled, enabled, or suspended:
| S3 Object Versioning → // S3 Operation ↓ | DISABLED | ENABLED | SUSPENDED |
|---|---|---|---|
| Standard GET | Returns the object | Returns the most recent version | Returns the most recent version |
| Version GET | Not supported | Retrieves the specified version | Retrieves the specified version |
| Standard PUT (update object) | Replaces the existing object | Creates a new version and marks it as current | Replaces the current version |
| Standard DELETE | Permanently removes the object | Adds a delete marker, older versions remain | Adds a delete marker, older versions remain |
| Version DELETE | Not supported | Deletes a specific version | Deletes a specific version |
- Delete markers:
- Act as a placeholder that makes the object appear deleted
- Standard GET requests will not return the object
- The console hides the object unless version visibility is enabled
- Removing the delete marker restores access to the previous version
MFA Delete
- A bucket-level setting that adds an extra layer of protection
- Requires multi-factor authentication (MFA) to perform sensitive actions:
- Deleting a specific object version
- Changing the versioning state of the bucket
- Requires multi-factor authentication (MFA) to perform sensitive actions:
- MFA credentials (serial number and code) must be included in API requests for these operations
S3 Performance Optimization
Default S3 Single-Stream Uploads

- By default, the
s3:PutObjectoperation uploads data as a single continuous stream - Limitations:
- If the stream is interrupted, the entire upload must be restarted
- The larger the object, the higher the risk of failure
- Performance and reliability are constrained by using only one stream
- Maximum upload size for this method is 5 GB, even though S3 supports objects up to 5 TB
- If the stream is interrupted, the entire upload must be restarted
- Single-stream uploads are particularly inefficient for global applications

- Greater distance between users and the S3 region leads to:
- Slower transfer speeds
- Increased likelihood of failure due to unstable network conditions
- Technologies like BitTorrent were designed to address similar performance challenges in distributed networks
- To improve performance and reliability, two main approaches are used:
- S3 Multipart Upload
- S3 Transfer Acceleration
S3 Multipart Upload

- This method divides a large object into smaller parts and uploads them in parallel using multiple streams
- Typically used for objects 100 MB or larger
- Key characteristics:
- Objects can be split into up to 10,000 parts
- Each part can range from 5 MB to 5 GB (except the final part, which can be smaller)
- Benefits:
- Failed parts can be retried individually without restarting the entire upload
- Faster upload speeds due to parallel transfers
- More efficient use of available network bandwidth
- It is recommended to use multipart upload whenever possible for larger files
- The AWS Management Console enables this automatically for applicable uploads
S3 Transfer Acceleration

- Uses AWS edge locations to speed up data transfers to S3
- Instead of sending data directly over the public internet to the S3 region:
- The client connects to the nearest edge location
- Data then travels through the AWS global network, which is optimized for speed and reliability
- Instead of sending data directly over the public internet to the S3 region:
- Advantages:
- Improved upload performance, especially when users are far from the S3 bucket’s region
- Reduced latency and more consistent transfer speeds
- When enabled:
- A special accelerated endpoint is provided
- This endpoint automatically routes traffic to the closest edge location
- Requirements and limitations:
- Bucket names must be DNS-compliant
- Bucket names cannot include periods (
.)
- You can test performance differences using this tool:
S3 Transfer Acceleration speed comparison tool - Conceptual comparison:
- Public internet → flexible but indirect, with variable routing and delays
- AWS global network → optimized, direct, and high-performance infrastructure for faster data transfer
Encryption 101
Encryption – Key Concepts
- Encryption is the process of transforming data into a format that cannot be understood by unauthorized users
- Common approaches: encryption at rest and encryption in transit
- Main types: symmetric and asymmetric encryption
- Plaintext refers to data in its original, unencrypted form
- It can be any type of data (text, images, files, etc.), not just written text
- Ciphertext is the result of encryption
- The data appears scrambled and cannot be interpreted without the proper key
- A key is used to encrypt and decrypt data
- It can be something simple like a password or a complex string of characters
- An algorithm is the mathematical process used to perform encryption and decryption
- Plaintext + key → ciphertext (encryption)
- Ciphertext + key → plaintext (decryption)
- Examples include AES, DES, Blowfish, RC4, RC5, and RC6

Encryption Approaches

Encryption at Rest
- Protects data that is stored, such as on disks or in cloud storage
- Prevents unauthorized access if the storage medium is stolen or compromised
- Uses a secret (key) to secure stored data
- Typically involves only one party, responsible for protecting its own data
- In AWS, services like Key Management Service (KMS) are used for this purpose
Encryption in Transit
- Secures data while it is moving between systems
- Example: transferring data between a client and a server over HTTPS
- One side encrypts the data before sending, and the other decrypts it upon receipt
- Data travels through an encrypted channel, preventing interception from being useful
- AWS communications commonly use SSL/TLS for this type of protection
Encryption Types
Symmetric Encryption
- Uses a single shared key for both encryption and decryption
- Advantages:
- Fast and efficient in terms of processing
- Disadvantages:
- Sharing the key securely between parties is difficult
- Common use cases:
- Encrypting stored data
- Encrypting transmitted data after a secure channel is established

Asymmetric Encryption and PKI
- Uses a pair of keys:
- Public key → shared openly
- Private key → kept secret
- One key encrypts the data, and the other decrypts it
- Advantages:
- Enables secure communication without prior key exchange
- Public keys can be safely distributed
- Disadvantages:
- Slower and more resource-intensive than symmetric encryption
- Common use cases:
- Establishing secure channels (e.g., SSL/TLS, SSH)
- Exchanging symmetric keys securely
- Identity verification through digital signatures
- In practice:
- Asymmetric encryption is often used to securely share a symmetric key
- After that, symmetric encryption is used for efficient data transfer

Digital Signing
- Encryption alone does not confirm the sender’s identity
- Digital signatures are used to verify authenticity
- Process:
- A sender signs data using their private key
- The receiver verifies the signature using the sender’s public key
- This ensures:
- The message was created by the expected sender
- The content has not been altered

Steganography
- Used when the goal is to hide the existence of communication, not just protect its content
- Steganography involves embedding hidden data inside another file
- Example: hiding information within an image
- Key points:
- Observers may not even realize data is being transmitted
- Extraction usually requires specific knowledge or keys
- Can be combined with:
- Encryption (to protect the hidden data)
- Digital signatures (to verify authenticity)

Envelope Encryption
Envelope Encryption – Key Concepts
- Envelope encryption is the technique of encrypting encryption keys, providing multiple layers of security.
- Think of it like locking a key inside a vault that itself requires another key to open.
- Key Encryption Key (KEK) → encrypts/decrypts other keys
- Data Encryption Key (DEK) → encrypts/decrypts actual data
- Typically:
- Key service stores KEKs
- Customers store encrypted DEKs and encrypted data
- Customers request the key service to encrypt/decrypt DEKs
- Example: AWS Key Management Service (KMS) acts as the managed key service in AWS
- Benefits:
- Permission separation: storage admins can manage data storage without access to the data itself
- Less data sent to key service: DEKs are small compared to bulk data
- Isolated blast radius: each object can use a unique DEK, limiting exposure if a key is compromised
- Combines asymmetric flexibility and symmetric efficiency:
- KEKs can be asymmetric for flexibility
- DEKs are usually symmetric for speed
Envelope Encryption – Encrypt/Decrypt Processes
Scenario: Many cat pictures are stored in Amazon S3, and we want to encrypt them securely using AWS KMS.
- KMS keys can encrypt/decrypt up to 4 KB of data → suitable for DEKs, not large objects
- KMS keys are symmetric and stay inside KMS (never leave the service)
- Permissions for KMS are independent from S3 → having access to S3 objects doesn’t guarantee KMS access
Encryption Process
- Customer creates a KMS key for use with S3
- S3 requests KMS to generate a DEK for a cat picture
- KMS generates a DEK and returns:
- Plaintext DEK → used immediately by S3 to encrypt data
- Wrapped DEK (ciphertext version) → stored alongside encrypted object
- S3 encrypts the cat picture using the plaintext DEK, then discards the plaintext DEK
- Encrypted cat picture and wrapped DEK are stored together
- Repeat for all pictures
Why envelope encryption?
- Cat pictures are much larger than 4 KB → KMS cannot encrypt them directly
- Allows use of unique DEKs per object for best security practices
- Symmetric DEKs allow fast encryption; asymmetric would be slower
Decryption Process
- Customer requests access to an encrypted cat picture
- If the customer lacks KMS permissions, S3 cannot decrypt the object
- S3 sends the wrapped DEK to KMS to unwrap (decrypt) it
- KMS verifies permissions and identifies which KMS key (KEK) was used
- KMS decrypts the DEK and returns the plaintext DEK to S3
- S3 decrypts the cat picture using the plaintext DEK, then discards the DEK
- S3 returns the decrypted cat picture to the customer
This approach ensures security, efficiency, and granular access control.
AWS Key Management Service (KMS)
AWS KMS – Overview & Key Concepts
What KMS Does
- AWS Key Management Service (KMS) creates and manages cryptographic keys.
- Supports:
- Symmetric keys (basic use, fast encryption/decryption)
- Asymmetric keys (advanced use, slower but enables secure key exchange)
- Can perform cryptographic operations:
Encrypt,Decrypt,GenerateDataKey, etc.
Security & Isolation
- Keys never leave KMS; they’re stored in HSMs (Hardware Security Modules)
- FIPS 140-2 (Level 2) compliant
- Key material stays inside HSM
- AWS KMS ≠ CloudHSM → AWS has access to KMS keys, but no access to CloudHSM keys
- Keys are region-specific, though multi-region keys exist (out of SAA-C03 scope)
- KMS is a public service with public endpoints
Cryptographic Operations

| Operation | Description |
|---|---|
CreateKey | Creates a KMS key and stores it encrypted in HSMs |
Encrypt | Encrypts plaintext using a KMS key → returns ciphertext |
Decrypt | Decrypts ciphertext → returns plaintext (KMS key info embedded in ciphertext) |
GenerateDataKey | Generates a Data Encryption Key (DEK) for bulk encryption (>4 KB) |
KMS permissions are very granular → allows strict role separation
KMS Keys
- KMS key = logical container with metadata, backed by key material
- Old term: Customer Master Key (CMK)
- Can directly operate on data ≤ 4 KB
- Key material = actual bytes/numbers used in cryptographic operations
- Metadata includes:
- Key ID, Creation date, Key policy, Description, State (Enabled/Disabled)
Types of KMS keys
- AWS-owned (default, free)
- Used automatically by AWS services (S3, SQS, DynamoDB)
- Shared across accounts → low admin overhead, but limited security controls
- Customer-owned
- AWS-managed (free) → AWS creates/manages, rotates automatically yearly
- Customer-managed ($1/month) → customer creates and manages manually
- Supports aliases (unique per region)
- Supports automatic rotation (yearly) or on-demand rotation
- Can be used by AWS services or custom apps
Billing
- Customer-managed keys: $1/month + $0.03 per 10k API calls
- AWS-owned or AWS-managed keys: free
KMS Key Policies & Permissions
- Every KMS key has a key policy (resource policy)
- Can only be modified for customer-managed keys
- KMS does not automatically trust IAM users → trust must be explicitly added
- Access controlled by key policy + IAM policies
- Optional: grants (not in scope for SAA-C03)
Data Encryption Keys (DEKs)

- DEKs are generated by KMS for bulk encryption (> 4 KB)
- Key part of envelope encryption
kms:GenerateDataKeyreturns:- Plaintext DEK → used immediately, then discarded
- Ciphertext DEK → stored with encrypted object
- KMS never stores DEKs; they’re for client or AWS service use
- Can choose:
- Same DEK for multiple objects
- Unique DEK per object (best practice for isolated security)
Demo: Shell Commands
echo "find all the doggos, distract them with the yumz" > battleplans.txt# Encrypt file
aws kms encrypt \
--key-id alias/catrobot \
--plaintext fileb://battleplans.txt \
--output text \
--query CiphertextBlob \
| base64 --decode > not_battleplans.enc # Decrypt file
aws kms decrypt \
--ciphertext-blob fileb://not_battleplans.enc \
--output text \
--query Plaintext | base64 --decode > decryptedplans.txt
- Note:
kms:Decryptdoes not require explicitly specifying the KMS key; the key info is embedded in the ciphertext.
S3 Encryption
S3 Encryption In Transit
- S3 enforces encryption during data transfer
- S3 endpoints require HTTPS connections, ensuring that clients use SSL/TLS when sending or retrieving data.
S3 Object Encryption (Encryption At Rest)

- Data is encrypted on arrival at S3 endpoints before it is written to storage → this is encryption at rest.
- Encryption applies to objects, not buckets
- Each object can have different encryption settings.
- Buckets can have a default encryption configuration to automatically encrypt new objects.
- Two main approaches for encryption at rest:
- Client-Side Encryption (CSE): client provides ciphertext
- The client controls the encryption keys and process
- S3 acts purely as storage; no cryptographic operations are performed
- AWS never sees the unencrypted data or keys
- Suitable for strict compliance requirements
- Tradeoff: client is responsible for all encryption/decryption operations, which can be resource-intensive
- Server-Side Encryption (SSE): client provides plaintext
- S3 performs encryption/decryption operations
- Tradeoff: client has less direct control over encryption, but encryption is offloaded to S3
- Client-Side Encryption (CSE): client provides ciphertext
- AWS requires SSE for all objects
- Storing unencrypted objects is no longer allowed
- If using CSE, SSE must also be applied
S3 Server-Side Encryption (SSE)
- SSE types:
- SSE-S3: S3-managed keys (default)
- SSE-KMS: KMS-managed keys
- SSE-C: customer-provided keys
- Each type involves tradeoffs depending on who manages the keys and level of control required
SSE-S3 (AES-256)

- S3 manages keys and encryption operations
- Uses AES-256 encryption and is suitable for general-purpose workloads
- Envelope encryption: S3 Master Key generates a unique Data Encryption Key (DEK) for each object, which is stored alongside the encrypted object
- Advantages:
- Minimal administrative effort
- Strong AES-256 algorithm
- Limitations:
- Limited control over keys
- No auditing/logging of key usage available to customer
- Role separation not supported (any S3 admin can decrypt all objects)
- Not recommended for high-security environments (e.g., finance, healthcare)
SSE-KMS

- S3 performs encryption/decryption using customer-owned KMS keys
- KMS manages the keys; S3 requests use of keys for encryption operations
- KMS key options:
- AWS-managed: automatic yearly rotation, less configurable
- Customer-managed: flexible management, manual or automatic rotation possible
- Advantages:
- Key usage can be logged and audited (e.g., via CloudTrail)
- Supports role separation: S3 admins cannot decrypt objects they did not create
- Allows use of other encryption algorithms if required
- Limitations:
- Higher administrative overhead compared to SSE-S3
- Keys remain hosted within AWS
SSE-C

- S3 encrypts objects using customer-provided keys
- Clients must supply the key for each operation
- KMS is not involved
- S3 performs the encryption operation and discards the key
- Key hash is stored with the encrypted object to verify future decryption attempts
- Advantages:
- Keys are never stored in AWS
- Supports role separation: only the client can access objects
- Offloads encryption work from client while maintaining key control
- Limitations:
- More administrative effort than SSE-KMS
- AWS performs encryption operations with your key temporarily; if complete separation is required, only CSE ensures no AWS exposure
Summary Table for S3 Encryption At Rest
| S3 Encryption Method | Key Management | Cryptographic Processing | Notes / Extras |
|---|---|---|---|
| SSE-S3 | Managed by S3 | Encryption/decryption handled by S3 | – No control over keys – No role separation |
| SSE-KMS | Managed by KMS (AWS or customer) | S3 performs crypto operations using KMS keys | – Key rotation control – Supports role separation and auditing |
| SSE-C | Provided by customer | S3 uses customer key for crypto ops | – Keys never stored in AWS – Supports role separation |
| CSE (Client-Side Encryption) | Customer | Encryption/decryption handled by client | – S3 only stores ciphertext – AWS never sees plaintext |
S3 Bucket Keys
Scaling Challenges with S3 SSE-KMS
- In standard SSE-KMS, each object upload requires generating a unique DEK via
kms:GenerateDataKey→ one KMS API call per object.- This can become costly at high upload rates (e.g., tens of thousands of objects per second).
- The
kms:GenerateDataKeyoperation has throttling limits.- Max PUTs per second per KMS key is finite, which can constrain large-scale workloads.
S3 Bucket Keys for SSE-KMS
- Bucket keys are temporary keys created by a KMS key to generate DEKs for all objects in a bucket.
- This reduces KMS API calls and lowers costs at scale.
- Benefits:
- Significantly fewer KMS calls: only one call to create the bucket key; subsequent DEKs are generated locally by S3.
- CloudTrail logging is consolidated per bucket: object-level DEK generation is no longer logged, reducing log volume.
- Limitations:
- Not retroactive: existing objects encrypted before enabling bucket keys won’t benefit.
- Compatibility:
- Works with S3 Replication (SRR and CRR).
- Encryption configuration is preserved in the target bucket.
- ETag nuance: replicated objects may have changed ETags if bucket keys are used, but this is mostly irrelevant now that plaintext storage is disallowed.
S3 Object Storage Classes
Overview of S3 Storage and Classes
- S3 provides cost-effective storage and multiple storage classes to optimize costs and performance.
- Each class represents a tradeoff between storage cost, retrieval speed, and data redundancy.
Key S3 characteristics:
- 11 nines of durability (99.999999999%)
- For 10 million objects, expect 1 object loss every 10,000 years.
- PUT confirmation (
HTTP/1.1 200 OK) ensures durable storage.
- Checksums (Content-MD5 & CRCs) detect and repair data corruption.
- Data replication across at least 3 AZs ensures regional resilience.
- Exception: One-Zone Infrequent Access (1Z-IA).
- Low first-byte latency (milliseconds) for most classes, except archival.
- Objects can be made public via URLs or static website hosting.
Billing overview:
- Storage fee: $/GB per month, depends on storage class.
- Data transfer OUT: ~$0.01/GB; transfer IN is free.
- Request fee: per 1,000 requests.
- Additional fees may apply for retrieval, minimum duration, or minimum object size depending on class.
S3 storage classes:
- “Warm” storage (frequent or infrequent access):
- Standard, Standard-IA, One-Zone-IA
- “Cold” storage (archival):
- Glacier Instant Retrieval (IR), Glacier Flexible Retrieval (FR), Glacier Deep Archive (DA)
- Intelligent-Tiering:
- Automatically moves objects between tiers based on access patterns.
S3 Standard (Default)

- Default class for frequently-accessed, critical data.
- Balanced in features and cost: no retrieval fees, no minimum storage duration, no minimum object size.
- Suitable for most workloads requiring high durability and low latency.
S3 Standard-Infrequent Access (IA)

- About half the storage cost of Standard, but incurs retrieval fees and minimum charges.
- Designed for data accessed rarely (~1x/month) but still important.
- Minimum duration: 30 days; minimum object size: 128 KB.
- Good for cost-efficient storage of long-lived, infrequently-accessed data.
S3 One Zone-Infrequent Access (1Z-IA)

- Lower storage cost than Standard or Standard-IA.
- Stores data in only one AZ (no multi-AZ replication).
- Suitable for replaceable, infrequently-accessed data.
- Same retrieval fee, minimum duration (30 days), and minimum object size (128 KB) as Standard-IA.
- Use cases: secondary copies, intermediate processing data, or data that can be regenerated.
S3 Glacier Instant Retrieval (IR)

- Cheaper than Standard-IA with higher retrieval cost.
- Minimum storage duration: 90 days.
- Designed for rarely-accessed, irreplaceable data.
- Provides millisecond first-byte latency, making it suitable for data that requires instant access.
S3 Glacier Flexible Retrieval (FR)

- About 1/6th the cost of Standard, intended for archival purposes.
- Cold storage: objects are not immediately accessible; only metadata is stored in S3.
- Retrieval options: Expedited (1–5 mins), Standard (3–5 hrs), Bulk (5–12 hrs).
- Minimum size: 40 KB; minimum duration: 90 days.
- Best for long-term archival data accessed infrequently.
S3 Glacier Deep Archive (DA)

- Lowest cost storage, for data rarely accessed.
- Objects stored in a “frozen” state; retrieval can take hours to days.
- Minimum size: 40 KB; minimum duration: 180 days.
- Suitable for regulatory compliance and secondary backups, not primary backups.
- Retrieval types: Standard (12 hrs), Bulk (up to 48 hrs).
S3 Intelligent-Tiering

- Automatically moves objects between storage tiers based on access frequency.
- Reduces administrative overhead for long-lived data with changing or unknown access patterns.
- Tiers: Frequent Access, IA, Archive-IA, Archive-Access, Deep Archive.
- Bottom two tiers do not provide instant retrieval; data is retrieved asynchronously.
- Monitoring and migration incur a small management fee per 1,000 objects.
- No retrieval fee for accessing objects.
S3 Lifecycle Configuration
S3 Lifecycle Management, Configuration, and Rules

- S3 Lifecycle Rules allow automatic transition or expiration of objects/versions in a bucket after a defined period, helping to optimize costs for large buckets.
- Rules consist of conditions and actions, and they can apply to a whole bucket or specific groups of objects (defined by prefix or tags).
Action Types
- Transition Actions
- Move objects to a different storage class after a specified time.
- Example: Move objects to Glacier-IR 30 days after creation.
- Expiration Actions
- Automatically delete objects or previous versions.
- Example: Delete previous versions on the first of each month.
Important: Conditions are not based on object access or usage.
- For usage-based management, rely on S3 Intelligent-Tiering instead.
- Lifecycle rules are ideal for objects with predictable, time-based behavior.
Transition Flow
- S3 transitions follow a waterfall model:
Std → Std-IA → Intelligent-Tiering → 1Z-IA → Glacier-IR → Glacier-FR → Glacier-DA
- Objects can only move downward/right in this hierarchy.
- You cannot automatically move objects upward/left (e.g., Std-IA → Std).
- Manual reclassification is always possible via Console, CLI, or API.
Exceptions:
- Cannot transition directly from 1Z-IA to Glacier-IR.
- Usually, objects progress sequentially, but skipping tiers is possible.
Key Considerations
- Cost for small objects: Transitioning small objects from Std → IA or Intelligent-Tiering may increase storage cost.
- Minimum duration rules:
- Objects must remain in Standard at least 30 days before moving to Std-IA, 1Z-IA, or Intelligent-Tiering via lifecycle rules.
- If the same rule transitions from Std → IA and then IA → Glacier, objects must stay in IA for an additional 30 days before moving to Glacier.
- Using multiple rules can bypass this restriction.
- Lifecycle rules are most effective for objects with consistent time-based patterns, not for access-based patterns.
S3 Replication
S3 Replication – Overview
- S3 replication automatically copies and syncs objects from a source (SRC) bucket to a destination (DST) bucket.
Replication Types:
- By region:
- Same-Region Replication (SRR) – SRC and DST in the same region.
- Cross-Region Replication (CRR) – SRC and DST in different regions.
- By account:
- Same-Account Replication – both buckets in the same account.
- Cross-Account Replication – buckets in different accounts.
Use Cases:
- SRR:
- Aggregate logs or audit data into one bucket.
- Sync data between TEST & PROD environments.
- Improve resilience while keeping data within a single region.
- CRR:
- Provide disaster recovery in a different region.
- Reduce latency by placing data closer to end-users.
S3 Replication – Architecture
- S3 needs an IAM role with permission to read from SRC and write to DST.
- Same account: DST bucket automatically trusts the role.
- Cross-account: DST bucket must explicitly trust the role from the external account via bucket policy.
S3 Replication – Features
- Replicate all objects (default) or a subset (filtered by prefix or tags).
- Can select the storage class for replicated objects in DST (default = same as SRC).
- Ownership:
- Default: replicated objects are owned by SRC account.
- For cross-account replication, you may need to change ownership to DST account.
- Replication Time Control (RTC):
- 15-minute SLA, disabled by default.
- Provides metrics and faster replication but incurs extra cost.
S3 Replication – Considerations & Limitations
- One-way replication by default; bi-directional is possible.
- Not retroactive: only replicates new objects by default; use Batch Replication for existing objects.
- Versioning required on both SRC and DST buckets.
- Works with all encryption types (SSE-C, SSE-S3, SSE-KMS), but SSE-KMS requires extra configuration.
- SRC account must have access to all objects for replication.
- Only user-generated events are replicated; lifecycle transitions are not replicated.
- Objects in Glacier-FR or Glacier-DA are not replicated.
- Deletes are not replicated by default; enable
DeleteMarkerReplicationif needed. - No replication chaining: objects from bucket 1 → bucket 2 do not automatically replicate to bucket 3.
S3 Presigned URLs
Limitations of Anonymous S3 Access to Private Resources
- S3 objects can typically be accessed using:
- IAM users – require authentication and authorization with long-term credentials.
- IAM roles – require assuming a role and using temporary credentials.
- Public buckets – allow anonymous access without authentication.

- Challenge:
- How to share private or sensitive objects without requiring users to authenticate to AWS?
- IAM-based access requires identity management and may not provide a smooth user experience.
- Making the bucket public is not acceptable for restricted content.
- Solution: Presigned URLs
S3 Presigned URL – Architecture

- Presigned URLs allow temporary access to private S3 objects using the permissions of an IAM identity.
How it works:
- An IAM user or role calls
generatePreSignedURLand provides:- Credentials
- Expiration time
- Object key
- Operation type (GET for download or PUT for upload)
- S3 returns a presigned URL, which can be shared with external users.
- The recipient uses the URL to access S3 without direct authentication.
- The request is executed as if performed by the IAM identity that generated the URL.
- Authorization data is embedded in the URL.
- Actions performed are logged under that IAM identity.
- Security:
- The URL is valid only for a limited time and expires automatically.
Common Use Cases of Presigned URLs
- Secure sharing of private content
- Applications can provide temporary access to uploaded or processed files.
- Offloading uploads/downloads to S3
- Clients interact directly with S3 instead of routing data through application servers.

- Serverless architectures
- Avoid running backend servers just to manage access to S3 objects.
Presigned URL – Important Behaviors
- Avoid using IAM roles to generate presigned URLs when possible:
- The URL becomes invalid when the role’s temporary credentials expire, which may happen before the URL’s configured expiration.
- Permissions are evaluated at request time, not at creation time:
- If the IAM identity loses access after generating the URL, the URL will no longer work.
- A presigned URL can be generated even if:
- The IAM identity does not currently have access to the object.
- The object does not exist yet.
- The IAM identity has no S3 permissions at all.
AccessDenied). - Error behavior:
AccessDenied→ IAM identity lacks required permissions.NoSuchKey→ Object does not exist.
S3 Select and Glacier Select
S3/Glacier Select – Overview

- Retrieving large objects from S3 can be inefficient:
- Downloading very large files (e.g., multiple TBs) takes significant time.
- Data transfer costs apply to the entire object size.
- Performing filtering on the client side is not effective:
- The full object must still be downloaded before filtering.
- This results in unnecessary time and cost.
- S3 Select and Glacier Select allow retrieval of only specific portions of an object instead of downloading the entire file.
- Filtering is performed server-side using SQL-like expressions.
Key Features
- Improves performance and cost efficiency:
- Can be up to 4× faster and reduce costs by up to 80% compared to client-side filtering.
- Supported formats:
- CSV
- JSON
- Parquet
- Compression support: BZIP2 (for CSV and JSON)
- Flexible solution for processing structured data stored in S3 or Glacier.
- Not enabled by default and must be explicitly configured before use.
S3 Events
S3 Events – Architecture

- S3 Event Notifications allow you to receive alerts when specific actions occur in a bucket.
- Examples include object creation and deletion.
- Commonly used to build event-driven architectures (EDA).
- When an event occurs, S3 sends a JSON message to the configured destination.
- Configuration is done by updating the bucket’s notification subresource:
Configuration Components
- Event destinations:
- AWS Lambda
- Amazon SQS
- Amazon SNS
- Each destination must have a resource policy that allows S3 to send events.
- Event types:
- Object creation (
Put,Post,Copy,CompleteMultipartUpload) - Object deletion (
Delete,DeleteMarkerCreated) - Object restore (from Glacier storage classes)
- Replication events (e.g., success, failure, threshold delays)
- Object creation (
Key Consideration
- S3 Event Notifications is a basic and older mechanism for event handling.
- Amazon EventBridge is generally preferred for modern event-driven designs because it:
- Supports a wider range of event sources
- Provides more flexible routing and filtering
- Integrates with a larger set of targets
S3 Access Logs
S3 Server Access Logging – Architecture

- S3 Server Access Logging provides detailed records of requests made to a bucket and its objects, helping improve visibility and auditing.
- Logs are delivered to a separate target bucket.
Log Structure
- Log files contain multiple log records, each on a new line.
- Each record includes fields such as date, time, request type, and status code.
- Fields are space-delimited, similar in format to Apache access logs.
Logging Process
- Logging is handled by the S3 Log Delivery Group, an AWS-managed background service.
- Log delivery operates on a best-effort basis and is not real-time.
- Delivery may take several hours.
Configuration
1. Source Bucket
- Enable logging using:
- AWS Management Console, or
PUT Bucket Loggingvia CLI/API
- Specify:
- Target bucket
- Optional prefix to organize logs
- A single target bucket can store logs from multiple source buckets using different prefixes.
2. Target Bucket
- Must grant write permissions to the S3 Log Delivery Group (typically via bucket ACL).
Important Considerations
- Log lifecycle is not managed automatically:
- You should configure lifecycle rules to transition or delete old logs.
- Logs are intended for analysis, not real-time monitoring.
Common Use Cases
- Auditing and security analysis
- Analyzing access patterns and usage trends
- Investigating unexpected S3 cost changes
S3 Object Lock
S3 Object Lock – Key Concepts
- S3 Object Lock is used to protect object versions from being deleted or overwritten, either temporarily or permanently.
- Enables a Write-Once-Read-Many (WORM) model.
- Can be applied to individual objects or set as a default at the bucket level.
- Two main mechanisms (can be used together):
- Legal Hold
- Retention Period (Governance mode or Compliance mode)
Important Considerations
- Versioning must be enabled, since Object Lock applies to object versions.
- Best enabled during bucket creation.
- Enabling it on an existing bucket requires contacting AWS Support.
- Once enabled:
- Object Lock cannot be disabled
- Versioning cannot be turned off
S3 Object Lock – Legal Hold
- Each object version has a boolean flag indicating whether a legal hold is active.
- No expiration is associated with this lock.
- The lock remains until it is manually removed.
- Operation used:
s3:PutObjectLegalHold
Use Cases
- Prevent accidental deletion or modification of specific object versions.
- Mark certain versions as critical or under legal review.
S3 Object Lock – Retention Period
- Locks an object version for a defined time period (in days or years).
- During this period, the object version cannot be modified or deleted.
- After expiration, normal operations are allowed again.
- Configured using
put-object-lock-configurationwith a required mode.
Retention Modes
1. Governance Mode
- Provides protection but allows authorized users to override the lock.
- Requires special permission:
s3:BypassGovernanceRetention. - Requests must also include the header:
x-amz-bypass-governance-retention:true
- Note:
- The AWS Management Console automatically includes this header, so users with permission can bypass the lock through the UI.
Use Cases:
- Prevent accidental deletion or modification via CLI/SDK.
- Testing retention policies before enforcing stricter controls.
2. Compliance Mode
- Provides strict, non-bypassable protection for the duration of the retention period.
- Object versions cannot be modified, deleted, or unlocked, even by the root user.
Use Cases:
- Regulatory or legal requirements requiring fixed data retention (e.g., financial or medical records).
S3 Access Points
Scaling Limitations for Granular Configurations in S3 Buckets
- Large S3 buckets may require fine-grained access control across different teams, applications, or use cases.
- Relying on bucket policies alone does not scale well:
- Policies can become overly large and complex.
- Managing multiple overlapping permissions becomes difficult.
- Increased risk of misconfiguration due to policy complexity.
- A more scalable approach is to use S3 Access Points, assigning one per team, application, or use case.
S3 Access Points – Architecture
- S3 Access Points provide logical views into a bucket, allowing access to specific subsets of objects.
- Each access point has its own DNS endpoint and independent access controls.
- Benefits:
- Simplifies management of large buckets.
- Enables separation of access by team or application.
- Creation:
- CLI:
aws s3control create-access-point --name <name> --account-id <id> - Can also be created via the AWS Management Console.
- CLI:
Access Point Policies
- Each access point has its own policy that controls access to its specific subset of objects.
- Similar to a bucket policy, but limited to that access point’s scope.
- Recommended design:
- Use the bucket policy to allow broad access, typically requiring access through access points.
- Use access point policies for fine-grained permission control.
- This approach:
- Reduces overall policy complexity.
- Enables delegation of access management to different teams.
Network Access Control
- Access points can be configured to allow access only from a specific VPC.
- Access is enforced using a VPC Endpoint (VPCE) and its associated policy.
LAB: S3 Multi-Region Access Point (MRAP)
S3 Multi-Region Access Point (MRAP) – Overview
- S3 MRAP provides a single global endpoint that automatically routes requests to the nearest available bucket.
- Key characteristics:
- Combines multiple S3 buckets across different regions.
- Routes requests (GET, PUT, etc.) based on lowest network latency.
- Once created, buckets cannot be added or removed from the MRAP.
- Replication support:
- Buckets can be configured to replicate data one-way or bidirectionally.
- Failover capability:
- Traffic is directed to active buckets.
- If a region becomes unavailable, requests are routed to a failover bucket in another region.
Stage 1 – Create an MRAP
- Create two S3 buckets in different regions (e.g., Canada and Sydney).
- Enable versioning on both buckets.
- In S3:
- Navigate to Multi-Region Access Points → Create
- Add both buckets to the MRAP
- Use default settings for the remaining configuration
- Notes:
- MRAP setup typically takes under 30 minutes, but can take up to 24 hours.
Stage 2 – Configure Replication
- Open the MRAP → Replication and failover → Create replication rules
- Configuration:
- Select replicate across all buckets
- Apply replication to all objects
- Result:
- Objects uploaded to one bucket are automatically replicated to the other bucket(s)
Stage 3 – Test the MRAP
Preparation
- Open each bucket in separate tabs
- Keep the MRAP ARN available
- Use AWS CloudShell in different regions
Test Process
- Create a test file: dd if=/dev/urandom of=<file_name> bs=1M count=10
- Upload to MRAP: aws s3 cp <file_name> s3://<MRAP_ARN>
- Observe which bucket receives the file first
Test Scenarios
- From Tokyo:
- File is stored first in the Sydney bucket (closest region)
- Then replicated to Canada
- From Ohio:
- File is stored first in the Canada bucket
- Not immediately available in Sydney
- Eventually replicated
- From Mumbai:
- Initial bucket selection may vary
- Depends on latency and real-time network conditions
Key Insight
- Replication across regions is not instantaneous.
- Applications must be designed to handle replication delay in global architectures.
Stage 4 – Cleanup
- Delete the MRAP
- Empty and delete the associated S3 buckets