Skip to main content

Amazon S3 - Interview Preparation

Total Questions: 213 Levels: Core Fundamentals (100), Intermediate (120), Advanced (80)


Table of Contents​

  1. Core Fundamentals
  2. Intermediate Topics
  3. Additional Core Questions Summary
  4. Senior / Principal — Real World S3 Scenarios
  5. Senior / Principal — Amazon S3 Real World Scenarios (Continued)

1. Core Fundamentals​

Q1: What is Amazon S3 and what are its storage classes?​

Technical Answer: Amazon S3 provides object storage with 99.999999999% (11 9s) durability.

Storage Classes:

ClassUse CaseDurabilityAvailability
S3 StandardFrequently accessed11 9s99.99%
S3 Intelligent-TieringUnknown patterns11 9s99.9%
S3 Standard-IAInfrequent access11 9s99.9%
S3 One Zone-IAInfrequent, single AZ11 9s99.5%
S3 Glacier IRArchive, instant retrieval11 9s99.9%
S3 GlacierArchive, minutes-hours11 9s99.99%
S3 Glacier DeepRarely accessed11 9s99.9%

Basic Operations:

import boto3
import json

s3 = boto3.client('s3')

# Create bucket
s3.create_bucket(
Bucket='my-app-bucket',
CreateBucketConfiguration={'LocationConstraint': 'us-west-2'}
)

# Enable versioning
s3.put_bucket_versioning(
Bucket='my-app-bucket',
VersioningConfiguration={'Status': 'Enabled'}
)

# Enable encryption
s3.put_bucket_encryption(
Bucket='my-app-bucket',
ServerSideEncryptionConfiguration={
'Rules': [{
'ApplyServerSideEncryptionByDefault': {
'SSEAlgorithm': 'aws:kms',
'KMSMasterKeyID': 'arn:aws:kms:us-west-2:123456789:key/123'
},
'BucketKeyEnabled': True
}]
}
)

# Upload with storage class
s3.put_object(
Bucket='my-app-bucket',
Key='documents/report.pdf',
Body=open('report.pdf', 'rb'),
StorageClass='STANDARD_IA',
ServerSideEncryption='aws:kms'
)

# Generate presigned URL
url = s3.generate_presigned_url(
'get_object',
Params={'Bucket': 'my-app-bucket', 'Key': 'documents/report.pdf'},
ExpiresIn=3600
)

🔍 Interviewer Notes: Testing storage optimization and cost management.

❌ Common Mistakes:

  • Using Standard for all objects
  • Not enabling versioning
  • Wrong storage class for access patterns

Q2: How do you secure S3 buckets?​

Technical Answer: S3 security uses bucket policies, ACLs, encryption, and access logging.

Bucket Policy:

import boto3
import json

s3 = boto3.client('s3')

bucket_policy = {
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyInsecureTransport",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::my-app-bucket",
"arn:aws:s3:::my-app-bucket/*"
],
"Condition": {
"Bool": {"aws:SecureTransport": "false"}
}
},
{
"Sid": "DenyUnencryptedUploads",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::my-app-bucket/*",
"Condition": {
"StringNotEquals": {
"s3:x-amz-server-side-encryption": "aws:kms"
}
}
},
{
"Sid": "AllowSpecificRoles",
"Effect": "Allow",
"Principal": {"AWS": [
"arn:aws:iam::123456789:role/AppServerRole"
]},
"Action": ["s3:GetObject", "s3:PutObject"],
"Resource": "arn:aws:s3:::my-app-bucket/*",
"Condition": {
"StringEquals": {"aws:SourceVpc": "vpc-123456789"}
}
}
]
}

s3.put_bucket_policy(
Bucket='my-app-bucket',
Policy=json.dumps(bucket_policy)
)

Block Public Access:

s3.put_public_access_block(
Bucket='my-app-bucket',
PublicAccessBlockConfiguration={
'BlockPublicAcls': True,
'IgnorePublicAcls': True,
'BlockPublicPolicy': True,
'RestrictPublicBuckets': True
}
)

🔍 Interviewer Notes: Testing security best practices.

❌ Common Mistakes:

  • Not blocking public access
  • Using ACLs instead of bucket policies
  • Not enforcing encryption in transit

Q3: How do you implement S3 lifecycle policies?​

Technical Answer: Lifecycle policies automatically transition or delete objects based on age.

import boto3
import json

s3 = boto3.client('s3')

lifecycle_policy = {
"Rules": [
{
"ID": "TransitionToIA",
"Status": "Enabled",
"Filter": {"Prefix": "logs/"},
"Transitions": [
{"Days": 30, "StorageClass": "STANDARD_IA"},
{"Days": 90, "StorageClass": "GLACIER_IR"},
{"Days": 365, "StorageClass": "DEEP_ARCHIVE"}
]
},
{
"ID": "DeleteOldLogs",
"Status": "Enabled",
"Filter": {"Prefix": "logs/temp/"},
"Expiration": {"Days": 7}
},
{
"ID": "CleanupMultipartUploads",
"Status": "Enabled",
"Filter": {"Prefix": ""},
"AbortIncompleteMultipartUpload": {
"DaysAfterInitiation": 7
}
},
{
"ID": "VersionManagement",
"Status": "Enabled",
"Filter": {"Prefix": "documents/"},
"NoncurrentVersionTransitions": [
{"NoncurrentDays": 30, "StorageClass": "STANDARD_IA"}
],
"NoncurrentVersionExpiration": {"NoncurrentDays": 90}
}
]
}

s3.put_bucket_lifecycle_configuration(
Bucket='my-app-bucket',
LifecycleConfiguration=lifecycle_policy
)

Intelligent-Tiering:

s3.put_object(
Bucket='my-app-bucket',
Key='data/dataset.parquet',
Body=open('dataset.parquet', 'rb'),
StorageClass='INTELLIGENT_TIERING'
)

# Configure archive settings
s3.put_bucket_intelligent_tiering_configuration(
Bucket='my-app-bucket',
Id='ArchiveAfter1Year',
IntelligentTieringConfiguration={
'Status': 'Enabled',
'Tierings': [
{'Days': 90, 'AccessTier': 'ARCHIVE_ACCESS'},
{'Days': 365, 'AccessTier': 'DEEP_ARCHIVE_ACCESS'}
]
}
)

🔍 Interviewer Notes: Testing cost optimization.


Q4: How do you handle large file uploads to S3?​

Technical Answer: Use multipart upload for large files.

import boto3
import os
from concurrent.futures import ThreadPoolExecutor

s3 = boto3.client('s3')

bucket = 'my-app-bucket'
key = 'large-files/100gb-file.bin'
file_path = '/path/to/large/file'

# Start multipart upload
response = s3.create_multipart_upload(
Bucket=bucket,
Key=key,
StorageClass='STANDARD'
)
upload_id = response['UploadId']

# Upload parts
part_size = 100 * 1024 * 1024 # 100MB
file_size = os.path.getsize(file_path)
num_parts = (file_size + part_size - 1) // part_size

parts = []

def upload_part(part_number):
start = (part_number - 1) * part_size
end = min(start + part_size, file_size)

with open(file_path, 'rb') as f:
f.seek(start)
data = f.read(end - start)

response = s3.upload_part(
Bucket=bucket,
Key=key,
UploadId=upload_id,
PartNumber=part_number,
Body=data
)

return {'PartNumber': part_number, 'ETag': response['ETag']}

# Parallel upload
with ThreadPoolExecutor(max_workers=10) as executor:
parts = list(executor.map(upload_part, range(1, num_parts + 1)))

# Complete upload
s3.complete_multipart_upload(
Bucket=bucket,
Key=key,
UploadId=upload_id,
MultipartUpload={'Parts': parts}
)

Transfer Acceleration:

# Enable transfer acceleration
s3.put_bucket_accelerate_configuration(
Bucket='my-app-bucket',
AccelerateConfiguration={'Status': 'Enabled'}
)

# Use accelerated endpoint
s3.upload_file(
'large-file.zip',
'my-app-bucket',
'large-file.zip',
ExtraArgs={'ServerSideEncryption': 'AES256'},
Config=boto3.s3.transfer.TransferConfig(use_threads=True)
)

🔍 Interviewer Notes: Testing large file handling.


Q5: What is S3 Select and how do you use it?​

Technical Answer: S3 Select retrieves only a subset of data from an object using SQL.

import boto3

s3 = boto3.client('s3')

# Query CSV
response = s3.select_object_content(
Bucket='my-app-bucket',
Key='large-dataset.csv',
Expression="SELECT * FROM s3object WHERE age > 30",
ExpressionType='SQL',
InputSerialization={'CSV': {'FileHeaderInfo': 'USE'}},
OutputSerialization={'JSON': {}}
)

for event in response['Payload']:
if 'Records' in event:
print(event['Records']['Payload'].decode('utf-8'))

🔍 Interviewer Notes: Testing data retrieval optimization.


Q6: How do you implement S3 versioning?​

Technical Answer: Versioning keeps multiple versions of an object for backup and recovery.

import boto3

s3 = boto3.client('s3')

# Enable versioning
s3.put_bucket_versioning(
Bucket='my-bucket',
VersioningConfiguration={'Status': 'Enabled'}
)

# List versions
versions = s3.list_object_versions(Bucket='my-bucket', Prefix='file.txt')
for v in versions.get('Versions', []):
print(f"Version: {v['VersionId']}, IsLatest: {v['IsLatest']}")

🔍 Interviewer Notes: Testing data protection strategies.

❌ Common Mistakes:

  • Not enabling versioning for critical data
  • Not managing version storage costs

Q7: How do you configure S3 bucket policies?​

Technical Answer: Bucket policies specify access permissions for buckets and objects.

# Require HTTPS only
https_policy = {
"Version": "2012-10-17",
"Statement": [{
"Sid": "ForceHTTPS",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": "arn:aws:s3:::my-bucket/*",
"Condition": {
"Bool": {"aws:SecureTransport": "false"}
}
}]
}

🔍 Interviewer Notes: Testing IAM policy knowledge.

❌ Common Mistakes:

  • Using Principal "*" without conditions
  • Not testing policies before applying

Q8: How do you use S3 pre-signed URLs?​

Technical Answer: Pre-signed URLs grant temporary access to private objects.

import boto3

s3 = boto3.client('s3')

# Generate download URL
url = s3.generate_presigned_url(
'get_object',
Params={'Bucket': 'my-bucket', 'Key': 'file.pdf'},
ExpiresIn=300 # 5 minutes
)

# Generate upload URL
post_url = s3.generate_presigned_post(
Bucket='my-bucket',
Key='uploads/${filename}',
Fields={'acl': 'private'},
Conditions=[["content-length-range", 0, 10485760]],
ExpiresIn=600
)

🔍 Interviewer Notes: Testing secure access patterns.

❌ Common Mistakes:

  • URLs with excessive expiration time
  • Not validating file types for uploads

Q9: How do you implement S3 Static Website Hosting?​

Technical Answer: S3 can host static websites directly with custom domains.

s3.put_bucket_website(
Bucket='my-website',
WebsiteConfiguration={
'IndexDocument': {'Suffix': 'index.html'},
'ErrorDocument': {'Key': 'error.html'}
}
)

Note: Use CloudFront in front for HTTPS and custom domains.

🔍 Interviewer Notes: Testing static hosting and CDN integration.

❌ Common Mistakes:

  • Not using CloudFront for HTTPS
  • Wrong bucket name for Route 53

Q10: How do you enable S3 access logging?​

Technical Answer: Access logging records all requests to a bucket for audit.

s3.put_bucket_logging(
Bucket='source-bucket',
BucketLoggingStatus={
'LoggingEnabled': {
'TargetBucket': 'logs-bucket',
'TargetPrefix': 's3-access-logs/'
}
}
)

🔍 Interviewer Notes: Testing audit capabilities.

❌ Common Mistakes:

  • Not setting lifecycle policy on logs
  • Not using Athena for analysis

Q11: What are S3 storage classes and when should you use each?​

Technical Answer: S3 offers 7 storage classes optimized for different access patterns and cost requirements. S3 Standard for frequent access, Standard-IA for infrequent access, Intelligent-Tiering for unknown patterns, One Zone-IA for non-critical data, and Glacier classes for archival.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Upload with different storage classes
storage_classes = {
'frequent-access.log': 'STANDARD',
'monthly-report.pdf': 'STANDARD_IA',
'unknown-pattern.bin': 'INTELLIGENT_TIERING',
'temp-cache.dat': 'ONEZONE_IA',
'compliance-doc.pdf': 'GLACIER_IR',
'old-archive.zip': 'GLACIER',
'regulatory-data.tar': 'DEEP_ARCHIVE'
}

for key, storage_class in storage_classes.items():
s3.put_object(
Bucket='my-bucket',
Key=key,
Body=b'data',
StorageClass=storage_class
)

# Restore from Glacier
s3.restore_object(
Bucket='my-bucket',
Key='old-archive.zip',
RestoreRequest={
'Days': 7, # Keep in temporary copy
'GlacierJobParameters': {'Tier': 'Standard'} # or 'Bulk', 'Expedited'
}
)

🔍 Interviewer Notes: Tests understanding of cost optimization and access patterns.

❌ Common Mistakes:

  • Using Standard for all data regardless of access pattern
  • Not considering retrieval costs for Glacier
  • Choosing Glacier Deep Archive for data needed quickly

Q12: How does S3 Intelligent-Tiering work?​

Technical Answer: Intelligent-Tiering automatically moves objects between Frequent, Infrequent, and Archive Access tiers based on access patterns. It monitors access and moves data to cheaper tiers after 30 and 90 days of no access, with no retrieval fees for tier changes.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Upload to Intelligent-Tiering
s3.put_object(
Bucket='my-bucket',
Key='dataset.parquet',
Body=open('dataset.parquet', 'rb'),
StorageClass='INTELLIGENT_TIERING'
)

# Configure archive access tiers (optional)
s3.put_bucket_intelligent_tiering_configuration(
Bucket='my-bucket',
Id='archive-config',
IntelligentTieringConfiguration={
'Status': 'Enabled',
'Tierings': [
{'Days': 90, 'AccessTier': 'ARCHIVE_ACCESS'},
{'Days': 180, 'AccessTier': 'DEEP_ARCHIVE_ACCESS'}
]
}
)

🔍 Interviewer Notes: Tests knowledge of automated cost optimization.

❌ Common Mistakes:

  • Thinking there are retrieval fees for tier changes
  • Not understanding the 30/90 day thresholds
  • Using for small objects (monitoring fee applies per object)

Q13: How do you enable and manage S3 versioning?​

Technical Answer: Versioning keeps all versions of an object in a bucket, allowing recovery from deletes and overwrites. Once enabled, versioning cannot be disabled—only suspended. Each version is identified by a unique VersionId.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Enable versioning
s3.put_bucket_versioning(
Bucket='my-bucket',
VersioningConfiguration={'Status': 'Enabled'}
)

# List all versions
response = s3.list_object_versions(Bucket='my-bucket', Prefix='file.txt')
for version in response.get('Versions', []):
print(f"Version: {version['VersionId']}, LastModified: {version['LastModified']}")

# Delete specific version (permanent delete)
s3.delete_object(
Bucket='my-bucket',
Key='file.txt',
VersionId='version-id-here'
)

# Get specific version
response = s3.get_object(
Bucket='my-bucket',
Key='file.txt',
VersionId='version-id-here'
)

🔍 Interviewer Notes: Tests data protection and recovery strategies.

❌ Common Mistakes:

  • Thinking versioning can be disabled (only suspended)
  • Not managing storage costs of old versions
  • Not enabling versioning before replication

Q14: How do you configure S3 lifecycle policies?​

Technical Answer: Lifecycle policies automate transitioning objects to cheaper storage classes and expiring objects after specified periods. Policies use rules with filters, transitions, and expiration actions, and support versioned and non-versioned buckets.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

lifecycle_config = {
'Rules': [
{
'ID': 'LogManagement',
'Status': 'Enabled',
'Filter': {'Prefix': 'logs/'},
'Transitions': [
{'Days': 30, 'StorageClass': 'STANDARD_IA'},
{'Days': 90, 'StorageClass': 'GLACIER_IR'},
{'Days': 365, 'StorageClass': 'DEEP_ARCHIVE'}
],
'Expiration': {'Days': 2555} # 7 years
},
{
'ID': 'DeleteIncompleteMultipart',
'Status': 'Enabled',
'Filter': {'Prefix': ''},
'AbortIncompleteMultipartUpload': {'DaysAfterInitiation': 7}
}
]
}

s3.put_bucket_lifecycle_configuration(
Bucket='my-bucket',
LifecycleConfiguration=lifecycle_config
)

🔍 Interviewer Notes: Tests automation and cost management skills.

❌ Common Mistakes:

  • Not setting Filter when transitioning versioned objects
  • Forgetting to handle incomplete multipart uploads
  • Transitioning to Glacier before 30 days (minimum storage duration)

Q15: How does S3 encryption work (SSE-S3, SSE-KMS, SSE-C)?​

Technical Answer: S3 supports three server-side encryption modes: SSE-S3 (Amazon-managed keys), SSE-KMS (AWS KMS keys with audit trail), and SSE-C (customer-provided keys). Client-side encryption is also available for encrypting before upload.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# SSE-S3 (default, Amazon manages keys)
s3.put_object(
Bucket='my-bucket',
Key='file1.txt',
Body=b'data',
ServerSideEncryption='AES256'
)

# SSE-KMS (use KMS key)
s3.put_object(
Bucket='my-bucket',
Key='file2.txt',
Body=b'data',
ServerSideEncryption='aws:kms',
SSEKMSKeyId='arn:aws:kms:us-east-1:123456789:key/uuid'
)

# SSE-C (customer-provided key)
s3.put_object(
Bucket='my-bucket',
Key='file3.txt',
Body=b'data',
SSECustomerAlgorithm='AES256',
SSECustomerKey='32-byte-key-here-32-bytes-long!'
)

# Enable default encryption on bucket
s3.put_bucket_encryption(
Bucket='my-bucket',
ServerSideEncryptionConfiguration={
'Rules': [{
'ApplyServerSideEncryptionByDefault': {
'SSEAlgorithm': 'aws:kms',
'KMSMasterKeyID': 'arn:aws:kms:us-east-1:123456789:key/uuid'
}
}]
}
)

🔍 Interviewer Notes: Tests security and compliance knowledge.

❌ Common Mistakes:

  • Not enabling default encryption on bucket
  • Using SSE-S3 when audit trail is needed (use KMS)
  • Forgetting KMS key permissions for cross-account access

Q16: How do S3 bucket policies differ from IAM policies?​

Technical Answer: Bucket policies are resource-based policies attached to S3 buckets, supporting conditions like IP restrictions and VPC endpoints. IAM policies are identity-based and attached to users/roles. Bucket policies can grant cross-account access without IAM roles.

Code/Config Example:

import boto3
import json

s3 = boto3.client('s3')

# Bucket Policy - applies to bucket, supports conditions
bucket_policy = {
"Version": "2012-10-17",
"Statement": [
{
"Sid": "EnforceEncryption",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::my-bucket/*",
"Condition": {
"StringNotEquals": {
"s3:x-amz-server-side-encryption": "AES256"
}
}
},
{
"Sid": "AllowFromVPC",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::my-bucket/*",
"Condition": {
"StringEquals": {"aws:SourceVpc": "vpc-12345678"}
}
}
]
}

s3.put_bucket_policy(
Bucket='my-bucket',
Policy=json.dumps(bucket_policy)
)

🔍 Interviewer Notes: Tests understanding of AWS authorization models.

❌ Common Mistakes:

  • Using IAM policies when cross-account access is needed (use bucket policy)
  • Not understanding Principal in bucket policies
  • Mixing up resource-based vs identity-based policies

Q17: How does S3 Block Public Access work?​

Technical Answer: Block Public Access (BPA) is a bucket-level setting that prevents public access through ACLs, bucket policies, or access points. It can be applied at account level and overrides any conflicting settings, providing defense-in-depth against accidental exposure.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Enable all BPA settings
s3.put_public_access_block(
Bucket='my-bucket',
PublicAccessBlockConfiguration={
'BlockPublicAcls': True,
'IgnorePublicAcls': True,
'BlockPublicPolicy': True,
'RestrictPublicBuckets': True
}
)

# Account-level BPA (applies to all buckets)
s3control = boto3.client('s3control')
s3control.put_public_access_block(
AccountId='123456789',
PublicAccessBlockConfiguration={
'BlockPublicAcls': True,
'IgnorePublicAcls': True,
'BlockPublicPolicy': True,
'RestrictPublicBuckets': True
}
)

🔍 Interviewer Notes: Tests security best practices and defense-in-depth.

❌ Common Mistakes:

  • Not enabling BPA on buckets with sensitive data
  • Confusing the four different BPA settings
  • Thinking BPA breaks legitimate public access needs

Q18: How do you implement S3 multipart uploads?​

Technical Answer: Multipart upload splits large files into parts for parallel upload, improving throughput and resilience. It's recommended for files over 100MB and required for files over 5GB. Failed parts can be retried without restarting.

Code/Config Example:

import boto3
from concurrent.futures import ThreadPoolExecutor

s3 = boto3.client('s3')

def upload_large_file(bucket, key, file_path):
# Initiate multipart upload
response = s3.create_multipart_upload(
Bucket=bucket,
Key=key,
ServerSideEncryption='AES256'
)
upload_id = response['UploadId']

# Upload parts in parallel
part_size = 10 * 1024 * 1024 # 10MB parts
parts = []

def upload_part(part_num, data):
response = s3.upload_part(
Bucket=bucket,
Key=key,
UploadId=upload_id,
PartNumber=part_num,
Body=data
)
return {'PartNumber': part_num, 'ETag': response['ETag']}

with open(file_path, 'rb') as f:
with ThreadPoolExecutor(max_workers=5) as executor:
futures = []
part_num = 1
while True:
data = f.read(part_size)
if not data:
break
futures.append(executor.submit(upload_part, part_num, data))
part_num += 1
parts = [f.result() for f in futures]

# Complete multipart upload
s3.complete_multipart_upload(
Bucket=bucket,
Key=key,
UploadId=upload_id,
MultipartUpload={'Parts': sorted(parts, key=lambda x: x['PartNumber'])}
)

upload_large_file('my-bucket', 'large-file.iso', '/path/to/file.iso')

🔍 Interviewer Notes: Tests large file handling and parallel processing.

❌ Common Mistakes:

  • Not handling failed parts (abort incomplete uploads)
  • Using wrong part size (min 5MB except last part)
  • Not sorting parts by PartNumber before completing

Q19: How do you generate and use S3 presigned URLs?​

Technical Answer: Presigned URLs grant temporary access to S3 objects without AWS credentials. They can be generated for GET (download) or PUT (upload) operations with configurable expiration times. They're commonly used for user uploads/downloads in web applications.

Code/Config Example:

import boto3
from datetime import datetime, timedelta

s3 = boto3.client('s3')

# Generate presigned URL for download
download_url = s3.generate_presigned_url(
ClientMethod='get_object',
Params={'Bucket': 'my-bucket', 'Key': 'private-file.pdf'},
ExpiresIn=3600 # 1 hour
)

# Generate presigned POST for uploads
post = s3.generate_presigned_post(
Bucket='my-bucket',
Key='uploads/user123/document.pdf',
Fields={'acl': 'private', 'Content-Type': 'application/pdf'},
Conditions=[
['content-length-range', 0, 10485760], # Max 10MB
{'bucket': 'my-bucket'}
],
ExpiresIn=600 # 10 minutes
)

# Use with boto3 S3 client (for programmatic access)
s3_client = boto3.client(
's3',
endpoint_url=download_url # Not actual usage, just for illustration
)

🔍 Interviewer Notes: Tests secure access delegation patterns.

❌ Common Mistakes:

  • Setting excessive expiration times (security risk)
  • Not validating file types/sizes for uploads
  • Using presigned URLs for server-to-server transfers (use IAM roles)

Q20: How do you configure S3 event notifications?​

Technical Answer: S3 event notifications trigger AWS Lambda, SQS, or SNS when bucket events occur (object created, deleted, etc.). Events can be filtered by prefix/suffix and support multiple destinations with different filters.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

s3.put_bucket_notification_configuration(
Bucket='my-bucket',
NotificationConfiguration={
'LambdaFunctionConfigurations': [{
'Id': 'ProcessImages',
'LambdaFunctionArn': 'arn:aws:lambda:us-east-1:123456789:function:process-image',
'Events': ['s3:ObjectCreated:*'],
'Filter': {
'Key': {
'FilterRules': [
{'Name': 'prefix', 'Value': 'images/'},
{'Name': 'suffix', 'Value': '.jpg'}
]
}
}
}],
'QueueConfigurations': [{
'Id': 'QueueNotifications',
'QueueArn': 'arn:aws:sqs:us-east-1:123456789:my-queue',
'Events': ['s3:ObjectCreated:*', 's3:ObjectRemoved:*']
}]
}
)

🔍 Interviewer Notes: Tests event-driven architecture knowledge.

❌ Common Mistakes:

  • Not granting S3 permission to invoke Lambda/SQS/SNS
  • Using prefix/suffix filters incorrectly
  • Not handling duplicate events (S3 provides at-least-once delivery)

Q21: How do you use S3 Select to query data?​

Technical Answer: S3 Select enables retrieving only a subset of data from an object using SQL expressions, reducing data transfer costs. It supports CSV, JSON, and Parquet formats with various serialization options.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Query CSV file
response = s3.select_object_content(
Bucket='my-bucket',
Key='data/employees.csv',
Expression="SELECT * FROM s3object WHERE salary > 50000",
ExpressionType='SQL',
InputSerialization={
'CSV': {
'FileHeaderInfo': 'USE',
'RecordDelimiter': '\n',
'FieldDelimiter': ','
}
},
OutputSerialization={'JSON': {'RecordDelimiter': '\n'}}
)

# Process results
for event in response['Payload']:
if 'Records' in event:
print(event['Records']['Payload'].decode('utf-8'))

# Query JSON file
response = s3.select_object_content(
Bucket='my-bucket',
Key='data/users.json',
Expression="SELECT s.name, s.email FROM s3object s WHERE s.active = true",
ExpressionType='SQL',
InputSerialization={'JSON': {'Type': 'DOCUMENT'}},
OutputSerialization={'JSON': {}}
)

🔍 Interviewer Notes: Tests data retrieval optimization techniques.

❌ Common Mistakes:

  • Using S3 Select for small files (overhead not worth it)
  • Not handling large result sets properly
  • Wrong serialization format for input data

Q22: How does S3 Cross-Region Replication (CRR) work?​

Technical Answer: CRR automatically replicates objects between buckets in different AWS regions for compliance, latency reduction, or disaster recovery. Both source and destination buckets must have versioning enabled, and an IAM role is required for S3 to assume.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Configure CRR
s3.put_bucket_replication(
Bucket='source-bucket-us-east-1',
ReplicationConfiguration={
'Role': 'arn:aws:iam::123456789:role/s3-replication-role',
'Rules': [{
'ID': 'ReplicateToWest',
'Status': 'Enabled',
'Priority': 1,
'DeleteMarkerReplication': {'Status': 'Enabled'},
'Destination': {
'Bucket': 'arn:aws:s3:::dest-bucket-us-west-2',
'StorageClass': 'STANDARD_IA',
'ReplicationTime': {
'Status': 'Enabled',
'Time': {'Minutes': 15}
}
},
'Filter': {'Prefix': ''}
}]
}
)

🔍 Interviewer Notes: Tests disaster recovery and compliance patterns.

❌ Common Mistakes:

  • Not enabling versioning on both buckets
  • IAM role missing necessary permissions
  • Not replicating delete markers when needed

Q23: How does S3 Same-Region Replication (SRR) work?​

Technical Answer: SRR replicates objects within the same AWS region for log aggregation, production/staging sync, or compliance. It uses the same configuration as CRR but destination bucket is in the same region.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Configure SRR
s3.put_bucket_replication(
Bucket='prod-bucket',
ReplicationConfiguration={
'Role': 'arn:aws:iam::123456789:role/s3-replication-role',
'Rules': [{
'ID': 'AggregateLogs',
'Status': 'Enabled',
'Filter': {'Prefix': 'logs/'},
'Destination': {
'Bucket': 'arn:aws:s3:::log-archive-bucket',
'StorageClass': 'STANDARD_IA'
}
}]
}
)

🔍 Interviewer Notes: Tests understanding of replication use cases.

❌ Common Mistakes:

  • Thinking SRR and CRR require different APIs
  • Not understanding SRR use cases (log aggregation)
  • Forgetting replication time metrics

Q24: How do you implement S3 Access Points?​

Technical Answer: Access Points simplify managing access to shared datasets by providing unique hostnames with specific policies. They support VPC restrictions and can be used with Object Lambda for data transformation.

Code/Config Example:

import boto3

s3control = boto3.client('s3control')

# Create access point
response = s3control.create_access_point(
AccountId='123456789',
Name='data-science-team',
Bucket='shared-datasets',
VpcConfiguration={'VpcId': 'vpc-12345678'},
PublicAccessBlockConfiguration={
'BlockPublicAcls': True,
'IgnorePublicAcls': True,
'BlockPublicPolicy': True,
'RestrictPublicBuckets': True
}
)

# Use access point ARN
s3 = boto3.client('s3')
s3.put_object(
Bucket='arn:aws:s3:us-east-1:123456789:accesspoint/data-science-team',
Key='analysis/results.csv',
Body=b'results'
)

🔍 Interviewer Notes: Tests data lake access patterns.

❌ Common Mistakes:

  • Not using access point ARN format correctly
  • Forgetting VPC restriction configuration
  • Not understanding when to use access points vs bucket policies

Q25: How does S3 Object Lambda work?​

Technical Answer: S3 Object Lambda allows transforming objects on-the-fly using Lambda functions without storing transformed copies. It uses Access Points to intercept GetObject requests and return modified data.

Code/Config Example:

import boto3
import json

s3control = boto3.client('s3control')

# Create Object Lambda access point
s3control.create_access_point_for_object_lambda(
AccountId='123456789',
Name='redact-pii',
Configuration={
'SupportingAccessPoint': 'arn:aws:s3:us-east-1:123456789:accesspoint/original-data',
'TransformationConfigurations': [{
'Actions': ['GetObject'],
'ContentTransformation': {
'AwsLambda': {
'FunctionArn': 'arn:aws:lambda:us-east-1:123456789:function:redact-pii'
}
}
}]
}
)

# Lambda handler
def lambda_handler(event, context):
s3 = boto3.client('s3')
object_context = event['getObjectContext']

# Get original object
response = s3.get_object(
Bucket='original-data-bucket',
Key=event['userRequest']['url'].split('/')[-1]
)

# Transform (redact PII)
data = response['Body'].read().decode('utf-8')
transformed = redact_pii(data)

# Return transformed data
s3.write_get_object_response(
RequestRoute=object_context['outputRoute'],
RequestToken=object_context['outputToken'],
Body=transformed
)
return {'statusCode': 200}

🔍 Interviewer Notes: Tests advanced S3 patterns and Lambda integration.

❌ Common Mistakes:

  • Not understanding the difference from regular Access Points
  • Lambda timeout issues with large objects
  • Forgetting to write response using write_get_object_response

Q26: How do you use S3 Transfer Acceleration?​

Technical Answer: Transfer Acceleration uses CloudFront edge locations to accelerate uploads over long distances. It adds an acceleration endpoint (s3-accelerate) and can significantly improve upload speeds for geographically distributed users.

Code/Config Example:

import boto3
from boto3.s3.transfer import TransferConfig

# Enable transfer acceleration
s3 = boto3.client('s3')
s3.put_bucket_accelerate_configuration(
Bucket='my-bucket',
AccelerateConfiguration={'Status': 'Enabled'}
)

# Use acceleration endpoint
s3_accelerated = boto3.client(
's3',
endpoint_url='https://s3-accelerate.amazonaws.com'
)

# Upload with acceleration
config = TransferConfig(
multipart_threshold=8 * 1024 * 1024, # 8MB
max_concurrency=10,
use_threads=True
)

s3_accelerated.upload_file(
'/path/to/large-file.zip',
'my-bucket',
'large-file.zip',
Config=config
)

🔍 Interviewer Notes: Tests performance optimization for global applications.

❌ Common Mistakes:

  • Using for same-region transfers (slower due to extra hop)
  • Not considering cost (2x more expensive)
  • Not enabling acceleration on bucket first

Q27: How does S3 consistency model work?​

Technical Answer: S3 provides strong read-after-write consistency for all operations since December 2020. New object writes and deletes are immediately visible, and overwrite PUTs and DELETEs are strongly consistent.

Code/Config Example:

import boto3
import time

s3 = boto3.client('s3')

# Strong consistency - read after write
s3.put_object(Bucket='my-bucket', Key='test.txt', Body=b'version1')
response = s3.get_object(Bucket='my-bucket', Key='test.txt')
print(response['Body'].read()) # Immediately returns 'version1'

# Overwrite is strongly consistent
s3.put_object(Bucket='my-bucket', Key='test.txt', Body=b'version2')
response = s3.get_object(Bucket='my-bucket', Key='test.txt')
print(response['Body'].read()) # Immediately returns 'version2'

# List operations are also strongly consistent
s3.put_object(Bucket='my-bucket', Key='new-file.txt', Body=b'data')
response = s3.list_objects_v2(Bucket='my-bucket')
# New object appears immediately in list

🔍 Interviewer Notes: Tests understanding of distributed systems consistency.

❌ Common Mistakes:

  • Citing old eventual consistency model (pre-2020)
  • Not understanding strong vs eventual consistency
  • Expecting transactional ACID properties (S3 is not a database)

Q28: How do you implement S3 static website hosting?​

Technical Answer: S3 can host static websites directly with configurable index and error documents. For custom domains and HTTPS, CloudFront should be used in front of S3.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Configure static website hosting
s3.put_bucket_website(
Bucket='www.example.com',
WebsiteConfiguration={
'IndexDocument': {'Suffix': 'index.html'},
'ErrorDocument': {'Key': 'error.html'},
'RoutingRules': [{
'Condition': {'KeyPrefixEquals': 'docs/'},
'Redirect': {'ReplaceKeyPrefixWith': 'documentation/'}
}]
}
)

# Bucket policy for public read (if not using CloudFront)
public_policy = {
"Version": "2012-10-17",
"Statement": [{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::www.example.com/*"
}]
}

# Note: Use CloudFront + OAC instead for production

🔍 Interviewer Notes: Tests static hosting and CDN integration.

❌ Common Mistakes:

  • Not using CloudFront for HTTPS/custom domains
  • Wrong bucket naming for Route 53 alias
  • Not configuring error documents

Q29: How do you use S3 with CloudFront?​

Technical Answer: CloudFront serves S3 content from edge locations for lower latency and HTTPS support. Use Origin Access Control (OAC) or OAI to restrict direct S3 access, and configure cache behaviors for different path patterns.

Code/Config Example:

import boto3

cloudfront = boto3.client('cloudfront')

# Create CloudFront distribution with S3 origin
response = cloudfront.create_distribution(
DistributionConfig={
'CallerReference': 'unique-ref-123',
'Origins': {
'Items': [{
'Id': 'S3Origin',
'DomainName': 'my-bucket.s3.us-east-1.amazonaws.com',
'S3OriginConfig': {'OriginAccessIdentity': ''},
'OriginAccessControlId': 'oac-123456' # OAC ID
}]
},
'DefaultCacheBehavior': {
'TargetOriginId': 'S3Origin',
'ViewerProtocolPolicy': 'redirect-to-https',
'CachePolicyId': 'cache-policy-id'
},
'Enabled': True,
'DefaultRootObject': 'index.html'
}
)

# OAC configuration (create separately)
oac = cloudfront.create_origin_access_control(
OriginAccessControlConfig={
'Name': 'S3OAC',
'OriginAccessControlOriginType': 's3',
'SigningBehavior': 'always',
'SigningProtocol': 'sigv4'
}
)

🔍 Interviewer Notes: Tests CDN and S3 integration patterns.

❌ Common Mistakes:

  • Not using OAC/OAI (security risk)
  • Not configuring cache behaviors properly
  • Forgetting to invalidate cache after updates

Q30: How do you monitor S3 with CloudWatch and S3 Inventory?​

Technical Answer: S3 publishes metrics to CloudFront (request metrics, data transfer) and can generate inventory reports for object metadata. CloudTrail logs all API calls for auditing.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Enable request metrics
s3.put_bucket_metrics_configuration(
Bucket='my-bucket',
Id='EntireBucket',
MetricsConfiguration={'Id': 'EntireBucket', 'Filter': {'Prefix': ''}}
)

# Configure S3 Inventory
s3.put_bucket_inventory_configuration(
Bucket='my-bucket',
Id='DailyInventory',
InventoryConfiguration={
'Destination': {
'S3BucketDestination': {
'Bucket': 'arn:aws:s3:::inventory-bucket',
'Prefix': 'inventory/',
'Format': 'Parquet'
}
},
'IsEnabled': True,
'Schedule': {'Frequency': 'Daily'},
'IncludedObjectVersions': 'All',
'OptionalFields': ['Size', 'LastModifiedDate', 'StorageClass']
}
)

🔍 Interviewer Notes: Tests monitoring and observability practices.

❌ Common Mistakes:

  • Not enabling request metrics (disabled by default)
  • Not using inventory for large buckets (API listing is slow)
  • Forgetting to check CloudTrail for API auditing

Q31: How do you configure S3 bucket policies with conditions?​

Technical Answer: Bucket policies support conditions like IP restrictions, VPC endpoints, SSL requirements, and MFA enforcement. Conditions add fine-grained control beyond basic allow/deny decisions.

Code/Config Example:

import boto3
import json

s3 = boto3.client('s3')

policy = {
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyExceptFromVPC",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": ["arn:aws:s3:::my-bucket", "arn:aws:s3:::my-bucket/*"],
"Condition": {
"StringNotEquals": {"aws:SourceVpc": "vpc-12345678"}
}
},
{
"Sid": "RequireMFA",
"Effect": "Deny",
"Principal": {"AWS": "arn:aws:iam::123456789:user/john"},
"Action": "s3:DeleteObject",
"Resource": "arn:aws:s3:::my-bucket/*",
"Condition": {"Null": {"aws:MultiFactorAuthAge": "true"}}
}
]
}

s3.put_bucket_policy(Bucket='my-bucket', Policy=json.dumps(policy))

🔍 Interviewer Notes: Tests advanced IAM policy conditions.

❌ Common Mistakes:

  • Not testing policies before applying (can lock out)
  • Using aws:SourceIp with VPC endpoints (use aws:SourceVpc)
  • Condition logic errors (StringNotEquals vs StringNotLike)

Q32: How do S3 ACLs work and when should you use them?​

Technical Answer: ACLs (Access Control Lists) are a legacy permission mechanism granting read/write access to specific AWS accounts. AWS recommends using bucket policies and IAM instead, but ACLs are still needed for specific scenarios like S3 log delivery.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Disable ACLs (recommended - use bucket policies instead)
s3.put_bucket_ownership_controls(
Bucket='my-bucket',
OwnershipControls={
'Rules': [{'ObjectOwnership': 'BucketOwnerEnforced'}]
}
)

🔍 Interviewer Notes: Tests understanding of legacy vs modern access control.

❌ Common Mistakes:

  • Using ACLs when bucket policies are better
  • Not disabling ACLs for simplified access
  • Confusion between ACLs and bucket policies

Q33: How do you implement S3 encryption with KMS keys?​

Technical Answer: SSE-KMS uses AWS KMS keys for encryption with audit trail via CloudTrail. You can use AWS-managed keys (free) or customer-managed keys (more control, additional cost).

Code/Config Example:

import boto3
import json

s3 = boto3.client('s3')
kms = boto3.client('kms')

# Create customer-managed KMS key
key = kms.create_key(
Description='S3 encryption key',
KeyUsage='ENCRYPT_DECRYPT',
Origin='AWS_KMS'
)

# Enable bucket encryption with KMS
s3.put_bucket_encryption(
Bucket='my-bucket',
ServerSideEncryptionConfiguration={
'Rules': [{
'ApplyServerSideEncryptionByDefault': {
'SSEAlgorithm': 'aws:kms',
'KMSMasterKeyID': key['KeyMetadata']['KeyId']
},
'BucketKeyEnabled': True
}]
}
)

🔍 Interviewer Notes: Tests KMS integration and cost optimization.

❌ Common Mistakes:

  • Not enabling BucketKey (increases KMS costs)
  • Forgetting KMS key permissions for cross-account access
  • Using KMS for public buckets (access denied)

Q34: How do you use S3 Object Lock for compliance?​

Technical Answer: Object Lock prevents object deletion or modification for a retention period using Governance or Compliance mode. Governance mode allows overrides by users with special permissions, while Compliance mode is immutable.

Code/Config Example:

import boto3
from datetime import datetime, timedelta

s3 = boto3.client('s3')

# Create bucket with Object Lock enabled (must be at creation)
s3.create_bucket(
Bucket='compliance-bucket',
CreateBucketConfiguration={'LocationConstraint': 'us-east-1'},
ObjectLockEnabledForBucket=True
)

# Enable Object Lock configuration
s3.put_object_lock_configuration(
Bucket='compliance-bucket',
ObjectLockConfiguration={
'ObjectLockEnabled': 'Enabled',
'Rule': {
'DefaultRetention': {
'Mode': 'GOVERNANCE',
'Days': 365
}
}
}
)

# Upload with Object Lock
retain_until = datetime.now() + timedelta(days=365)
s3.put_object(
Bucket='compliance-bucket',
Key='financial-report.pdf',
Body=b'report data',
ObjectLockMode='COMPLIANCE',
ObjectLockRetainUntilDate=retain_until
)

🔍 Interviewer Notes: Tests compliance and regulatory requirements knowledge.

❌ Common Mistakes:

  • Not enabling Object Lock at bucket creation (can't enable later)
  • Confusing Governance vs Compliance mode
  • Not understanding legal hold vs retention

Q35: How do you implement S3 Glacier restore operations?​

Technical Answer: Glacier restore makes archived objects temporarily accessible. Three restore tiers: Expedited (1-5 min), Standard (3-5 hours), Bulk (5-12 hours). Restored copies exist for specified days.

Code/Config Example:

import boto3
import time

s3 = boto3.client('s3')

# Initiate restore
s3.restore_object(
Bucket='my-bucket',
Key='archive.zip',
RestoreRequest={
'Days': 7,
'GlacierJobParameters': {'Tier': 'Standard'}
}
)

# Check restore status
while True:
response = s3.head_object(Bucket='my-bucket', Key='archive.zip')
if 'Restore' in response:
if 'ongoing-request="false"' in response['Restore']:
print("Restore complete!")
break
time.sleep(60)

🔍 Interviewer Notes: Tests archival and retrieval strategies.

❌ Common Mistakes:

  • Not checking restore status before accessing
  • Choosing wrong restore tier for urgency
  • Forgetting restored copy expires after Days

Q36: How do you use S3 Batch Operations?​

Technical Answer: S3 Batch Operations perform large-scale actions on billions of objects using a manifest file. Supported operations include copy, tag, ACL update, restore, and Lambda invocation.

Code/Config Example:

import boto3

s3control = boto3.client('s3control')

job = s3control.create_job(
AccountId='123456789',
Operation={
'S3PutObjectCopy': {
'TargetResource': 'arn:aws:s3:::dest-bucket',
'MetadataDirective': 'COPY'
}
},
Manifest={
'Spec': {'Format': 'S3BatchOperations_CSV_20180820', 'Fields': ['Bucket', 'Key']},
'Location': {'ObjectArn': 'arn:aws:s3:::manifest-bucket/manifest.csv'}
},
Report={
'Bucket': 'arn:aws:s3:::report-bucket',
'Format': 'Report_CSV_20180820',
'Enabled': True
},
Priority=10,
RoleArn='arn:aws:iam::123456789:role/S3BatchRole'
)

🔍 Interviewer Notes: Tests large-scale data management.

❌ Common Mistakes:

  • Not creating proper IAM role for batch operations
  • Wrong manifest format
  • Not enabling completion reports

Q37: How do you configure S3 Storage Lens?​

Technical Answer: Storage Lens provides organization-wide S3 analytics and insights. It generates daily metrics on storage usage, cost optimization, and data protection across all buckets.

Code/Config Example:

import boto3

s3control = boto3.client('s3control')

s3control.put_storage_lens_configuration(
AccountId='123456789',
ConfigId='org-analytics',
StorageLensConfiguration={
'Id': 'org-analytics',
'IsEnabled': True,
'AccountLevel': {
'ActivityMetrics': {'IsEnabled': True},
'AdvancedCostOptimizationMetrics': {'IsEnabled': True}
},
'DataExport': {
'S3BucketDestination': {
'AccountId': '123456789',
'Arn': 'arn:aws:s3:::analytics-bucket',
'Format': 'CSV'
}
}
}
)

🔍 Interviewer Notes: Tests observability and analytics capabilities.

❌ Common Mistakes:

  • Not enabling Storage Lens for multi-account organizations
  • Not configuring data export for historical analysis
  • Ignoring cost optimization recommendations

Q38: How do you implement S3 Access Analyzer?​

Technical Answer: S3 Access Analyzer identifies buckets with public access or cross-account access. It continuously monitors and generates findings for security review.

Code/Config Example:

import boto3

access_analyzer = boto3.client('accessanalyzer')

analyzer = access_analyzer.create_analyzer(
analyzerName='s3-access-analyzer',
type='ACCOUNT'
)

findings = access_analyzer.list_findings(
analyzerArn='arn:aws:access-analyzer:us-east-1:123456789:analyzer/s3-access-analyzer',
filter={'resourceType': {'eq': ['AWS::S3::Bucket']}}
)

🔍 Interviewer Notes: Tests security monitoring and compliance.

❌ Common Mistakes:

  • Not enabling Access Analyzer in all regions
  • Ignoring findings
  • Not automating remediation

Q39: How do you use S3 with VPC Gateway Endpoints?​

Technical Answer: S3 Gateway Endpoints keep traffic to S3 within the AWS network without internet gateway or NAT. They're free and use route table entries to direct S3 traffic.

Code/Config Example:

import boto3

ec2 = boto3.client('ec2')

endpoint = ec2.create_vpc_endpoint(
VpcId='vpc-12345678',
ServiceName='com.amazonaws.us-east-1.s3',
RouteTableIds=['rtb-12345678']
)

# Restrict S3 bucket access to VPC endpoint
s3_policy = {
"Version": "2012-10-17",
"Statement": [{
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": "arn:aws:s3:::my-bucket/*",
"Condition": {
"StringNotEquals": {"aws:SourceVpce": "vpce-12345678"}
}
}]
}

🔍 Interviewer Notes: Tests network security and VPC integration.

❌ Common Mistakes:

  • Confusing Gateway vs Interface endpoints
  • Not updating route tables after creating endpoint
  • Wrong condition key (use aws:SourceVpce)

Q40: How do you optimize S3 performance for high throughput?​

Technical Answer: S3 supports 3,500 PUT/COPY/POST/DELETE and 5,500 GET/HEAD requests per second per prefix. Use hash prefixes or randomize key names to avoid hot partitions.

Code/Config Example:

import boto3
import hashlib

def get_optimized_key(original_key):
hash_prefix = hashlib.md5(original_key.encode()).hexdigest()[:4]
return f"{hash_prefix}/{original_key}"

s3 = boto3.client('s3')

# GOOD: Hash prefix distributes across partitions
key = get_optimized_key('data/2024/01/01/file1.csv')

s3.put_object(Bucket='my-bucket', Key=key, Body=b'data')

🔍 Interviewer Notes: Tests performance optimization and scalability.

❌ Common Mistakes:

  • Sequential key naming
  • Not understanding prefix-based partitioning
  • Over-optimizing for low-throughput workloads

Q41: How do you use S3 range GETs for partial downloads?​

Technical Answer: Range GETs download specific byte ranges from objects, enabling parallel downloads and resumable transfers. This is useful for large files or when only part of the data is needed.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Download specific byte range
response = s3.get_object(
Bucket='my-bucket',
Key='large-file.zip',
Range='bytes=0-1048575' # First 1MB
)
data = response['Body'].read()

🔍 Interviewer Notes: Tests efficient data transfer techniques.

❌ Common Mistakes:

  • Not handling incomplete range downloads
  • Overhead of too many small ranges
  • Not checking ContentRange in response

Q42: How do you implement S3 multipart copy?​

Technical Answer: Multipart copy copies large objects within S3 without downloading. It's useful for copying between buckets or changing storage classes for large objects.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Initiate multipart copy
response = s3.create_multipart_upload(
Bucket='dest-bucket',
Key='large-file.zip',
StorageClass='STANDARD_IA'
)
upload_id = response['UploadId']

# Copy parts (simplified - normally in loop)
response = s3.upload_part_copy(
Bucket='dest-bucket',
Key='large-file.zip',
UploadId=upload_id,
PartNumber=1,
CopySource={'Bucket': 'source-bucket', 'Key': 'large-file.zip'},
CopySourceRange='bytes=0-104857599'
)

🔍 Interviewer Notes: Tests server-side operations and large object handling.

❌ Common Mistakes:

  • Not handling copy for objects >5GB (must use multipart)
  • Wrong byte range calculation
  • Not completing multipart upload

Q43: How do you use S3 Select with Parquet format?​

Technical Answer: S3 Select supports Parquet format with schema-aware querying. It can filter rows and project columns, reducing data transfer for analytical queries.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

response = s3.select_object_content(
Bucket='my-bucket',
Key='data/large-dataset.parquet',
Expression="SELECT timestamp, value FROM s3object WHERE timestamp > '2024-01-01'",
ExpressionType='SQL',
InputSerialization={'Parquet': {}},
OutputSerialization={'JSON': {'RecordDelimiter': '\n'}}
)

for event in response['Payload']:
if 'Records' in event:
print(event['Records']['Payload'].decode('utf-8'))

🔍 Interviewer Notes: Tests analytics and data format knowledge.

❌ Common Mistakes:

  • Using CSV serialization for Parquet input
  • Not leveraging column projection
  • Large result sets exceeding Lambda timeout

Q44: How do you implement S3 replication with KMS encryption?​

Technical Answer: Replicating KMS-encrypted objects requires additional IAM permissions and KMS key policies. The replication role needs access to both source and destination KMS keys.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

s3.put_bucket_replication(
Bucket='source-bucket',
ReplicationConfiguration={
'Role': 'arn:aws:iam::123456789:role/s3-replication-role',
'Rules': [{
'ID': 'ReplicateEncrypted',
'Status': 'Enabled',
'SourceSelectionCriteria': {
'SseKmsEncryptedObjects': {'Status': 'Enabled'}
},
'Destination': {
'Bucket': 'arn:aws:s3:::dest-bucket',
'EncryptionConfiguration': {
'ReplicaKmsKeyID': 'arn:aws:kms:us-west-2:123456789:key/dest-key-id'
}
}
}]
}
)

🔍 Interviewer Notes: Tests encryption and replication integration.

❌ Common Mistakes:

  • Not updating KMS key policy for replication role
  • Forgetting SourceSelectionCriteria for KMS objects
  • Different KMS keys in source/destination

Q45: How do you use S3 Inventory for compliance reporting?​

Technical Answer: S3 Inventory generates daily/weekly reports of object metadata including encryption status, storage class, and replication status. It's essential for compliance auditing of large buckets.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

s3.put_bucket_inventory_configuration(
Bucket='compliance-bucket',
Id='ComplianceReport',
InventoryConfiguration={
'Destination': {
'S3BucketDestination': {
'Bucket': 'arn:aws:s3:::inventory-reports',
'Prefix': 'compliance/',
'Format': 'Parquet'
}
},
'IsEnabled': True,
'IncludedObjectVersions': 'All',
'OptionalFields': ['Size', 'LastModifiedDate', 'StorageClass', 'EncryptionStatus']
}
)

🔍 Interviewer Notes: Tests compliance and audit capabilities.

❌ Common Mistakes:

  • Not including all required OptionalFields
  • Using CSV for large inventories (use Parquet)
  • Not automating inventory analysis

Q46: How do you implement S3 Object Lambda transformations?​

Technical Answer: S3 Object Lambda transforms objects on-the-fly using Lambda functions. Common use cases: redacting PII, resizing images, converting formats, and filtering data.

Code/Config Example:

import boto3
import csv
import io

def lambda_handler(event, context):
s3 = boto3.client('s3')
object_context = event['getObjectContext']

response = s3.get_object(
Bucket='source-bucket',
Key=event['userRequest']['url'].split('/')[-1]
)

original_data = response['Body'].read().decode('utf-8')
reader = csv.DictReader(io.StringIO(original_data))
filtered = [row for row in reader if row.get('status') == 'active']

output = io.StringIO()
writer = csv.DictWriter(output, fieldnames=reader.fieldnames)
writer.writeheader()
writer.writerows(filtered)

s3.write_get_object_response(
RequestRoute=object_context['outputRoute'],
RequestToken=object_context['outputToken'],
Body=output.getvalue()
)
return {'statusCode': 200}

🔍 Interviewer Notes: Tests serverless transformation patterns.

❌ Common Mistakes:

  • Lambda timeout with large objects
  • Not writing response with write_get_object_response
  • Forgetting to return statusCode

Q47: How do you use S3 with AWS Macie for data protection?​

Technical Answer: Macie discovers and protects sensitive data in S3 using machine learning. It identifies PII, PHI, and financial data, generating findings for remediation.

Code/Config Example:

import boto3

macie = boto3.client('macie2')

job = macie.create_classification_job(
jobType='SCHEDULED',
name='S3SensitiveDataScan',
s3JobDefinition={
'BucketDefinitions': [{
'AccountId': '123456789',
'Buckets': ['sensitive-data-bucket']
}]
},
scheduleFrequency={'dailySchedule': {}}
)

findings = macie.list_findings(
findingCriteria={
'criterion': {
'classificationDetails.jobId': {'eq': [job['jobId']]}
}
}
)

🔍 Interviewer Notes: Tests data protection and compliance automation.

❌ Common Mistakes:

  • Not enabling Macie in all regions
  • High cost for large buckets
  • Not automating remediation of findings

Q48: How do you implement S3 replication time control (RTC)?​

Technical Answer: RTC provides a predictable replication SLA (15 minutes) with automatic monitoring and failure alerts. It's essential for compliance and disaster recovery requirements.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

s3.put_bucket_replication(
Bucket='source-bucket',
ReplicationConfiguration={
'Role': 'arn:aws:iam::123456789:role/s3-replication-role',
'Rules': [{
'ID': 'RTCReplication',
'Status': 'Enabled',
'Destination': {
'Bucket': 'arn:aws:s3:::dest-bucket',
'ReplicationTime': {
'Status': 'Enabled',
'Time': {'Minutes': 15}
},
'Metrics': {
'Status': 'Enabled',
'EventThreshold': {'Minutes': 15}
}
}
}]
}
)

🔍 Interviewer Notes: Tests disaster recovery and SLA compliance.

❌ Common Mistakes:

  • Not enabling Metrics with RTC
  • Not setting up CloudWatch alarms
  • RTC costs extra

Q49: How do you use S3 Storage Class Analysis?​

Technical Answer: Storage Class Analysis monitors access patterns and recommends lifecycle policy transitions. It helps optimize costs by identifying infrequently accessed data.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

s3.put_bucket_analytics_configuration(
Bucket='my-bucket',
Id='AccessPatternAnalysis',
AnalyticsConfiguration={
'Id': 'AccessPatternAnalysis',
'Filter': {'Prefix': 'logs/'},
'StorageClassAnalysis': {
'DataExport': {
'OutputSchemaVersion': 'V_1',
'Destination': {
'S3BucketDestination': {
'Bucket': 'arn:aws:s3:::analytics-bucket',
'Format': 'CSV'
}
}
}
}
}
)

🔍 Interviewer Notes: Tests cost optimization and data-driven decisions.

❌ Common Mistakes:

  • Not waiting 30 days for meaningful analysis
  • Not filtering to specific prefixes
  • Not acting on recommendations

Q50: How do you implement S3 with CloudFront OAC (Origin Access Control)?​

Technical Answer: OAC is the modern way to restrict S3 bucket access to CloudFront only. It replaces the older OAI (Origin Access Identity) and supports HTTPS and more secure signing.

Code/Config Example:

import boto3

cloudfront = boto3.client('cloudfront')

# Create OAC
oac = cloudfront.create_origin_access_control(
OriginAccessControlConfig={
'Name': 'S3OAC',
'OriginAccessControlOriginType': 's3',
'SigningBehavior': 'always',
'SigningProtocol': 'sigv4'
}
)

# Use OAC in distribution
cloudfront.create_distribution(
DistributionConfig={
'Origins': {'Items': [{
'Id': 'S3Origin',
'DomainName': 'my-bucket.s3.us-east-1.amazonaws.com',
'S3OriginConfig': {'OriginAccessIdentity': ''},
'OriginAccessControlId': oac['OriginAccessControl']['Id']
}]}
}
)

🔍 Interviewer Notes: Tests CDN security best practices.

❌ Common Mistakes:

  • Using deprecated OAI instead of OAC
  • Not updating bucket policy for OAC
  • Forgetting to sign requests (SigningBehavior)

Q51: How do you implement S3 presigned URLs for secure uploads?​

Technical Answer: Presigned POST allows users to upload directly to S3 without server credentials. It supports conditions like file size limits, content type restrictions, and key prefix enforcement.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

post = s3.generate_presigned_post(
Bucket='my-bucket',
Key='uploads/${filename}',
Fields={
'acl': 'private',
'Content-Type': 'image/jpeg'
},
Conditions=[
['content-length-range', 0, 5242880], # Max 5MB
['starts-with', '$key', 'uploads/'],
{'acl': 'private'},
{'Content-Type': 'image/jpeg'}
],
ExpiresIn=3600
)

# Use in HTML form
# <form action="..." method="post" enctype="multipart/form-data">
# <input type="hidden" name="key" value="uploads/${filename}">
# <input type="hidden" name="AWSAccessKeyId" value="...">
# ...

🔍 Interviewer Notes: Tests secure direct-to-S3 upload patterns.

❌ Common Mistakes:

  • Not setting file size limits (DoS risk)
  • Using presigned GET for server-to-server transfers
  • Expiration too long (security risk)

Q52: How do you implement S3 event notifications with multiple destinations?​

Technical Answer: S3 can send events to Lambda, SQS, and SNS simultaneously with different filters. Each destination can have unique prefix/suffix filters for routing events.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

s3.put_bucket_notification_configuration(
Bucket='my-bucket',
NotificationConfiguration={
'LambdaFunctionConfigurations': [{
'Id': 'ProcessImages',
'LambdaFunctionArn': 'arn:aws:lambda:us-east-1:123456789:function:process-image',
'Events': ['s3:ObjectCreated:*'],
'Filter': {'Key': {'FilterRules': [{'Name': 'suffix', 'Value': '.jpg'}]}}
}],
'QueueConfigurations': [{
'Id': 'BackupNotifications',
'QueueArn': 'arn:aws:sqs:us-east-1:123456789:backup-queue',
'Events': ['s3:ObjectCreated:*', 's3:ObjectRemoved:*']
}],
'TopicConfigurations': [{
'Id': 'AlertTopic',
'TopicArn': 'arn:aws:sns:us-east-1:123456789:alerts',
'Events': ['s3:ObjectCreated:*']
}]
}
)

🔍 Interviewer Notes: Tests event-driven architecture patterns.

❌ Common Mistakes:

  • Not granting S3 permission to invoke destinations
  • Duplicate events across destinations
  • Not handling idempotency in consumers

Q53: How do you use S3 with AWS DataSync?​

Technical Answer: DataSync transfers data between on-premises and S3 (or between S3 buckets) with automatic scheduling and monitoring. It's optimized for large datasets and checksum verification.

Code/Config Example:

import boto3

datasync = boto3.client('datasync')

# Create S3 location
s3_location = datasync.create_location_s3(
S3BucketArn='arn:aws:s3:::dest-bucket',
Subdirectory='backup/',
S3Config={'BucketAccessRoleArn': 'arn:aws:iam::123456789:role/datasync-role'}
)

# Create NFS location (on-premises)
nfs_location = datasync.create_location_nfs(
Subdirectory='/export/data',
ServerHostname='192.168.1.100',
OnPremConfig={'AgentArns': ['arn:aws:datasync:us-east-1:123456789:agent/agent-id']}
)

# Create and start task
task = datasync.create_task(
SourceLocationArn=nfs_location['LocationArn'],
DestinationLocationArn=s3_location['LocationArn'],
Name='OnPremToS3Backup',
Schedule={'ScheduleExpression': 'cron(0 2 * * ? *)'} # Daily 2AM
)

🔍 Interviewer Notes: Tests hybrid cloud data transfer.

❌ Common Mistakes:

  • Not configuring agents for on-premises
  • Not setting up proper IAM roles
  • Not monitoring task execution

Q54: How do you implement S3 with Storage Gateway (S3 File Gateway)?​

Technical Answer: S3 File Gateway provides on-premises access to S3 using NFS/SMB protocols. It caches frequently accessed data locally and uploads to S3 in the background.

Code/Config Example:

import boto3

storage_gateway = boto3.client('storagegateway')

# Activate gateway (after deploying VM on-premises)
gateway = storage_gateway.activate_gateway(
ActivationKey='1234-5678-9012-3456',
GatewayName='S3FileGateway',
GatewayTimezone='US/Eastern',
GatewayRegion='us-east-1'
)

# Create SMB file share
share = storage_gateway.create_smb_file_share(
GatewayARN=gateway['GatewayARN'],
LocationARN='arn:aws:s3:::my-bucket/share/',
Role='arn:aws:iam::123456789:role/storage-gateway-role',
GuessMIMETypeEnabled=True,
ReadOnly=False
)

🔍 Interviewer Notes: Tests hybrid cloud storage patterns.

❌ Common Mistakes:

  • Not sizing gateway VM properly for workload
  • Not configuring cache disk for performance
  • Confusing File Gateway vs Volume Gateway

Q55: How do you implement S3 cost allocation tags?​

Technical Answer: Cost allocation tags enable tracking S3 costs by project, department, or environment. Tags must be activated in Billing console and applied to objects or buckets.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Tag bucket for cost allocation
s3.put_bucket_tagging(
Bucket='my-bucket',
Tagging={
'TagSet': [
{'Key': 'Department', 'Value': 'Engineering'},
{'Key': 'Environment', 'Value': 'Production'},
{'Key': 'Project', 'Value': 'DataLake'}
]
}
)

# Tag individual objects
s3.put_object_tagging(
Bucket='my-bucket',
Key='data/file.csv',
Tagging={
'TagSet': [
{'Key': 'CostCenter', 'Value': 'CC123'}
]
}
)

🔍 Interviewer Notes: Tests cost management and governance.

❌ Common Mistakes:

  • Not activating tags in Billing console
  • Not using consistent tagging strategy
  • Forgetting tags on new objects (no inheritance)

Q56: How do you use S3 Requester Pays buckets?​

Technical Answer: Requester Pays shifts data transfer and request costs from bucket owner to requester. Useful for sharing large datasets where download costs should be borne by the downloader.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Enable Requester Pays
s3.put_bucket_request_payment(
Bucket='public-dataset-bucket',
RequestPaymentConfiguration={'Payer': 'Requester'}
)

# Access as requester (pays for download)
s3_requester = boto3.client('s3')
response = s3_requester.get_object(
Bucket='public-dataset-bucket',
Key='large-dataset.csv',
RequestPayer='requester' # Required!
)

🔍 Interviewer Notes: Tests cost sharing and billing models.

❌ Common Mistakes:

  • Not specifying RequestPayer in requests
  • Using Requester Pays for internal buckets
  • Not documenting for users of the bucket

Q57: How do you implement S3 Object Lambda with Access Points?​

Technical Answer: Object Lambda works with Access Points to transform objects on retrieval. The Access Point routes GetObject requests through Lambda for transformation before returning data.

Code/Config Example:

import boto3

s3control = boto3.client('s3control')

# Create supporting Access Point
support_ap = s3control.create_access_point(
AccountId='123456789',
Name='original-data',
Bucket='source-bucket'
)

# Create Object Lambda Access Point
s3control.create_access_point_for_object_lambda(
AccountId='123456789',
Name='redacted-data',
Configuration={
'SupportingAccessPoint': support_ap['AccessPointArn'],
'TransformationConfigurations': [{
'Actions': ['GetObject'],
'ContentTransformation': {
'AwsLambda': {
'FunctionArn': 'arn:aws:lambda:us-east-1:123456789:function:redact-pii'
}
}
}]
}
)

# Use Object Lambda ARN
s3 = boto3.client('s3')
response = s3.get_object(
Bucket='arn:aws:s3-object-lambda:us-east-1:123456789:accesspoint/redacted-data',
Key='sensitive-data.json'
)

🔍 Interviewer Notes: Tests advanced S3 access patterns.

❌ Common Mistakes:

  • Not creating supporting Access Point first
  • Wrong ARN format for Object Lambda
  • Lambda timeout with large objects

Q58: How do you implement S3 replication with delete marker replication?​

Technical Answer: Delete marker replication ensures DELETE operations are replicated to destination buckets. It must be explicitly enabled and requires versioning on both buckets.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

s3.put_bucket_replication(
Bucket='source-bucket',
ReplicationConfiguration={
'Role': 'arn:aws:iam::123456789:role/s3-replication-role',
'Rules': [{
'ID': 'ReplicateAll',
'Status': 'Enabled',
'DeleteMarkerReplication': {'Status': 'Enabled'},
'Destination': {
'Bucket': 'arn:aws:s3:::dest-bucket'
}
}]
}
)

🔍 Interviewer Notes: Tests replication consistency.

❌ Common Mistakes:

  • Not enabling DeleteMarkerReplication (disabled by default)
  • Expecting DELETE of specific version to replicate (it won't)
  • Not understanding delete marker vs permanent delete

Q59: How do you use S3 Select with JSON format?​

Technical Answer: S3 Select supports JSON (document or lines format) with SQL queries. Document format treats entire file as single JSON, while Lines format expects one JSON per line.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Query JSON Document format
response = s3.select_object_content(
Bucket='my-bucket',
Key='data/users.json',
Expression="SELECT * FROM s3object s WHERE s.age > 30",
ExpressionType='SQL',
InputSerialization={'JSON': {'Type': 'DOCUMENT'}},
OutputSerialization={'JSON': {}}
)

# Query JSON Lines format (one JSON per line)
response = s3.select_object_content(
Bucket='my-bucket',
Key='logs/logs.jsonl',
Expression="SELECT s.timestamp, s.level FROM s3object s WHERE s.level = 'ERROR'",
ExpressionType='SQL',
InputSerialization={'JSON': {'Type': 'LINES'}},
OutputSerialization={'JSON': {'RecordDelimiter': '\n'}}
)

🔍 Interviewer Notes: Tests data format handling.

❌ Common Mistakes:

  • Wrong JSON type (DOCUMENT vs LINES)
  • Not handling large result sets
  • Output serialization mismatch

Q60: How do you implement S3 with AWS Backup?​

Technical Answer: AWS Backup provides centralized backup management for S3 with cross-region copy and compliance reporting. It supports continuous backups and periodic backups.

Code/Config Example:

import boto3

backup = boto3.client('backup')

# Create backup plan
plan = backup.create_backup_plan(
BackupPlan={
'BackupPlanName': 'S3BackupPlan',
'Rules': [{
'RuleName': 'DailyBackup',
'TargetBackupVaultName': 'default',
'ScheduleExpression': 'cron(0 2 * * ? *)',
'Lifecycle': {'DeleteAfterDays': 30}
}]
}
)

# Assign resources to plan
backup.create_backup_selection(
BackupPlanId=plan['BackupPlanId'],
Selection={
'SelectionName': 'S3Buckets',
'IamRoleArn': 'arn:aws:iam::123456789:role/backup-role',
'Resources': ['arn:aws:s3:::my-bucket']
}
)

🔍 Interviewer Notes: Tests centralized backup strategies.

❌ Common Mistakes:

  • Not assigning proper IAM role
  • Confusing AWS Backup with S3 replication
  • Not considering backup costs

Q61: How do you implement S3 Glacier Flexible Retrieval (formerly Glacier)?​

Technical Answer: Glacier Flexible Retrieval provides low-cost archive storage with 3-5 hour retrieval. Use expedited (1-5 min), standard (3-5 hours), or bulk (5-12 hours) retrieval tiers.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Upload to Glacier Flexible Retrieval
s3.put_object(
Bucket='my-bucket',
Key='archive.zip',
Body=b'data',
StorageClass='GLACIER'
)

# Initiate restore
s3.restore_object(
Bucket='my-bucket',
Key='archive.zip',
RestoreRequest={
'Days': 7,
'GlacierJobParameters': {'Tier': 'Standard'}
}
)

# Check restore status
response = s3.head_object(Bucket='my-bucket', Key='archive.zip')
if 'Restore' in response:
print(response['Restore']) # Shows expiry date

🔍 Interviewer Notes: Tests archival storage strategies.

❌ Common Mistakes:

  • Not checking restore status before accessing
  • Wrong tier selection for urgency
  • Forgetting restored copy expires

Q62: How do you implement S3 Glacier Instant Retrieval?​

Technical Answer: Glacier Instant Retrieval provides milliseconds retrieval for archived data at lower cost than Standard-IA. Ideal for rarely accessed data that needs immediate access when required.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Upload to Glacier Instant Retrieval
s3.put_object(
Bucket='my-bucket',
Key='medical-records.pdf',
Body=b'records',
StorageClass='GLACIER_IR'
)

# Access immediately (no restore needed!)
response = s3.get_object(
Bucket='my-bucket',
Key='medical-records.pdf'
)
# Milliseconds access, no restore required

🔍 Interviewer Notes: Tests archive storage with instant access needs.

❌ Common Mistakes:

  • Restoring from Glacier IR (not needed!)
  • Using Standard-IA instead (more expensive for rare access)
  • Not considering retrieval costs per GB

Q63: How do you implement S3 replication with multiple destination buckets?​

Technical Answer: A single source bucket can replicate to multiple destinations by defining multiple replication rules. Each rule can have different filters and destinations.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

s3.put_bucket_replication(
Bucket='source-bucket',
ReplicationConfiguration={
'Role': 'arn:aws:iam::123456789:role/s3-replication-role',
'Rules': [
{
'ID': 'ReplicateToDR',
'Status': 'Enabled',
'Priority': 1,
'Filter': {'Prefix': ''},
'Destination': {
'Bucket': 'arn:aws:s3:::dr-bucket'
}
},
{
'ID': 'ReplicateLogsToAnalytics',
'Status': 'Enabled',
'Priority': 2,
'Filter': {'Prefix': 'logs/'},
'Destination': {
'Bucket': 'arn:aws:s3:::analytics-bucket',
'StorageClass': 'STANDARD_IA'
}
}
]
}
)

🔍 Interviewer Notes: Tests complex replication topologies.

❌ Common Mistakes:

  • Not setting Priority for overlapping rules
  • Duplicate storage costs across destinations
  • Not managing replication role permissions

Q64: How do you use S3 with Amazon Athena for querying?​

Technical Answer: Athena queries S3 data using SQL without loading into a database. Define tables via Glue Data Catalog or directly in Athena with serde specifications.

Code/Config Example:

import boto3

athena = boto3.client('athena')

# Run query on S3 data
response = athena.start_query_execution(
QueryString="""
SELECT year, COUNT(*) as count
FROM mydb.user_logs
WHERE year >= 2020
GROUP BY year
""",
QueryExecutionContext={
'Database': 'mydb'
},
ResultConfiguration={
'OutputLocation': 's3://query-results-bucket/athena-results/'
}
)

# Check status
execution = athena.get_query_execution(
QueryExecutionId=response['QueryExecutionId']
)

🔍 Interviewer Notes: Tests analytics on S3 data lakes.

❌ Common Mistakes:

  • Not partitioning data (slow/expensive queries)
  • Wrong output location for results
  • Not compressing S3 data (larger scan costs)

Q65: How do you implement S3 Access Point policies?​

Technical Answer: Access Point policies are resource-based policies attached to Access Points, controlling access through that specific Access Point. They work with bucket policies for defense-in-depth.

Code/Config Example:

import boto3
import json

s3control = boto3.client('s3control')

# Create Access Point with policy
s3control.create_access_point(
AccountId='123456789',
Name='read-only-access',
Bucket='shared-bucket',
Policy=json.dumps({
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": {"AWS": "arn:aws:iam::123456789:role/analyst"},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:us-east-1:123456789:accesspoint/read-only-access/object/*"
}]
})
)

🔍 Interviewer Notes: Tests fine-grained access control.

❌ Common Mistakes:

  • Not combining with bucket policy (both must allow)
  • Wrong resource ARN format in policy
  • Not restricting to specific Access Point

Technical Answer: Legal hold provides indefinite protection for objects under investigation or litigation. Unlike retention periods, legal holds don't expire and must be manually removed.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Place legal hold on object
s3.put_object_legal_hold(
Bucket='compliance-bucket',
Key='evidence.pdf',
LegalHold={'Status': 'ON'}
)

# Check legal hold status
response = s3.get_object_legal_hold(
Bucket='compliance-bucket',
Key='evidence.pdf'
)
print(response['LegalHold']['Status']) # ON or OFF

# Remove legal hold (when case closed)
s3.put_object_legal_hold(
Bucket='compliance-bucket',
Key='evidence.pdf',
LegalHold={'Status': 'OFF'}
)

🔍 Interviewer Notes: Tests legal and compliance scenarios.

❌ Common Mistakes:

  • Confusing legal hold with retention period
  • Not documenting reason for legal hold
  • Forgetting to remove legal hold when done

Q67: How do you monitor S3 requests with CloudTrail?​

Technical Answer: CloudTrail logs all S3 API calls for auditing. Enable data events for object-level logging (PutObject, GetObject, DeleteObject) in addition to management events.

Code/Config Example:

import boto3

cloudtrail = boto3.client('cloudtrail')

# Configure CloudTrail with S3 data events
cloudtrail.put_event_selectors(
TrailName='my-trail',
EventSelectors=[{
'ReadWriteType': 'All',
'IncludeManagementEvents': True,
'DataResources': [{
'Type': 'AWS::S3::Object',
'Values': ['arn:aws:s3:::my-bucket/']
}]
}]
)

# Query CloudTrail logs with Athena
# SELECT * FROM cloudtrail_logs WHERE eventname = 'DeleteObject'

🔍 Interviewer Notes: Tests auditing and compliance monitoring.

❌ Common Mistakes:

  • Not enabling data events (only management by default)
  • High CloudTrail costs for busy buckets
  • Not filtering to specific buckets

Q68: How do you implement S3 with Amazon QuickSight?​

Technical Answer: QuickSight connects directly to S3 for business intelligence dashboards. Use manifest files to specify S3 locations and supported file formats (CSV, JSON, Excel, etc.).

Code/Config Example:

import boto3

quicksight = boto3.client('quicksight')

# Create data source pointing to S3
quicksight.create_data_source(
AwsAccountId='123456789',
DataSourceId='s3-datasource',
Name='S3Analytics',
Type='S3',
DataSourceParameters={
'S3Parameters': {
'ManifestFileLocation': {
'Bucket': 'manifest-bucket',
'Key': 'quicksight-manifest.json'
}
}
},
RoleArn='arn:aws:iam::123456789:role/quicksight-s3-role'
)

# Manifest file (quicksight-manifest.json)
# {"fileLocations": [{"URIs": ["s3://data-bucket/data/"]}], "globalUploadSettings": {"format": "CSV"}}

🔍 Interviewer Notes: Tests BI integration with S3 data lakes.

❌ Common Mistakes:

  • Not creating proper IAM role for QuickSight
  • Wrong manifest file format
  • Not handling large datasets (SPICE vs Direct Query)

Q69: How do you use S3 with AWS Step Functions for orchestration?​

Technical Answer: Step Functions orchestrate multi-step workflows involving S3 operations. Use service integrations for S3 to copy, delete, or check existence without Lambda functions.

Code/Config Example:

{
"Comment": "S3 File Processing Workflow",
"StartAt": "CheckFileExists",
"States": {
"CheckFileExists": {
"Type": "Task",
"Resource": "arn:aws:states:::aws-sdk:s3:headObject",
"Parameters": {
"Bucket": "source-bucket",
"Key.$": "$.key"
},
"Next": "CopyToProcessed"
},
"CopyToProcessed": {
"Type": "Task",
"Resource": "arn:aws:states:::aws-sdk:s3:copyObject",
"Parameters": {
"Bucket": "dest-bucket",
"CopySource.$": "arn:aws:s3:::source-bucket/${$.key}",
"Key.$": "$.key"
},
"Next": "Success"
},
"Success": { "Type": "Succeed" }
}
}

🔍 Interviewer Notes: Tests workflow orchestration patterns.

❌ Common Mistakes:

  • Using Lambda when service integration exists
  • Not handling errors in workflow
  • Wrong IAM permissions for Step Functions

Q70: How do you implement S3 multipart upload with checksum?​

Technical Answer: S3 supports checksum validation during multipart upload using CRC32, CRC32C, SHA1, or SHA256. This ensures data integrity during transfer.

Code/Config Example:

import boto3
import hashlib

s3 = boto3.client('s3')

# Initiate multipart upload with checksum
response = s3.create_multipart_upload(
Bucket='my-bucket',
Key='large-file.bin',
ChecksumAlgorithm='SHA256'
)
upload_id = response['UploadId']

# Upload part with checksum
data = b'binary data...'
checksum = hashlib.sha256(data).digest()

response = s3.upload_part(
Bucket='my-bucket',
Key='large-file.bin',
UploadId=upload_id,
PartNumber=1,
Body=data,
ChecksumAlgorithm='SHA256',
ChecksumSHA256=checksum # Base64 encoded
)

🔍 Interviewer Notes: Tests data integrity and multipart patterns.

❌ Common Mistakes:

  • Not computing checksum correctly (Base64)
  • Mixing checksum algorithms
  • Not validating checksum on completion

Q71: How do you use S3 Mountpoint for S3?​

Technical Answer: Mountpoint is a file system client that mounts S3 buckets as local directories on Linux. It provides high throughput for sequential workloads like data lakes and machine learning training.

Code/Config Example:

# Install Mountpoint
wget https://s3.amazonaws.com/mountpoint-s3-release/latest/x86_64/mount-s3.rpm
sudo rpm -i mount-s3.rpm

# Mount bucket
mkdir -p /mnt/s3-bucket
mount-s3 my-bucket /mnt/s3-bucket --allow-delete

# Use as normal filesystem
cp /local/file.txt /mnt/s3-bucket/

🔍 Interviewer Notes: Tests filesystem interface to S3.

❌ Common Mistakes:

  • Not understanding it's for sequential access (not random I/O)
  • Using for databases (use File Gateway instead)
  • Not configuring IAM permissions for mountpoint

Q72: How do you implement S3 on Outposts?​

Technical Answer: S3 on Outposts brings S3 API to on-premises AWS Outposts. It supports local buckets with optional cloud replication for hybrid scenarios.

Code/Config Example:

import boto3

# Use Outpost endpoint
s3 = boto3.client('s3', endpoint_url='https://s3-outposts.us-east-1.amazonaws.com')

# Create bucket on Outpost
s3.create_bucket(
Bucket='local-data-bucket',
CreateBucketConfiguration={
'Location': {
'Type': 'Outpost',
'OutpostId': 'op-123456789'
}
}
)

# Replicate to AWS cloud
s3.put_bucket_replication(
Bucket='local-data-bucket',
ReplicationConfiguration={
'Role': 'arn:aws:iam::123456789:role/outpost-replication',
'Rules': [{
'Destination': {
'Bucket': 'arn:aws:s3:::cloud-bucket'
}
}]
}
)

🔍 Interviewer Notes: Tests hybrid cloud storage patterns.

❌ Common Mistakes:

  • Not using Outpost endpoint URL
  • Forgetting OutpostId in bucket creation
  • Not understanding storage capacity limits

Q73: How do you implement S3 Strong Consistency patterns?​

Technical Answer: S3 provides strong read-after-write consistency for all operations since December 2020. New objects, overwrites, and deletes are immediately consistent across all regions.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Immediately read after write (strongly consistent)
s3.put_object(Bucket='my-bucket', Key='test.txt', Body=b'v1')
response = s3.get_object(Bucket='my-bucket', Key='test.txt')
# Immediately returns v1

# Overwrite is also strongly consistent
s3.put_object(Bucket='my-bucket', Key='test.txt', Body=b'v2')
response = s3.get_object(Bucket='my-bucket', Key='test.txt')
# Immediately returns v2 (not eventual!)

🔍 Interviewer Notes: Tests understanding of modern S3 consistency.

❌ Common Mistakes:

  • Citing old eventual consistency model (pre-2020)
  • Expecting ACID transactions (S3 is not a database)
  • Not understanding list operations are also strongly consistent

Q74: How do you use S3 with Amazon EMR?​

Technical Answer: EMR uses S3 as the persistent data layer for Hadoop/Spark jobs. Use s3:// URIs and consider S3Guard for consistency (though less needed now with strong consistency).

Code/Config Example:

import boto3

# Configure EMR cluster with S3 access
emr = boto3.client('emr')

job_flow = emr.run_job_flow(
Name='SparkS3Job',
ReleaseLabel='emr-6.15.0',
Applications=[{'Name': 'Spark'}],
Configurations=[{
'Classification': 'spark-defaults',
'Properties': {
'spark.hadoop.fs.s3a.aws.credentials.provider': 'com.amazonaws.auth.DefaultAWSCredentialsProviderChain'
}
}],
Steps=[{
'Name': 'ProcessData',
'ActionOnFailure': 'CONTINUE',
'HadoopJarStep': {
'Jar': 'command-runner.jar',
'Args': [
'spark-submit',
'--deploy-mode', 'cluster',
's3://my-bucket/scripts/process.py'
]
}
}]
)

🔍 Interviewer Notes: Tests big data integration patterns.

❌ Common Mistakes:

  • Not configuring IAM roles for EMR
  • Using s3n:// or s3a:// incorrectly
  • Not optimizing for S3 throughput

Q75: How do you implement S3 conditional writes?​

Technical Answer: Conditional writes (If-None-Match with *) prevent overwriting existing objects. This provides optimistic concurrency control for distributed systems.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Conditional write - only create if not exists
try:
s3.put_object(
Bucket='my-bucket',
Key='unique-file.txt',
Body=b'data',
IfNoneMatch='*' # Only write if object doesn't exist
)
print("Object created!")
except s3.exceptions.ClientError as e:
if e.response['Error']['Code'] == 'PreconditionFailed':
print("Object already exists!")

🔍 Interviewer Notes: Tests concurrency control patterns.

❌ Common Mistakes:

  • Not handling PreconditionFailed exception
  • Using wrong condition (IfMatch vs IfNoneMatch)
  • Not understanding when to use conditional writes

Q76: How do you use S3 with Amazon Redshift?​

Technical Answer: Redshift can COPY data from S3 and UNLOAD data to S3. Use IAM roles for authentication and manifest files for loading multiple files.

Code/Config Example:

-- Copy from S3 to Redshift
COPY users
FROM 's3://my-bucket/data/users/'
IAM_ROLE 'arn:aws:iam::123456789:role/redshift-s3-role'
FORMAT AS CSV
REGION 'us-east-1';

-- Unload from Redshift to S3
UNLOAD ('SELECT * FROM users WHERE active = true')
TO 's3://my-bucket/exports/active-users/'
IAM_ROLE 'arn:aws:iam::123456789:role/redshift-s3-role'
PARALLEL ON
HEADER;

🔍 Interviewer Notes: Tests data warehouse integration.

❌ Common Mistakes:

  • Not configuring IAM role for Redshift
  • Wrong S3 path (needs trailing slash for prefix)
  • Not using manifest for many files

Q77: How do you implement S3 default bucket encryption?​

Technical Answer: Default bucket encryption automatically encrypts all new objects. You can use SSE-S3, SSE-KMS, or SSE-C as the default, and it applies to objects without explicit encryption.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Set default encryption with SSE-KMS
s3.put_bucket_encryption(
Bucket='my-bucket',
ServerSideEncryptionConfiguration={
'Rules': [{
'ApplyServerSideEncryptionByDefault': {
'SSEAlgorithm': 'aws:kms',
'KMSMasterKeyID': 'arn:aws:kms:us-east-1:123456789:key/uuid'
},
'BucketKeyEnabled': True # Reduces KMS costs
}]
}
)

# Check encryption status
response = s3.get_bucket_encryption(Bucket='my-bucket')
print(response['ServerSideEncryptionConfiguration'])

🔍 Interviewer Notes: Tests encryption best practices.

❌ Common Mistakes:

  • Not enabling BucketKey (increases KMS costs)
  • Forgetting to handle existing unencrypted objects
  • Not using default encryption (relies on clients)

Q78: How do you use S3 with AWS Lake Formation?​

Technical Answer: Lake Formation provides fine-grained access control for data lakes on S3. It uses named resource policies and tag-based access control for hybrid governance.

Code/Config Example:

import boto3

lakeformation = boto3.client('lakeformation')

# Grant permissions on S3 data lake
lakeformation.grant_permissions(
Principal={'DataLakePrincipalIdentifier': 'arn:aws:iam::123456789:user/analyst'},
Resource={
'Table': {
'DatabaseName': 'mydb',
'TableName': 'user_data'
}
},
Permissions=['SELECT', 'DESCRIBE'],
PermissionsWithGrantOption=['SELECT']
)

🔍 Interviewer Notes: Tests data lake governance.

❌ Common Mistakes:

  • Not registering S3 location with Lake Formation
  • Confusing Lake Formation vs IAM permissions
  • Not using tag-based access control

Q79: How do you implement S3 Object Ownership controls?​

Technical Answer: Object Ownership controls prevent ACLs and enforce bucket owner ownership. Prefer BucketOwnerEnforced to disable ACLs and simplify permissions.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Disable ACLs (recommended)
s3.put_bucket_ownership_controls(
Bucket='my-bucket',
OwnershipControls={
'Rules': [{'ObjectOwnership': 'BucketOwnerEnforced'}]
}
)

# Or prefer bucket owner (ACLs still work)
s3.put_bucket_ownership_controls(
Bucket='my-bucket',
OwnershipControls={
'Rules': [{'ObjectOwnership': 'BucketOwnerPreferred'}]
}
)

🔍 Interviewer Notes: Tests modern S3 access patterns.

❌ Common Mistakes:

  • Not disabling ACLs (BucketOwnerEnforced)
  • Confusion between ownership and bucket policies
  • Not updating applications after changing ownership

Q80: How do you use S3 with Amazon Kinesis Firehose?​

Technical Answer: Kinesis Firehose can deliver streaming data directly to S3 with buffering, transformation, and compression. Configure buffering size/time and optional Lambda transformation.

Code/Config Example:

import boto3

firehose = boto3.client('firehose')

firehose.create_delivery_stream(
DeliveryStreamName='S3DeliveryStream',
S3DestinationConfiguration={
'RoleARN': 'arn:aws:iam::123456789:role/firehose-s3-role',
'BucketARN': 'arn:aws:s3:::streaming-data-bucket',
'Prefix': 'logs/!{timestamp:yyyy/MM/dd}/',
'BufferingHints': {
'SizeInMBs': 128,
'IntervalInSeconds': 300
},
'CompressionFormat': 'GZIP'
}
)

🔍 Interviewer Notes: Tests streaming data integration.

❌ Common Mistakes:

  • Not configuring IAM role for Firehose
  • Wrong buffering settings (cost vs latency)
  • Not handling failed deliveries

Q81: How do you implement S3 intelligent-tiering archive configurations?​

Technical Answer: Intelligent-Tiering can automatically move objects to Archive Access and Deep Archive Access tiers after 90 and 180 days of no access. Configure via S3 console or API.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

s3.put_bucket_intelligent_tiering_configuration(
Bucket='my-bucket',
Id='ArchiveConfig',
IntelligentTieringConfiguration={
'Status': 'Enabled',
'Tierings': [
{'Days': 90, 'AccessTier': 'ARCHIVE_ACCESS'},
{'Days': 180, 'AccessTier': 'DEEP_ARCHIVE_ACCESS'}
]
}
)

🔍 Interviewer Notes: Tests automated cost optimization.

❌ Common Mistakes:

  • Not understanding monitoring fee per object
  • Setting archive too early (objects still accessed)
  • Not using for unknown access patterns

Q82: How do you use S3 with Amazon ECS/EKS?​

Technical Answer: ECS/EKS tasks/pods access S3 via IAM roles for service accounts (IRSA) or task roles. Mountpoint for S3 can also be used for filesystem access.

Code/Config Example:

import boto3

# IAM role for service account (IRSA) - setup in Kubernetes
# annotations: eks.amazonaws.com/role-arn: arn:aws:iam::123456789:role/ecs-s3-role

# Then in container, SDK automatically uses role
s3 = boto3.client('s3')

# List objects
response = s3.list_objects_v2(Bucket='app-data-bucket', Prefix='inputs/')
for obj in response.get('Contents', []):
print(obj['Key'])

🔍 Interviewer Notes: Tests containerized application patterns.

❌ Common Mistakes:

  • Not configuring IRSA for EKS
  • Using static credentials in containers
  • Not understanding task role vs execution role

Q83: How do you implement S3 event notifications with EventBridge?​

Technical Answer: EventBridge provides advanced routing for S3 events with filtering, archiving, and replay. It's the modern replacement for S3 direct event notifications to Lambda/SQS/SNS.

Code/Config Example:

import boto3

s3 = boto3.client('s3')
events = boto3.client('events')

# Enable EventBridge notification on bucket
s3.put_bucket_notification_configuration(
Bucket='my-bucket',
NotificationConfiguration={
'EventBridgeConfiguration': {} # Enable EventBridge
}
)

# Create EventBridge rule
events.put_rule(
Name='S3ObjectCreated',
EventPattern='{"source": ["aws.s3"], "detail-type": ["Object Created"]}'
)

🔍 Interviewer Notes: Tests modern event routing patterns.

❌ Common Mistakes:

  • Not enabling EventBridge on bucket
  • Wrong event pattern syntax
  • Not understanding EventBridge vs direct notifications

Q84: How do you use S3 with AWS Glue Data Catalog?​

Technical Answer: Glue Data Catalog stores metadata about S3 data lakes. Crawlers scan S3 and create tables, or you can define tables manually with serde specifications.

Code/Config Example:

import boto3

glue = boto3.client('glue')

# Create database
glue.create_database(
DatabaseInput={
'Name': 'datalake_db',
'Description': 'S3 data lake database'
}
)

# Create table pointing to S3
glue.create_table(
DatabaseName='datalake_db',
TableInput={
'Name': 'user_logs',
'StorageDescriptor': {
'Location': 's3://my-bucket/logs/',
'InputFormat': 'org.apache.hadoop.mapred.TextInputFormat',
'SerdeInfo': {
'SerializationLibrary': 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
},
'Columns': [
{'Name': 'timestamp', 'Type': 'string'},
{'Name': 'user_id', 'Type': 'int'}
]
}
}
)

🔍 Interviewer Notes: Tests data lake metadata management.

❌ Common Mistakes:

  • Not running crawlers regularly
  • Wrong serde for data format
  • Not partitioning tables (expensive queries)

Q85: How do you implement S3 presigned URLs with custom expiration?​

Technical Answer: Presigned URLs can have custom expiration times (1 second to 7 days for IAM roles, longer for credentials). Use shorter expirations for security.

Code/Config Example:

import boto3
from datetime import datetime, timedelta

s3 = boto3.client('s3')

# Generate URL with 5 minute expiration
url = s3.generate_presigned_url(
ClientMethod='get_object',
Params={'Bucket': 'my-bucket', 'Key': 'private.pdf'},
ExpiresIn=300 # 5 minutes
)

# For upload (PUT)
put_url = s3.generate_presigned_url(
ClientMethod='put_object',
Params={
'Bucket': 'my-bucket',
'Key': 'uploads/file.txt',
'ContentType': 'text/plain'
},
ExpiresIn=600 # 10 minutes
)

🔍 Interviewer Notes: Tests secure temporary access.

❌ Common Mistakes:

  • Setting expiration too long (security risk)
  • Not handling expired URLs in application
  • Using presigned URLs for server-to-server

Q86: How do you use S3 with Amazon SageMaker?​

Technical Answer: SageMaker reads training data from S3 and outputs models to S3. Use S3 for data versioning and model artifact storage with lifecycle policies.

Code/Config Example:

import boto3
import sagemaker

# SageMaker session with S3
sagemaker_session = sagemaker.Session()

# Upload training data to S3
training_data = sagemaker_session.upload_data(
path='local/train.csv',
bucket='ml-bucket',
key_prefix='training'
)

# Train model with S3 input/output
estimator = sagemaker.estimator.Estimator(
image_uri='...',
role='arn:aws:iam::123456789:role/sagemaker-role',
instance_count=1,
instance_type='ml.m5.large',
output_path='s3://ml-bucket/models/'
)

estimator.fit({'train': training_data})

🔍 Interviewer Notes: Tests ML pipeline integration.

❌ Common Mistakes:

  • Not configuring SageMaker IAM role for S3
  • Not versioning training data
  • Not using lifecycle policies for old models

Q87: How do you implement S3 bucket logging and analysis?​

Technical Answer: S3 server access logging writes logs to a target bucket. Analyze logs with Athena to understand access patterns, costs, and security issues.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Enable access logging
s3.put_bucket_logging(
Bucket='source-bucket',
BucketLoggingStatus={
'LoggingEnabled': {
'TargetBucket': 'log-bucket',
'TargetPrefix': 'access-logs/'
}
}
)

# Query logs with Athena
# CREATE EXTERNAL TABLE s3_access_logs (...)
# ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.RegexSerDe'
# LOCATION 's3://log-bucket/access-logs/'

🔍 Interviewer Notes: Tests audit and analysis capabilities.

❌ Common Mistakes:

  • Logging bucket in different region (extra cost)
  • Not setting lifecycle on log bucket
  • Not using Athena for log analysis

Q88: How do you use S3 with AWS Transfer Family (SFTP)?​

Technical Answer: AWS Transfer Family provides SFTP, FTPS, and FTP access to S3. Users authenticate via SSO, custom identity providers, or service-managed users.

Code/Config Example:

import boto3

transfer = boto3.client('transfer')

# Create SFTP server
server = transfer.create_server(
Protocols=['SFTP'],
IdentityProviderType='SERVICE_MANAGED',
EndpointType='PUBLIC',
LoggingRole='arn:aws:iam::123456789:role/transfer-logging-role'
)

# Add user
transfer.create_user(
ServerId=server['ServerId'],
UserName='partner1',
HomeDirectory='s3://data-bucket/partner1/',
Role='arn:aws:iam::123456789:role/transfer-s3-role',
SshPublicKeyBody='ssh-rsa AAAA...'
)

🔍 Interviewer Notes: Tests managed file transfer patterns.

❌ Common Mistakes:

  • Not configuring IAM role for Transfer
  • Wrong home directory format
  • Not enabling logging

Q89: How do you implement S3 object tagging strategies?​

Technical Answer: Object tags enable cost allocation, lifecycle rules, and access control. Use tags for department, project, environment, or data classification.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Tag objects at upload
s3.put_object(
Bucket='my-bucket',
Key='report.pdf',
Body=b'report',
Tagging='Department=Finance&Project=Q1Report&Classification=Confidential'
)

# Add tags to existing object
s3.put_object_tagging(
Bucket='my-bucket',
Key='report.pdf',
Tagging={
'TagSet': [
{'Key': 'Retention', 'Value': '7years'},
{'Key': 'Owner', 'Value': 'john@example.com'}
]
}
)

# Lifecycle rule using tags
lifecycle = {
'Rules': [{
'ID': 'DeleteByTag',
'Status': 'Enabled',
'Filter': {'Tag': {'Key': 'Temp', 'Value': 'true'}},
'Expiration': {'Days': 7}
}]
}

🔍 Interviewer Notes: Tests governance and organization.

❌ Common Mistakes:

  • Not using tags for cost allocation
  • Too many tags (max 10 per object)
  • Not using tags in lifecycle rules

Q90: How do you use S3 with Amazon CloudSearch or OpenSearch?​

Technical Answer: Upload documents to S3 and use Lambda to index in CloudSearch/OpenSearch. Alternatively, use S3 as document store with OpenSearch's S3 plugin.

Code/Config Example:

import boto3

# Lambda to index S3 documents in OpenSearch
def lambda_handler(event, context):
s3 = boto3.client('s3')
opensearch = boto3.client('opensearch')

for record in event['Records']:
bucket = record['s3']['bucket']['name']
key = record['s3']['object']['key']

# Get document from S3
response = s3.get_object(Bucket=bucket, Key=key)
document = response['Body'].read().decode('utf-8')

# Index in OpenSearch
opensearch.index(
Index='documents',
Body=document,
refresh=True
)

🔍 Interviewer Notes: Tests search integration patterns.

❌ Common Mistakes:

  • Not handling large documents (Lambda timeout)
  • Not batching documents for indexing
  • Wrong IAM permissions for OpenSearch

Q91: How do you implement S3 Batch Operations with Lambda?​

Technical Answer: Batch Operations can invoke Lambda for each object, enabling custom processing at scale. Lambda receives S3 event and can transform, validate, or enrich objects.

Code/Config Example:

import boto3

s3control = boto3.client('s3control')

# Create batch job with Lambda invocation
s3control.create_job(
AccountId='123456789',
Operation={
'LambdaInvoke': {
'FunctionArn': 'arn:aws:lambda:us-east-1:123456789:function:process-object'
}
},
Manifest={
'Spec': {'Format': 'S3BatchOperations_CSV_20180820'},
'Location': {'ObjectArn': 'arn:aws:s3:::manifest-bucket/manifest.csv'}
},
Report={'Bucket': 'arn:aws:s3:::report-bucket', 'Enabled': True},
Priority=10,
RoleArn='arn:aws:iam::123456789:role/BatchLambdaRole'
)

🔍 Interviewer Notes: Tests serverless data processing at scale.

❌ Common Mistakes:

  • Not granting Lambda permission to S3 Batch
  • Lambda timeout for large objects
  • Not handling errors in Lambda

Q92: How do you use S3 with Amazon EFS or FSx?​

Technical Answer: While EFS/FSx are file systems and S3 is object storage, you can transfer data between them using DataSync or copy tools. S3 is for object storage, EFS for shared file access.

Code/Config Example:

import boto3

# Use DataSync to copy from EFS to S3
datasync = boto3.client('datasync')

# Create EFS location
efs_loc = datasync.create_location_efs(
EfsFilesystemArn='arn:aws:elasticfilesystem:us-east-1:123456789:filesystem/fs-123',
Subdirectory='/data',
Ec2Config={
'SubnetArn': 'arn:aws:ec2:us-east-1:123456789:subnet/subnet-123',
'SecurityGroupArns': ['arn:aws:ec2:us-east-1:123456789:security-group/sg-123']
}
)

# Create S3 location and start task
s3_loc = datasync.create_location_s3(...)

🔍 Interviewer Notes: Tests file system vs object storage patterns.

❌ Common Mistakes:

  • Using S3 when EFS is needed (POSIX, file locking)
  • Using EFS when S3 is better (scale, durability)
  • Not using DataSync for transfer

Q93: How do you implement S3 replication metrics and alarms?​

Technical Answer: Enable replication metrics to monitor replication progress and set CloudWatch alarms for missed thresholds. Use ReplicationTime metrics for RTC (Replication Time Control).

Code/Config Example:

import boto3

s3 = boto3.client('s3')
cloudwatch = boto3.client('cloudwatch')

# Configure replication with metrics
s3.put_bucket_replication(
Bucket='source-bucket',
ReplicationConfiguration={
'Role': 'arn:aws:iam::123456789:role/replication-role',
'Rules': [{
'ID': 'ReplicationWithMetrics',
'Status': 'Enabled',
'Destination': {
'Bucket': 'arn:aws:s3:::dest-bucket',
'ReplicationTime': {
'Status': 'Enabled',
'Time': {'Minutes': 15}
},
'Metrics': {
'Status': 'Enabled',
'EventThreshold': {'Minutes': 15}
}
}
}]
}
)

# CloudWatch alarm for missed SLA
cloudwatch.put_metric_alarm(
AlarmName='ReplicationMissedSLA',
MetricName='OperationMissedThreshold',
Namespace='AWS/S3',
Threshold=1,
ComparisonOperator='GreaterThanThreshold'
)

🔍 Interviewer Notes: Tests monitoring and SLA compliance.

❌ Common Mistakes:

  • Not enabling Metrics with RTC
  • Not setting up alarms
  • Not monitoring replication backlog

Q94: How do you use S3 with AWS Config for compliance?​

Technical Answer: AWS Config rules check S3 bucket compliance (encryption, public access, logging). Use managed rules or custom Lambda rules for specific requirements.

Code/Config Example:

import boto3

config = boto3.client('config')

# Enable Config rule for S3 buckets
config.put_config_rule(
ConfigRule={
'ConfigRuleName': 's3-bucket-ssl-requests-only',
'Description': 'Checks S3 SSL requests only',
'Scope': {
'ComplianceResourceTypes': ['AWS::S3::Bucket']
},
'Source': {
'Owner': 'AWS',
'SourceIdentifier': 'S3_BUCKET_SSL_REQUESTS_ONLY'
}
}
)

🔍 Interviewer Notes: Tests compliance automation.

❌ Common Mistakes:

  • Not enabling Config in all regions
  • Not using AWS Config rules for S3
  • Not remediating non-compliant buckets

Q95: How do you implement S3 multi-region access points?​

Technical Answer: Multi-Region Access Points provide a single endpoint for accessing S3 data across regions. They use routing policies to direct requests to the closest or specific region.

Code/Config Example:

import boto3

s3control = boto3.client('s3control')

# Create Multi-Region Access Point
response = s3control.create_multi_region_access_point(
AccountId='123456789',
Name='global-data-access',
Routes={
'us-east-1': {'Bucket': 'arn:aws:s3:::data-bucket-useast'},
'eu-west-1': {'Bucket': 'arn:aws:s3:::data-bucket-euwest'}
}
)

# Use MRAP ARN
s3 = boto3.client('s3')
s3.put_object(
Bucket='arn:aws:s3::123456789:accesspoint/global-data-access',
Key='shared-data.txt',
Body=b'data'
)

🔍 Interviewer Notes: Tests global data access patterns.

❌ Common Mistakes:

  • Not configuring routing policies
  • Wrong ARN format for MRAP
  • Not understanding use cases (disaster recovery)

Q96: How do you use S3 with Amazon GuardDuty for threat detection?​

Technical Answer: GuardDuty detects suspicious activities on S3 like credential exfiltration, unusual data access, or penetration testing. Enable S3 protection in GuardDuty settings.

Code/Config Example:

import boto3

guardduty = boto3.client('guardduty')

# Enable S3 protection (done in console or API)
guardduty.update_detector(
DetectorId='detector-id',
Features=[{
'Name': 'S3_DATA_EVENTS',
'Status': 'ENABLED'
}]
)

# Findings are published to CloudWatch Events/EventBridge
# Example finding: Recon:EC2/PortProbe!

🔍 Interviewer Notes: Tests threat detection and security monitoring.

❌ Common Mistakes:

  • Not enabling S3 protection in GuardDuty
  • Ignoring GuardDuty findings
  • Not automating remediation

Q97: How do you implement S3 Object Lambda with custom runtimes?​

Technical Answer: Object Lambda supports any Lambda runtime. The key is reading from the original bucket and writing the transformed response using write_get_object_response.

Code/Config Example:

import boto3
import json

# Node.js Object Lambda example (conceptual)
"""
exports.handler = async (event) => {
const s3 = new AWS.S3();
const response = await s3.getObject({
Bucket: 'source-bucket',
Key: event.userRequest.url.split('/').pop()
}).promise();

const transformed = response.Body.toString().toUpperCase();

await s3.writeGetObjectResponse({
RequestRoute: event.getObjectContext.outputRoute,
RequestToken: event.getObjectContext.outputToken,
Body: transformed
}).promise();

return { statusCode: 200 };
};
"""

🔍 Interviewer Notes: Tests multi-language Lambda patterns.

❌ Common Mistakes:

  • Not returning statusCode
  • Not using writeGetObjectResponse
  • Runtime-specific issues (timeout, memory)

Q98: How do you use S3 with AWS Artifact for compliance reports?​

Technical Answer: AWS Artifact provides compliance reports for S3 (SOC, PCI, ISO, etc.). Download reports programmatically via API for audit automation.

Code/Config Example:

import boto3

artifact = boto3.client('artifact')

# List available reports
reports = artifact.list_reports()

# Download S3 compliance report
for report in reports['reports']:
if 'S3' in report['name'] or 'Storage' in report['name']:
content = artifact.get_report(
reportId=report['id'],
termToken=report['termToken']
)
with open(f"{report['name']}.pdf", 'wb') as f:
f.write(content['reportData'])

🔍 Interviewer Notes: Tests compliance documentation automation.

❌ Common Mistakes:

  • Not automating compliance report downloads
  • Not understanding report coverage
  • Not sharing reports with auditors

Q99: How do you implement S3 with AWS SDK for JavaScript (Node.js)?​

Technical Answer: AWS SDK for JavaScript v3 provides modular packages for S3. Use @aws-sdk/client-s3 with async/await patterns and streaming for large objects.

Code/Config Example:

import {
S3Client,
PutObjectCommand,
GetObjectCommand,
} from "@aws-sdk/client-s3";
import { Readable } from "stream";

const s3Client = new S3Client({ region: "us-east-1" });

// Upload with SDK v3
async function uploadFile(bucket, key, data) {
const command = new PutObjectCommand({
Bucket: bucket,
Key: key,
Body: data,
ServerSideEncryption: "AES256",
});
return await s3Client.send(command);
}

// Stream download
async function streamObject(bucket, key) {
const command = new GetObjectCommand({ Bucket: bucket, Key: key });
const response = await s3Client.send(command);
// response.Body is a Readable stream
return response.Body;
}

🔍 Interviewer Notes: Tests JavaScript SDK usage.

❌ Common Mistakes:

  • Using v2 SDK (not modular)
  • Not streaming large objects
  • Wrong region configuration

Q100: How do you monitor S3 costs with AWS Cost Explorer?​

Technical Answer: Cost Explorer can filter S3 costs by service, region, storage class, and tags. Use programmatic API to automate cost reporting and anomaly detection.

Code/Config Example:

import boto3
from datetime import datetime, timedelta

ce = boto3.client('ce')

# Get S3 costs for last 30 days
end = datetime.now()
start = end - timedelta(days=30)

response = ce.get_cost_and_usage(
TimePeriod={'Start': start.strftime('%Y-%m-%d'), 'End': end.strftime('%Y-%m-%d')},
Granularity='DAILY',
Metrics=['UnblendedCost'],
Filter={
'Dimensions': {
'Key': 'SERVICE',
'Values': ['Amazon Simple Storage Service']
}
},
GroupBy=[{'Type': 'DIMENSION', 'Key': 'REGION'}]
)

🔍 Interviewer Notes: Tests cost analysis and optimization.

❌ Common Mistakes:

  • Not filtering by storage class (different costs)
  • Not using tags for cost allocation
  • Not setting up cost anomaly alerts

Q101: How do you implement S3 event notifications?​

Technical Answer:

import boto3

s3 = boto3.client('s3')

# Configure event notification
s3.put_bucket_notification_configuration(
Bucket='my-app-bucket',
NotificationConfiguration={
'LambdaFunctionConfigurations': [{
'LambdaFunctionArn': 'arn:aws:lambda:...:function:process-upload',
'Events': ['s3:ObjectCreated:*'],
'Filter': {
'KeyFilterRules': [{
'Name': 'prefix',
'Value': 'uploads/'
}]
}
}],
'QueueConfigurations': [{
'QueueArn': 'arn:aws:sqs:...:my-queue',
'Events': ['s3:ObjectRemoved:*']
}],
'TopicConfigurations': [{
'TopicArn': 'arn:aws:sns:...:my-topic',
'Events': ['s3:ReducedRedundancyLostObject']
}]
}
)

Event Structure:

{
"Records": [{
"eventVersion": "2.1",
"eventSource": "aws:s3",
"awsRegion": "us-east-1",
"eventTime": "2024-01-01T00:00:00.000Z",
"eventName": "ObjectCreated:Put",
"s3": {
"bucket": {"name": "my-app-bucket"},
"object": {"key": "uploads/file.txt", "size": 1234}
}
}]
}

🔍 Interviewer Notes: Testing event-driven architecture.


Q102: How do you implement cross-region replication?​

Technical Answer:

import boto3

s3 = boto3.client('s3')

# Enable versioning on both buckets first

# Configure replication
s3.put_bucket_replication(
Bucket='source-bucket',
ReplicationConfiguration={
'Role': 'arn:aws:iam::123456789:role/s3-replication-role',
'Rules': [{
'ID': 'ReplicateAll',
'Status': 'Enabled',
'Priority': 1,
'Filter': {'Prefix': ''},
'DeleteMarkerReplication': {'Status': 'Enabled'},
'Destination': {
'Bucket': 'arn:aws:s3:::destination-bucket',
'StorageClass': 'STANDARD',
'ReplicationTime': {
'Status': 'Enabled',
'Time': {'Minutes': 15}
},
'Metrics': {
'Status': 'Enabled',
'Minutes': 15
}
}
}]
}
)

🔍 Interviewer Notes: Testing disaster recovery patterns.


Q103: How do you implement S3 Object Lambda?​

Technical Answer: Transform objects on the fly without storing transformed versions.

import boto3

s3control = boto3.client('s3control')

# Create Object Lambda access point
s3control.create_access_point_for_object_lambda(
AccountId='123456789',
Name='image-resizer',
Configuration={
'SupportingAccessPoint': 'arn:aws:s3:us-east-1:123456789:accesspoint/original-images',
'TransformationConfigurations': [{
'Actions': ['GetObject'],
'ContentTransformation': {
'AwsLambda': {
'FunctionArn': 'arn:aws:lambda:us-east-1:123456789:function:resize-image'
}
}
}]
}
)

Lambda Handler:

import boto3
import json

def lambda_handler(event, context):
# Get original object
s3 = boto3.client('s3')

object_context = event['getObjectContext']
request_route = object_context['outputRoute']
request_token = object_context['outputToken']

# Get original
original = s3.get_object(
Bucket=event['configuration']['accessPointArn'],
Key=event['userRequest']['url'].split('/')[-1]
)

# Transform (resize image, etc.)
transformed = resize_image(original['Body'].read())

# Write response back
s3.write_get_object_response(
RequestRoute=request_route,
RequestToken=request_token,
Body=transformed
)

return {'statusCode': 200}

🔍 Interviewer Notes: Testing advanced S3 features.


2. Intermediate Topics​

Q104: How do you implement S3 with CloudFront for secure content delivery?​

Technical Answer: CloudFront with S3 origin provides HTTPS, global edge locations, and Origin Access Control (OAC) for restricting direct S3 access. Configure cache behaviors for different path patterns.

Code/Config Example:

import boto3

cloudfront = boto3.client('cloudfront')

distribution = cloudfront.create_distribution(
DistributionConfig={
'Origins': {'Items': [{
'Id': 'S3Origin',
'DomainName': 'my-bucket.s3.us-east-1.amazonaws.com',
'S3OriginConfig': {'OriginAccessIdentity': ''},
'OriginAccessControlId': 'oac-123456'
}]},
'DefaultCacheBehavior': {
'TargetOriginId': 'S3Origin',
'ViewerProtocolPolicy': 'redirect-to-https',
'CachePolicyId': 'policy-123'
},
'Enabled': True
}
)

🔍 Interviewer Notes: Tests CDN integration and security.

❌ Common Mistakes:

  • Not using OAC/OAI (security risk)
  • Wrong S3 domain name (use regional endpoint)
  • Not configuring cache policies

Q105: How do you implement S3 presigned URLs with custom conditions?​

Technical Answer: Presigned URLs can include custom conditions like IP restrictions, content type, and metadata. Use Conditions parameter in generate_presigned_post for fine-grained control.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

post = s3.generate_presigned_post(
Bucket='my-bucket',
Key='uploads/${filename}',
Fields={'x-amz-meta-uploader': 'user123'},
Conditions=[
['content-length-range', 0, 10485760],
{'bucket': 'my-bucket'},
['starts-with', '$key', 'uploads/'],
{'x-amz-meta-uploader': 'user123'}
],
ExpiresIn=3600
)

🔍 Interviewer Notes: Tests secure upload patterns.

❌ Common Mistakes:

  • Not validating conditions server-side
  • Expiration too long
  • Not including bucket in conditions

Q106: How do you use S3 Inventory with AWS Athena for analysis?​

Technical Answer: S3 Inventory reports can be queried with Athena to analyze storage classes, encryption status, and object metadata at scale. Create tables directly on inventory data.

Code/Config Example:

-- Create table on S3 Inventory (Parquet format)
CREATE EXTERNAL TABLE s3_inventory (
bucket string,
key string,
size bigint,
last_modified_date timestamp,
storage_class string,
encryption_status string
)
STORED AS PARQUET
LOCATION 's3://inventory-bucket/inventory-reports/';

-- Analyze storage classes
SELECT storage_class, COUNT(*) as count, SUM(size) as total_size
FROM s3_inventory
GROUP BY storage_class;

🔍 Interviewer Notes: Tests large-scale data analysis.

❌ Common Mistakes:

  • Wrong file format (CSV vs Parquet)
  • Not updating table for new inventory
  • Expensive queries on large inventories

Q107: How do you implement S3 cross-account access patterns?​

Technical Answer: Cross-account access uses bucket policies with specific AWS accounts or roles. The accessing account also needs IAM permissions for the cross-account role.

Code/Config Example:

import boto3
import json

# Bucket policy granting cross-account access
policy = {
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": {"AWS": "arn:aws:iam::987654321:root"},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::my-bucket/*"
}]
}

s3 = boto3.client('s3')
s3.put_bucket_policy(Bucket='my-bucket', Policy=json.dumps(policy))

# Accessing account uses their own IAM role
# Role needs: s3:GetObject on arn:aws:s3:::my-bucket/*

🔍 Interviewer Notes: Tests cross-account access patterns.

❌ Common Mistakes:

  • Not granting IAM permissions in accessing account
  • Using Principal "root" without MFA consideration
  • Not understanding both policy layers needed

Q108: How do you use S3 with AWS Lambda for event processing?​

Technical Answer: S3 events trigger Lambda functions for real-time processing. Configure event notifications and ensure Lambda has S3 read permissions via execution role.

Code/Config Example:

import boto3

def lambda_handler(event, context):
s3 = boto3.client('s3')

for record in event['Records']:
bucket = record['s3']['bucket']['name']
key = record['s3']['object']['key']

# Process object
response = s3.get_object(Bucket=bucket, Key=key)
data = response['Body'].read().decode('utf-8')

# Process and store result
s3.put_object(
Bucket='processed-bucket',
Key=f"processed/{key}",
Body=data.upper() # Example transformation
)

return {'statusCode': 200}

🔍 Interviewer Notes: Tests serverless event processing.

❌ Common Mistakes:

  • Not handling idempotency (events retried)
  • Lambda timeout with large objects
  • Not granting S3 permissions to Lambda role

Q109: How do you implement S3 lifecycle transitions with intelligent-tiering?​

Technical Answer: Combine lifecycle policies with Intelligent-Tiering for automated cost optimization. Lifecycle handles transitions to Glacier, while Intelligent-Tiering manages frequent/infrequent access.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

lifecycle = {
'Rules': [{
'ID': 'OptimizeStorage',
'Status': 'Enabled',
'Filter': {'Prefix': ''},
'Transitions': [
{'Days': 30, 'StorageClass': 'INTELLIGENT_TIERING'},
{'Days': 365, 'StorageClass': 'GLACIER_IR'}
]
}]
}

s3.put_bucket_lifecycle_configuration(
Bucket='my-bucket',
LifecycleConfiguration=lifecycle
)

🔍 Interviewer Notes: Tests automated cost optimization.

❌ Common Mistakes:

  • Transitioning to Intelligent-Tiering too early (monitoring fee)
  • Not considering minimum storage duration
  • Conflicting lifecycle rules

Q110: How do you use S3 Select with large CSV files?​

Technical Answer: S3 Select queries large CSV files with SQL, returning only matching rows. Use FileHeaderInfo for CSV with headers and optimize by selecting specific columns.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

response = s3.select_object_content(
Bucket='my-bucket',
Key='large-file.csv',
Expression="SELECT name, email FROM s3object WHERE age > 30",
ExpressionType='SQL',
InputSerialization={
'CSV': {
'FileHeaderInfo': 'USE',
'RecordDelimiter': '\n',
'FieldDelimiter': ','
}
},
OutputSerialization={'JSON': {'RecordDelimiter': '\n'}}
)

for event in response['Payload']:
if 'Records' in event:
print(event['Records']['Payload'].decode('utf-8'))

🔍 Interviewer Notes: Tests data retrieval optimization.

❌ Common Mistakes:

  • Not using column projection (fetches all columns)
  • Wrong CSV format settings
  • Large result sets exceeding Lambda timeout

Q111: How do you implement S3 replication rules with filters?​

Technical Answer: Replication rules use prefix, tag, or AND/OR filters to select objects. Multiple rules with priorities handle overlapping filters.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

s3.put_bucket_replication(
Bucket='source-bucket',
ReplicationConfiguration={
'Role': 'arn:aws:iam::123456789:role/replication',
'Rules': [
{
'ID': 'ReplicateLogs',
'Priority': 1,
'Status': 'Enabled',
'Filter': {'Tag': {'Key': 'Backup', 'Value': 'true'}},
'Destination': {'Bucket': 'arn:aws:s3:::backup-bucket'}
},
{
'ID': 'ReplicateAll',
'Priority': 2,
'Status': 'Enabled',
'Filter': {'Prefix': ''},
'DeleteMarkerReplication': {'Status': 'Enabled'},
'Destination': {'Bucket': 'arn:aws:s3:::dr-bucket'}
}
]
}
)

🔍 Interviewer Notes: Tests complex replication scenarios.

❌ Common Mistakes:

  • Not setting Priority for overlapping rules
  • Wrong filter syntax
  • Not enabling delete marker replication

Q112: How do you use S3 with Amazon MQ for message queuing?​

Technical Answer: S3 events can trigger Lambda which sends messages to Amazon MQ (ActiveMQ/RabbitMQ). Use boto3 to interact with MQ or integrate via Lambda.

Code/Config Example:

import boto3
import json
import pika

def lambda_handler(event, context):
# Connect to RabbitMQ via MQ
mq = boto3.client('mq')
# Get MQ broker endpoint
brokers = mq.describe_broker(BrokerId='broker-123')

# Process S3 event and send to MQ
for record in event['Records']:
message = {
'bucket': record['s3']['bucket']['name'],
'key': record['s3']['object']['key'],
'event': record['eventName']
}

# Send to queue (simplified - use pika for RabbitMQ)
# channel.basic_publish(...)

🔍 Interviewer Notes: Tests message queue integration.

❌ Common Mistakes:

  • Not handling connection pooling
  • Lambda cold start with MQ connections
  • Not using dead-letter queues

Q113: How do you implement S3 object expiration and cleanup?​

Technical Answer: Lifecycle expiration permanently deletes objects or versions after specified days. Use Expiration for current versions and NoncurrentVersionExpiration for versioned objects.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

lifecycle = {
'Rules': [{
'ID': 'CleanupOldVersions',
'Status': 'Enabled',
'Filter': {'Prefix': 'temp/'},
'Expiration': {'Days': 30},
'NoncurrentVersionExpiration': {'NoncurrentDays': 7}
}]
}

s3.put_bucket_lifecycle_configuration(
Bucket='my-bucket',
LifecycleConfiguration=lifecycle
)

🔍 Interviewer Notes: Tests automated cleanup and cost control.

❌ Common Mistakes:

  • Not handling versioned buckets properly
  • Expiration too short (accidental data loss)
  • Not testing before applying

Q114: How do you use S3 with Amazon EFS for hybrid storage?​

Technical Answer: Use S3 for object storage and EFS for shared file storage. DataSync or custom scripts can sync data between them based on access patterns.

Code/Config Example:

import boto3

# Use DataSync to sync S3 to EFS
datasync = boto3.client('datasync')

s3_loc = datasync.create_location_s3(
S3BucketArn='arn:aws:s3:::my-bucket',
Subdirectory='shared/',
S3Config={'BucketAccessRoleArn': 'arn:aws:iam::123456789:role/datasync'}
)

efs_loc = datasync.create_location_efs(
EfsFilesystemArn='arn:aws:elasticfilesystem:us-east-1:123456789:filesystem/fs-123',
Subdirectory='/shared',
Ec2Config={'SecurityGroupArns': [...], 'SubnetArn': '...'}
)

🔍 Interviewer Notes: Tests hybrid storage patterns.

❌ Common Mistakes:

  • Using wrong storage for workload
  • Not considering performance differences
  • Not automating sync

Q115: How do you implement S3 presigned URLs for browser uploads?​

Technical Answer: Generate presigned POST policies for direct browser uploads to S3. Include conditions for file size, type, and use success_action_redirect for post-upload handling.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

post = s3.generate_presigned_post(
Bucket='my-bucket',
Key='uploads/${filename}',
Fields={
'success_action_redirect': 'https://example.com/success',
'acl': 'private'
},
Conditions=[
['content-length-range', 0, 5242880],
['starts-with', '$Content-Type', 'image/']
]
)

# Return post to browser for form submission
# <form action="{{ post['url'] }}" method="post" enctype="multipart/form-data">

🔍 Interviewer Notes: Tests web integration patterns.

❌ Common Mistakes:

  • Not setting file size limits
  • Not validating Content-Type
  • CORS issues with browser uploads

Q116: How do you use S3 with AWS Shield for DDoS protection?​

Technical Answer: S3 is automatically protected by AWS Shield Standard. For advanced protection, Shield Advanced can be added to protect against larger DDoS attacks.

Code/Config Example:

import boto3

shield = boto3.client('shield')

# Subscribe to Shield Advanced (paid service)
shield.create_subscription()

# Add S3 bucket as protection resource
shield.associate_drt_role(
RoleArn='arn:aws:iam::123456789:role/shield-drt-role'
)

# S3 buckets are automatically protected - no config needed

🔍 Interviewer Notes: Tests DDoS protection awareness.

❌ Common Mistakes:

  • Thinking S3 needs manual Shield configuration
  • Not understanding Shield Standard vs Advanced
  • Not configuring DRT access for Advanced

Q117: How do you implement S3 with Amazon API Gateway for uploads?​

Technical Answer: API Gateway can proxy requests to S3 for controlled uploads with validation and transformation. Use AWS integration type with S3 actions.

Code/Config Example:

{
"swagger": "2.0",
"paths": {
"/upload/{key}": {
"put": {
"x-amazon-apigateway-integration": {
"type": "aws",
"uri": "arn:aws:apigateway:us-east-1:s3:path/my-bucket/{key}",
"httpMethod": "PUT",
"credentials": "arn:aws:iam::123456789:role/apig-s3-role"
}
}
}
}
}

🔍 Interviewer Notes: Tests API design patterns.

❌ Common Mistakes:

  • Not configuring IAM role for API Gateway
  • Wrong S3 URI format
  • Not handling large payloads (10MB limit)

Q118: How do you use S3 with AWS Glue for ETL jobs?​

Technical Answer: Glue ETL jobs read from and write to S3. Use dynamic frames for schema inference and handling malformed records.

Code/Config Example:

import sys
from awsglue.transforms import *
from awsglue.utils import getResolvedOptions
from pyspark.context import SparkContext
from awsglue.context import GlueContext

glueContext = GlueContext(SparkContext.getOrCreate())

# Read from S3
dynamic_frame = glueContext.create_dynamic_frame_from_options(
connection_type='s3',
connection_options={'paths': ['s3://source-bucket/data/']},
format='csv',
format_options={'withHeader': True}
)

# Transform
transformed = ApplyMapping.apply(
frame=dynamic_frame,
mappings=[('col1', 'string', 'name', 'string')]
)

# Write to S3
glueContext.write_dynamic_frame.from_options(
frame=transformed,
connection_type='s3',
connection_options={'path': 's3://dest-bucket/processed/'},
format='parquet'
)

🔍 Interviewer Notes: Tests ETL and data lake patterns.

❌ Common Mistakes:

  • Not handling malformed records
  • Wrong IAM permissions for Glue
  • Not optimizing for Parquet output

Q119: How do you implement S3 bucket key for KMS cost optimization?​

Technical Answer: S3 Bucket Key reduces KMS request costs by using a bucket-level key that S3 manages. Enable BucketKeyEnabled in default encryption or per-object.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Enable default encryption with Bucket Key
s3.put_bucket_encryption(
Bucket='my-bucket',
ServerSideEncryptionConfiguration={
'Rules': [{
'ApplyServerSideEncryptionByDefault': {
'SSEAlgorithm': 'aws:kms',
'KMSMasterKeyID': 'arn:aws:kms:us-east-1:123456789:key/uuid'
},
'BucketKeyEnabled': True
}]
}
)

# Per-object upload with bucket key
s3.put_object(
Bucket='my-bucket',
Key='file.txt',
Body=b'data',
ServerSideEncryption='aws:kms',
BucketKeyEnabled=True
)

🔍 Interviewer Notes: Tests cost optimization for encrypted buckets.

❌ Common Mistakes:

  • Not enabling BucketKey (high KMS costs)
  • Confusing with SSE-S3
  • Not understanding cost implications

Q120: How do you use S3 with Amazon EKS for persistent volumes?​

Technical Answer: Use S3 as object storage for EKS applications. For POSIX file systems, use EFS CSI driver instead. S3 requires application-level integration.

Code/Config Example:

# Kubernetes pod with S3 access via IRSA
apiVersion: v1
kind: Pod
metadata:
name: s3-app
spec:
serviceAccountName: s3-service-account
containers:
- name: app
image: my-app:latest
env:
- name: BUCKET_NAME
value: "my-bucket"
---
# IRSA setup: annotate service account with role ARN
# kubectl annotate serviceaccount -n ns s3-service-account \
# eks.amazonaws.com/role-arn=arn:aws:iam::123456789:role/eks-s3-role

🔍 Interviewer Notes: Tests container storage patterns.

❌ Common Mistakes:

  • Using S3 when EFS is needed (POSIX)
  • Not configuring IRSA
  • Expecting POSIX semantics from S3

Q121: How do you implement S3 multi-region disaster recovery?​

Technical Answer: Multi-region DR uses CRR to replicate data across regions, CloudFront for global access, and Route53 health checks for failover. Test DR plans regularly with controlled failover.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Configure CRR for DR
s3.put_bucket_replication(
Bucket='primary-us-east-1',
ReplicationConfiguration={
'Role': 'arn:aws:iam::123456789:role/replication-role',
'Rules': [{
'ID': 'DRReplication',
'Status': 'Enabled',
'Destination': {
'Bucket': 'arn:aws:s3:::dr-us-west-2',
'StorageClass': 'STANDARD_IA',
'ReplicationTime': {'Status': 'Enabled', 'Time': {'Minutes': 15}}
}
}]
}
)

# Route53 health check for failover
route53 = boto3.client('route53')
# Configure failover routing policy

🔍 Interviewer Notes: Tests disaster recovery planning.

❌ Common Mistakes:

  • Not testing DR failover regularly
  • Not considering data residency requirements
  • Replicating to same region (defeats purpose)

Q122: How do you implement S3 with AWS Backup for compliance?​

Technical Answer: AWS Backup provides centralized backup management for S3 with cross-region copy and compliance reporting. Configure backup plans with S3 as a resource.

Code/Config Example:

import boto3

backup = boto3.client('backup')

# Create backup plan
plan = backup.create_backup_plan(
BackupPlan={
'BackupPlanName': 'S3ComplianceBackup',
'Rules': [{
'RuleName': 'DailyBackup',
'TargetBackupVaultName': 'default',
'ScheduleExpression': 'cron(0 2 * * ? *)'
}]
}
)

# Assign S3 bucket to backup plan
backup.create_backup_selection(
BackupPlanId=plan['BackupPlanId'],
Selection={
'SelectionName': 'S3Buckets',
'IamRoleArn': 'arn:aws:iam::123456789:role/backup-role',
'Resources': ['arn:aws:s3:::compliance-bucket']
}
)

🔍 Interviewer Notes: Tests centralized backup strategies.

❌ Common Mistakes:

  • Not configuring IAM role for Backup
  • Confusing with S3 replication
  • Not considering backup costs

Q123: How do you use S3 with Amazon MQ for event-driven architecture?​

Technical Answer: S3 events can trigger Lambda which publishes to Amazon MQ (ActiveMQ/RabbitMQ). This decouples storage events from message consumers.

Code/Config Example:

import boto3
import json
import pika

def lambda_handler(event, context):
# Process S3 event
for record in event['Records']:
message = {
'bucket': record['s3']['bucket']['name'],
'key': record['s3']['object']['key'],
'event': record['eventName']
}

# Publish to RabbitMQ via MQ
# Connection handling simplified
connection = pika.BlockingConnection(
pika.URLParameters('amqps://mq-endpoint')
)
channel = connection.channel()
channel.basic_publish(
exchange='s3-events',
routing_key='object.created',
body=json.dumps(message)
)

🔍 Interviewer Notes: Tests message queue integration.

❌ Common Mistakes:

  • Not handling connection pooling
  • Lambda cold start with MQ connections
  • Not using dead-letter queues

Q124: How do you implement S3 conditional writes for concurrency control?​

Technical Answer: Conditional writes (If-None-Match: *) prevent overwriting existing objects. This provides optimistic concurrency control without locking.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Conditional write - only create if not exists
try:
s3.put_object(
Bucket='my-bucket',
Key='unique-id.txt',
Body=b'data',
IfNoneMatch='*'
)
print("Object created!")
except s3.exceptions.ClientError as e:
if e.response['Error']['Code'] == 'PreconditionFailed':
print("Object already exists!")

🔍 Interviewer Notes: Tests concurrency control patterns.

❌ Common Mistakes:

  • Not handling PreconditionFailed
  • Wrong condition header
  • Not understanding use cases

Q125: How do you use S3 with AWS Step Functions for workflows?​

Technical Answer: Step Functions orchestrate S3 operations using service integrations. Use S3 APIs directly without Lambda for copy, delete, and metadata operations.

Code/Config Example:

{
"Comment": "Process S3 File Workflow",
"StartAt": "CheckFile",
"States": {
"CheckFile": {
"Type": "Task",
"Resource": "arn:aws:states:::aws-sdk:s3:headObject",
"Parameters": {
"Bucket": "source-bucket",
"Key.$": "$.key"
},
"Next": "CopyFile"
},
"CopyFile": {
"Type": "Task",
"Resource": "arn:aws:states:::aws-sdk:s3:copyObject",
"Parameters": {
"Bucket": "dest-bucket",
"CopySource.$": "arn:aws:s3:::source-bucket/${$.key}",
"Key.$": "$.key"
},
"End": true
}
}
}

🔍 Interviewer Notes: Tests workflow orchestration.

❌ Common Mistakes:

  • Using Lambda when service integration exists
  • Not handling errors
  • Wrong IAM permissions

Q126: How do you implement S3 access logging analysis with Athena?​

Technical Answer: S3 server access logs can be analyzed with Athena for security auditing, cost analysis, and usage patterns. Create a table on log data and query.

Code/Config Example:

-- Create table for S3 access logs
CREATE EXTERNAL TABLE s3_access_logs (
bucket_owner string,
bucket string,
time string,
remote_ip string,
requester string,
request_id string,
operation string,
key string,
request_uri string,
http_status string,
error_code string,
bytes_sent bigint,
object_size bigint,
total_time string,
turnaround_time string,
referrer string,
user_agent string,
version_id string
)
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.RegexSerDe'
WITH SERDEPROPERTIES (
'input.regex'='([^ ]*) ([^ ]*) \\[(.*)\\] ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) \"([^\"]*)\" ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*)'
)
LOCATION 's3://log-bucket/access-logs/';

-- Query for errors
SELECT time, bucket, key, http_status, error_code
FROM s3_access_logs
WHERE http_status >= '400'
ORDER BY time DESC;

🔍 Interviewer Notes: Tests log analysis and security auditing.

❌ Common Mistakes:

  • Wrong regex for log format
  • Not partitioning by date
  • Expensive queries on busy buckets

Q127: How do you use S3 with Amazon Kinesis Data Firehose?​

Technical Answer: Kinesis Data Firehose delivers streaming data to S3 with buffering, compression, and optional Lambda transformation. Configure buffering size/time and output format.

Code/Config Example:

import boto3

firehose = boto3.client('firehose')

firehose.create_delivery_stream(
DeliveryStreamName='S3DeliveryStream',
S3DestinationConfiguration={
'RoleARN': 'arn:aws:iam::123456789:role/firehose-s3-role',
'BucketARN': 'arn:aws:s3:::streaming-data',
'Prefix': 'logs/!{timestamp:yyyy/MM/dd}/',
'BufferingHints': {
'SizeInMBs': 128,
'IntervalInSeconds': 300
},
'CompressionFormat': 'GZIP'
}
)

🔍 Interviewer Notes: Tests streaming data integration.

❌ Common Mistakes:

  • Not configuring IAM role
  • Wrong buffering settings
  • Not handling delivery errors

Q128: How do you implement S3 lifecycle with object tags?​

Technical Answer: Lifecycle rules can filter objects by tags for targeted transitions and expirations. This enables granular data management based on business metadata.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

lifecycle = {
'Rules': [
{
'ID': 'DeleteTempByTag',
'Status': 'Enabled',
'Filter': {'Tag': {'Key': 'Temp', 'Value': 'true'}},
'Expiration': {'Days': 7}
},
{
'ID': 'ArchiveByDepartment',
'Status': 'Enabled',
'Filter': {'Tag': {'Key': 'Department', 'Value': 'Finance'}},
'Transitions': [
{'Days': 90, 'StorageClass': 'GLACIER_IR'}
]
}
]
}

s3.put_bucket_lifecycle_configuration(
Bucket='my-bucket',
LifecycleConfiguration=lifecycle
)

🔍 Interviewer Notes: Tests tag-based data management.

❌ Common Mistakes:

  • Not adding tags to new objects
  • Conflicting lifecycle rules
  • Not testing tag filters

Q129: How do you use S3 with AWS Glue DataBrew?​

Technical Answer: DataBrew provides visual data preparation on S3 data. It creates profiles and transformations without code, storing results back to S3.

Code/Config Example:

import boto3

databrew = boto3.client('databrew')

# Create dataset from S3
dataset = databrew.create_dataset(
Name='S3Dataset',
Format='CSV',
Input={
'S3InputDefinition': {
'Bucket': 'data-bucket',
'Key': 'raw-data/'
}
}
)

# Create recipe for transformation
recipe = databrew.create_recipe(
Name='CleanData',
DatasetName='S3Dataset'
)

🔍 Interviewer Notes: Tests visual data preparation.

❌ Common Mistakes:

  • Not understanding DataBrew vs Glue
  • Not storing results back to S3
  • Cost of interactive preparation

Q130: How do you implement S3 presigned URLs with IP restrictions?​

Technical Answer: Presigned URLs can include IP address conditions in the policy. This restricts access to specific IP ranges for enhanced security.

Code/Config Example:

import boto3
import json

s3 = boto3.client('s3')

# Generate presigned URL with IP condition
# Note: IP restriction is in bucket policy, not in presigned URL directly
# Presigned URLs inherit bucket policy restrictions

# Bucket policy with IP restriction
policy = {
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::my-bucket/*",
"Condition": {
"IpAddress": {"aws:SourceIp": ["192.168.1.0/24"]}
}
}]
}

# Then generate presigned URL (inherits policy)
url = s3.generate_presigned_url(
'get_object',
Params={'Bucket': 'my-bucket', 'Key': 'file.txt'},
ExpiresIn=3600
)

🔍 Interviewer Notes: Tests conditional access patterns.

❌ Common Mistakes:

  • Trying to put IP in presigned URL (not possible)
  • Not understanding policy inheritance
  • Wrong CIDR notation

Q131: How do you use S3 with Amazon EMR for data processing?​

Technical Answer: EMR processes S3 data using Hadoop/Spark with S3 as the persistent layer. Configure S3 paths for input/output and use EMRFS for consistency.

Code/Config Example:

import boto3

emr = boto3.client('emr')

job_flow = emr.run_job_flow(
Name='SparkS3Processing',
ReleaseLabel='emr-6.15.0',
Applications=[{'Name': 'Spark'}],
Configurations=[{
'Classification': 'spark-defaults',
'Properties': {
'spark.hadoop.fs.s3a.aws.credentials.provider':
'com.amazonaws.auth.DefaultAWSCredentialsProviderChain'
}
}],
Steps=[{
'Name': 'ProcessData',
'ActionOnFailure': 'CONTINUE',
'HadoopJarStep': {
'Jar': 'command-runner.jar',
'Args': [
'spark-submit',
'--deploy-mode', 'cluster',
's3://my-bucket/scripts/process.py'
]
}
}]
)

🔍 Interviewer Notes: Tests big data processing patterns.

❌ Common Mistakes:

  • Not configuring IAM roles
  • Wrong S3 path format
  • Not optimizing for S3 throughput

Q132: How do you implement S3 replication with multiple destination buckets?​

Technical Answer: A single source bucket can replicate to multiple destinations using multiple replication rules. Each rule can have different filters, destinations, and storage classes.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

s3.put_bucket_replication(
Bucket='source-bucket',
ReplicationConfiguration={
'Role': 'arn:aws:iam::123456789:role/replication-role',
'Rules': [
{
'ID': 'ReplicateToDR',
'Priority': 1,
'Status': 'Enabled',
'Filter': {'Prefix': ''},
'Destination': {'Bucket': 'arn:aws:s3:::dr-bucket'}
},
{
'ID': 'ReplicateLogsToAnalytics',
'Priority': 2,
'Status': 'Enabled',
'Filter': {'Prefix': 'logs/'},
'Destination': {
'Bucket': 'arn:aws:s3:::analytics-bucket',
'StorageClass': 'STANDARD_IA'
}
}
]
}
)

🔍 Interviewer Notes: Tests complex replication topologies.

❌ Common Mistakes:

  • Not setting Priority for overlapping rules
  • Duplicate storage costs
  • Not managing replication permissions

Q133: How do you use S3 with Amazon Redshift Spectrum?​

Technical Answer: Redshift Spectrum queries S3 data directly without loading into Redshift. Define external tables pointing to S3 locations using Glue Data Catalog.

Code/Config Example:

-- Create external schema (uses Glue Data Catalog)
CREATE EXTERNAL SCHEMA spectrum_schema
FROM DATA CATALOG
DATABASE 'spectrum_db'
IAM_ROLE 'arn:aws:iam::123456789:role/spectrum-role';

-- Query S3 data directly
SELECT year, COUNT(*) as count
FROM spectrum_schema.user_logs
WHERE year >= 2020
GROUP BY year;

-- No data loaded into Redshift!

🔍 Interviewer Notes: Tests data lake query patterns.

❌ Common Mistakes:

  • Not configuring IAM role for Spectrum
  • Wrong S3 path in external table
  • Expensive queries (not partitioned)

Q134: How do you implement S3 object lock with compliance mode?​

Technical Answer: Compliance mode Object Lock cannot be overridden by anyone, including root user. Use for regulatory requirements where data must be immutable.

Code/Config Example:

import boto3
from datetime import datetime, timedelta

s3 = boto3.client('s3')

# Upload with Compliance mode
retain_until = datetime.now() + timedelta(days=365 * 7) # 7 years

s3.put_object(
Bucket='compliance-bucket',
Key='regulatory-doc.pdf',
Body=b'document data',
ObjectLockMode='COMPLIANCE',
ObjectLockRetainUntilDate=retain_until
)

# Attempt to delete (will fail in Compliance mode)
try:
s3.delete_object(Bucket='compliance-bucket', Key='regulatory-doc.pdf')
except Exception as e:
print("Cannot delete in Compliance mode!")

🔍 Interviewer Notes: Tests regulatory compliance patterns.

❌ Common Mistakes:

  • Confusing Governance vs Compliance mode
  • Not understanding immutability
  • Retention too long (cannot be shortened)

Q135: How do you use S3 with AWS Transfer Family for SFTP?​

Technical Answer: AWS Transfer Family provides SFTP, FTPS, and FTP access to S3. Users authenticate via service-managed, SSO, or custom identity providers.

Code/Config Example:

import boto3

transfer = boto3.client('transfer')

# Create SFTP server
server = transfer.create_server(
Protocols=['SFTP'],
IdentityProviderType='SERVICE_MANAGED',
EndpointType='PUBLIC'
)

# Add user with S3 access
transfer.create_user(
ServerId=server['ServerId'],
UserName='partner-upload',
HomeDirectory='s3://data-bucket/partner/',
Role='arn:aws:iam::123456789:role/transfer-s3-role',
SshPublicKeyBody='ssh-rsa AAAA...'
)

🔍 Interviewer Notes: Tests managed file transfer.

❌ Common Mistakes:

  • Not configuring IAM role
  • Wrong home directory format
  • Not enabling logging

Q136: How do you implement S3 performance with byte-range fetches?​

Technical Answer: Byte-range fetches download specific portions of objects for parallel downloads. This improves performance for large files and enables resumable downloads.

Code/Config Example:

import boto3
from concurrent.futures import ThreadPoolExecutor

s3 = boto3.client('s3')

def download_range(bucket, key, start, end):
response = s3.get_object(
Bucket=bucket,
Key=key,
Range=f'bytes={start}-{end}'
)
return (start, response['Body'].read())

def parallel_download(bucket, key, file_path, num_parts=4):
response = s3.head_object(Bucket=bucket, Key=key)
size = response['ContentLength']

part_size = size // num_parts
ranges = [(i * part_size, min((i+1) * part_size - 1, size - 1))
for i in range(num_parts)]

with open(file_path, 'wb') as f:
with ThreadPoolExecutor(max_workers=num_parts) as executor:
futures = [executor.submit(download_range, bucket, key, s, e)
for s, e in ranges]
for future in futures:
start, data = future.result()
f.seek(start)
f.write(data)

🔍 Interviewer Notes: Tests parallel download patterns.

❌ Common Mistakes:

  • Not handling incomplete ranges
  • Too many small ranges (overhead)
  • Not checking ContentRange

Q137: How do you use S3 with Amazon QuickSight for BI?​

Technical Answer: QuickSight connects to S3 via manifest files for business intelligence dashboards. Supports various formats and can refresh data on a schedule.

Code/Config Example:

import boto3

quicksight = boto3.client('quicksight')

# Create data source
quicksight.create_data_source(
AwsAccountId='123456789',
DataSourceId='s3-analytics-source',
Name='S3Analytics',
Type='S3',
DataSourceParameters={
'S3Parameters': {
'ManifestFileLocation': {
'Bucket': 'manifest-bucket',
'Key': 'quicksight-manifest.json'
}
}
},
RoleArn='arn:aws:iam::123456789:role/quicksight-s3-role'
)

# Manifest file (s3://manifest-bucket/quicksight-manifest.json)
# {"fileLocations": [{"URIs": ["s3://data-bucket/reports/"]}], "globalUploadSettings": {"format": "CSV"}}

🔍 Interviewer Notes: Tests BI integration.

❌ Common Mistakes:

  • Wrong manifest format
  • Not configuring IAM role
  • Not refreshing data

Q138: How do you implement S3 replication with KMS encryption?​

Technical Answer: Replicating KMS-encrypted objects requires the replication role to have decrypt permissions on source key and encrypt permissions on destination key.

Code/Config Example:

import boto3
import json

kms = boto3.client('kms')

# Update source KMS key policy
kms.put_key_policy(
KeyId='source-key-id',
PolicyName='default',
Policy=json.dumps({
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": {"AWS": "arn:aws:iam::123456789:role/replication-role"},
"Action": ["kms:Decrypt", "kms:GenerateDataKey"],
"Resource": "*"
}]
})
)

# Configure replication with KMS
s3.put_bucket_replication(
Bucket='source-bucket',
ReplicationConfiguration={
'Role': 'arn:aws:iam::123456789:role/replication-role',
'Rules': [{
'ID': 'EncryptedReplication',
'Status': 'Enabled',
'SourceSelectionCriteria': {
'SseKmsEncryptedObjects': {'Status': 'Enabled'}
},
'Destination': {
'Bucket': 'arn:aws:s3:::dest-bucket',
'EncryptionConfiguration': {
'ReplicaKmsKeyID': 'arn:aws:kms:us-west-2:123456789:key/dest-key'
}
}
}]
}
)

🔍 Interviewer Notes: Tests encrypted replication.

❌ Common Mistakes:

  • Not updating KMS key policy
  • Forgetting SourceSelectionCriteria
  • Different KMS keys mismatch

Q139: How do you use S3 with AWS Config rules for compliance?​

Technical Answer: AWS Config rules continuously monitor S3 compliance (encryption, public access, logging). Use managed rules or custom Lambda rules.

Code/Config Example:

import boto3

config = boto3.client('config')

# Enable S3 bucket SSL-only rule
config.put_config_rule(
ConfigRule={
'ConfigRuleName': 's3-bucket-ssl-requests-only',
'Description': 'Checks S3 SSL requests only',
'Scope': {
'ComplianceResourceTypes': ['AWS::S3::Bucket']
},
'Source': {
'Owner': 'AWS',
'SourceIdentifier': 'S3_BUCKET_SSL_REQUESTS_ONLY'
}
}
)

🔍 Interviewer Notes: Tests compliance automation.

❌ Common Mistakes:

  • Not enabling Config in all regions
  • Not using managed rules
  • Not remediating non-compliant buckets

Q140: How do you implement S3 with Amazon Macie for PII detection?​

Technical Answer: Macie uses machine learning to discover PII, PHI, and financial data in S3. It generates findings and can trigger automated remediation via EventBridge.

Code/Config Example:

import boto3

macie = boto3.client('macie2')

# Enable Macie
macie.enable_macie(FindingPublishingFrequency='SIX_HOURS')

# Create classification job
job = macie.create_classification_job(
JobType='SCHEDULED',
Name='PIIScan',
S3JobDefinition={
'BucketDefinitions': [{
'AccountId': '123456789',
'Buckets': ['sensitive-data-bucket']
}]
},
ScheduleFrequency={'DailySchedule': {}}
)

# Get findings
findings = macie.list_findings(
FindingCriteria={
'Criterion': {
'ClassificationDetails.JobId': {'eq': [job['JobId']]}
}
}
)

🔍 Interviewer Notes: Tests data protection automation.

❌ Common Mistakes:

  • Not enabling Macie in all regions
  • High cost for large buckets
  • Not automating remediation

Q141: How do you implement S3 cost optimization strategies?​

Technical Answer: Cost optimization uses storage class selection, lifecycle policies, intelligent-tiering, and cleanup of old versions. Monitor costs with Cost Explorer and S3 Storage Lens.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Cost optimization lifecycle
lifecycle = {
'Rules': [
{
'ID': 'OptimizeStorage',
'Status': 'Enabled',
'Filter': {'Prefix': ''},
'Transitions': [
{'Days': 30, 'StorageClass': 'INTELLIGENT_TIERING'}
],
'NoncurrentVersionExpiration': {'NoncurrentDays': 30}
},
{
'ID': 'DeleteOldLogs',
'Status': 'Enabled',
'Filter': {'Prefix': 'logs/temp/'},
'Expiration': {'Days': 7}
}
]
}

s3.put_bucket_lifecycle_configuration(
Bucket='my-bucket',
LifecycleConfiguration=lifecycle
)

🔍 Interviewer Notes: Tests cost management skills.

❌ Common Mistakes:

  • Not using Intelligent-Tiering for unknown patterns
  • Keeping old versions indefinitely
  • Not monitoring with Cost Explorer

Q142: How do you use S3 Storage Lens for cost visibility?​

Technical Answer: S3 Storage Lens provides organization-wide metrics on storage costs, access patterns, and optimization opportunities. Export data to S3 for analysis with Athena.

Code/Config Example:

import boto3

s3control = boto3.client('s3control')

s3control.put_storage_lens_configuration(
AccountId='123456789',
ConfigId='cost-optimization-lens',
StorageLensConfiguration={
'Id': 'cost-optimization-lens',
'IsEnabled': True,
'AccountLevel': {
'ActivityMetrics': {'IsEnabled': True},
'AdvancedCostOptimizationMetrics': {'IsEnabled': True}
},
'DataExport': {
'S3BucketDestination': {
'AccountId': '123456789',
'Arn': 'arn:aws:s3:::lens-exports',
'Format': 'CSV'
}
}
}
)

🔍 Interviewer Notes: Tests cost visibility tools.

❌ Common Mistakes:

  • Not enabling advanced cost metrics
  • Not exporting data for analysis
  • Ignoring recommendations

Q143: How do you implement S3 Inventory for unused data identification?​

Technical Answer: S3 Inventory reports object metadata including last access time. Analyze with Athena to identify unused data for archival or deletion.

Code/Config Example:

-- Find unused data (not accessed in 90 days)
SELECT key, size, last_modified_date, storage_class
FROM s3_inventory
WHERE last_modified_date < date_add('day', -90, current_date)
AND storage_class = 'STANDARD'
ORDER BY last_modified_date ASC;

🔍 Interviewer Notes: Tests data lifecycle management.

❌ Common Mistakes:

  • Not including last modified date in inventory
  • Wrong analysis (use storage class analysis)
  • Not automating cleanup

Q144: How do you use S3 with AWS Cost Anomaly Detection?​

Technical Answer: Cost Anomaly Detection identifies unusual S3 spending patterns. Configure monitors for S3 service and get alerts via SNS.

Code/Config Example:

import boto3

ce = boto3.client('ce')

# Create anomaly monitor for S3
ce.create_anomaly_monitor(
AnomalyMonitor={
'MonitorName': 'S3CostMonitor',
'MonitorType': 'DIMENSIONAL',
'MonitorDimension': 'SERVICE',
'MonitorSpecification': {
'Dimensions': {'Key': 'SERVICE', 'Values': ['Amazon Simple Storage Service']}
}
}
)

# Create alert subscription
ce.create_anomaly_subscription(
AnomalySubscription={
'SubscriptionName': 'S3Alerts',
'Threshold': 50.0, # 50% increase
'Frequency': 'DAILY',
'MonitorArnList': ['arn:aws:ce::123456789:anomalymonitor/...'],
'Subscribers': [{'Type': 'SNS', 'Address': 'arn:aws:sns:us-east-1:123456789:s3-alerts'}]
}
)

🔍 Interviewer Notes: Tests cost monitoring automation.

❌ Common Mistakes:

  • Not setting appropriate thresholds
  • Not monitoring all regions
  • Ignoring alerts

Q145: How do you implement S3 Intelligent-Tiering for cost optimization?​

Technical Answer: Intelligent-Tiering automatically moves objects between Frequent, Infrequent, and Archive tiers. It's ideal for unknown or changing access patterns with no retrieval fees.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Upload to Intelligent-Tiering
s3.put_object(
Bucket='my-bucket',
Key='unknown-pattern.bin',
Body=b'data',
StorageClass='INTELLIGENT_TIERING'
)

# Configure archive access (optional)
s3.put_bucket_intelligent_tiering_configuration(
Bucket='my-bucket',
Id='archive-config',
IntelligentTieringConfiguration={
'Status': 'Enabled',
'Tierings': [
{'Days': 90, 'AccessTier': 'ARCHIVE_ACCESS'},
{'Days': 180, 'AccessTier': 'DEEP_ARCHIVE_ACCESS'}
]
}
)

🔍 Interviewer Notes: Tests automated cost optimization.

❌ Common Mistakes:

  • Not considering monitoring fee per object
  • Setting archive too early
  • Using for small objects (<128KB monitoring fee)

Q146: How do you use S3 with Reserved Capacity for Glacier?​

Technical Answer: S3 Glacier Reserve Capacity provides discounted pricing for committed usage. Purchase capacity units in specific regions for 1 or 3 years.

Code/Config Example:

# Note: Reserved Capacity is purchased via AWS Console or CLI
# aws glacier purchase-provisioned-capacity --account-id 123456789

# Then upload to Glacier with reduced price
s3.put_object(
Bucket='archive-bucket',
Key='large-archive.tar',
Body=b'data',
StorageClass='GLACIER'
)

🔍 Interviewer Notes: Tests cost commitment strategies.

❌ Common Mistakes:

  • Not understanding it's for Glacier only
  • Wrong region for capacity
  • Not monitoring utilization

Q147: How do you implement S3 object lifecycle for cost control?​

Technical Answer: Lifecycle policies automate cost control by transitioning to cheaper storage classes and expiring old data. Use for log cleanup, temp file expiration, and archival.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

lifecycle = {
'Rules': [
{
'ID': 'LogRetention',
'Status': 'Enabled',
'Filter': {'Prefix': 'logs/'},
'Transitions': [
{'Days': 30, 'StorageClass': 'STANDARD_IA'},
{'Days': 90, 'StorageClass': 'GLACIER_IR'}
],
'Expiration': {'Days': 365}
},
{
'ID': 'TempFileCleanup',
'Status': 'Enabled',
'Filter': {'Tag': {'Key': 'Temp', 'Value': 'true'}},
'Expiration': {'Days': 1}
}
]
}

s3.put_bucket_lifecycle_configuration(
Bucket='my-bucket',
LifecycleConfiguration=lifecycle
)

🔍 Interviewer Notes: Tests automated cost controls.

❌ Common Mistakes:

  • Not considering minimum storage duration
  • Conflicting lifecycle rules
  • Not testing before applying

Q148: How do you use S3 Select to reduce data transfer costs?​

Technical Answer: S3 Select retrieves only needed data from objects, reducing data transfer costs. Use for large CSV/JSON files where only subset is needed.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Instead of downloading entire 1GB file
# Only retrieve matching rows
response = s3.select_object_content(
Bucket='my-bucket',
Key='large-dataset.csv',
Expression="SELECT * FROM s3object WHERE region = 'us-east-1'",
ExpressionType='SQL',
InputSerialization={'CSV': {'FileHeaderInfo': 'USE'}},
OutputSerialization={'JSON': {}}
)

# Process only matching data (much less than 1GB)
for event in response['Payload']:
if 'Records' in event:
print(event['Records']['Payload'].decode('utf-8'))

🔍 Interviewer Notes: Tests data retrieval optimization.

❌ Common Mistakes:

  • Using for small files (overhead)
  • Not handling large result sets
  • Wrong input serialization

Q149: How do you implement S3 batch delete for cost cleanup?​

Technical Answer: S3 Batch Operations can delete millions of objects matching specific criteria. Use with manifest files or S3 Inventory as input.

Code/Config Example:

import boto3

s3control = boto3.client('s3control')

# Create batch delete job
s3control.create_job(
AccountId='123456789',
Operation={
'S3DeleteObject': {}
},
Manifest={
'Spec': {'Format': 'S3BatchOperations_CSV_20180820', 'Fields': ['Bucket', 'Key']},
'Location': {'ObjectArn': 'arn:aws:s3:::manifest-bucket/delete-manifest.csv'}
},
Report={'Bucket': 'arn:aws:s3:::report-bucket', 'Enabled': True},
Priority=10,
RoleArn='arn:aws:iam::123456789:role/BatchDeleteRole'
)

🔍 Interviewer Notes: Tests large-scale cleanup operations.

❌ Common Mistakes:

  • Not creating proper manifest
  • Not setting up IAM role
  • Accidental deletion (test first!)

Q150: How do you use S3 with AWS Budgets for cost control?​

Technical Answer: AWS Budgets can alert on S3 spending thresholds. Create budgets specific to S3 service and get notifications via email or SNS.

Code/Config Example:

import boto3

budgets = boto3.client('budgets')

budgets.create_budget(
AccountId='123456789',
Budget={
'BudgetName': 'S3MonthlyBudget',
'BudgetLimit': {'Amount': '1000', 'Unit': 'USD'},
'TimeUnit': 'MONTHLY',
'BudgetType': 'COST',
'CostFilters': {
'Service': ['Amazon Simple Storage Service']
}
},
NotificationsWithSubscribers=[
{
'Notification': {
'NotificationType': 'ACTUAL',
'ComparisonOperator': 'GREATER_THAN',
'Threshold': 80.0,
'ThresholdType': 'PERCENTAGE'
},
'Subscribers': [{'SubscriptionType': 'EMAIL', 'Address': 'admin@example.com'}]
}
]
)

🔍 Interviewer Notes: Tests budget management.

❌ Common Mistakes:

  • Not filtering by S3 service
  • Not setting up notifications
  • Ignoring budget alerts

Q151: How do you implement S3 multipart upload for cost optimization?​

Technical Answer: Multipart upload enables parallel transfers, reducing time and potential retry costs. Use for files >100MB and configure part size for optimal throughput.

Code/Config Example:

import boto3
from concurrent.futures import ThreadPoolExecutor

s3 = boto3.client('s3')

def optimized_upload(bucket, key, file_path):
# Use larger part size for better throughput
config = boto3.s3.transfer.TransferConfig(
multipart_threshold=100 * 1024 * 1024, # 100MB
multipart_chunksize=100 * 1024 * 1024, # 100MB parts
max_concurrency=10
)

s3.upload_file(
file_path, bucket, key,
Config=config,
ExtraArgs={'ServerSideEncryption': 'AES256'}
)

🔍 Interviewer Notes: Tests transfer optimization.

❌ Common Mistakes:

  • Using default part size (too small)
  • Not using parallel uploads
  • Wrong thresholds

Q152: How do you use S3 with SQS for event processing costs?​

Technical Answer: S3 event notifications to SQS provide reliable, cost-effective event processing. SQS is cheaper than SNS for many use cases and supports batch processing.

Code/Config Example:

import boto3

s3 = boto3.client('s3')
sqs = boto3.client('sqs')

# Configure S3 to send events to SQS
s3.put_bucket_notification_configuration(
Bucket='my-bucket',
NotificationConfiguration={
'QueueConfigurations': [{
'Id': 'ToSQS',
'QueueArn': 'arn:aws:sqs:us-east-1:123456789:my-queue',
'Events': ['s3:ObjectCreated:*']
}]
}
)

# Process messages in batch (cost efficient)
response = sqs.receive_message(
QueueUrl='https://sqs.us-east-1.amazonaws.com/123456789/my-queue',
MaxNumberOfMessages=10
)

🔍 Interviewer Notes: Tests cost-effective event processing.

❌ Common Mistakes:

  • Not batching SQS messages
  • Not configuring SQS permissions
  • Wrong queue URL

Q153: How do you implement S3 presigned URLs for cost control?​

Technical Answer: Presigned URLs enable direct-to-S3 uploads, reducing server data transfer costs. Set expiration and file size limits to prevent abuse.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Generate presigned POST with limits
post = s3.generate_presigned_post(
Bucket='my-bucket',
Key='uploads/${filename}',
Fields={'acl': 'private'},
Conditions=[
['content-length-range', 0, 10485760], # Max 10MB
['starts-with', '$key', 'uploads/']
],
ExpiresIn=3600
)
# Clients upload directly to S3 (no proxy costs!)

🔍 Interviewer Notes: Tests direct upload patterns.

❌ Common Mistakes:

  • Not setting file size limits
  • Expiration too long
  • Not validating uploads server-side

Q154: How do you use S3 lifecycle transitions for cost optimization?​

Technical Answer: Lifecycle transitions move objects to cheaper storage classes. Understand minimum storage durations: Standard-IA (30 days), Glacier (90 days), Deep Archive (180 days).

Code/Config Example:

import boto3

s3 = boto3.client('s3')

lifecycle = {
'Rules': [{
'ID': 'CostOptimization',
'Status': 'Enabled',
'Filter': {'Prefix': ''},
'Transitions': [
{'Days': 30, 'StorageClass': 'STANDARD_IA'},
{'Days': 120, 'StorageClass': 'GLACIER_IR'}, # 90+30=120
{'Days': 210, 'StorageClass': 'DEEP_ARCHIVE'} # 180+30=210
]
}]
}

# Note: Objects transitioned before minimum duration incur penalty

🔍 Interviewer Notes: Tests lifecycle cost optimization.

❌ Common Mistakes:

  • Transitioning before minimum duration (penalty)
  • Not accounting for transition costs
  • Wrong order of transitions

Q155: How do you implement S3 request metrics for cost analysis?​

Technical Answer: S3 request metrics show API call patterns. Analyze with CloudWatch to identify expensive operations and optimize access patterns.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Enable request metrics
s3.put_bucket_metrics_configuration(
Bucket='my-bucket',
Id='RequestMetrics',
MetricsConfiguration={'Id': 'RequestMetrics', 'Filter': {'Prefix': ''}}
)

# Query CloudWatch for cost analysis
cloudwatch = boto3.client('cloudwatch')

response = cloudwatch.get_metric_statistics(
Namespace='AWS/S3',
MetricName='GetRequests',
Dimensions=[
{'Name': 'BucketName', 'Value': 'my-bucket'}
],
StartTime='2024-01-01',
EndTime='2024-01-31',
Period=86400,
Statistics=['Sum']
)

🔍 Interviewer Notes: Tests request cost analysis.

❌ Common Mistakes:

  • Not enabling request metrics (disabled by default)
  • Wrong CloudWatch query
  • Not monitoring all operations

Q156: How do you use S3 with CloudFront for cost optimization?​

Technical Answer: CloudFront reduces S3 data transfer costs by caching content at edge locations. Use for frequently accessed, publicly readable content.

Code/Config Example:

import boto3

cloudfront = boto3.client('cloudfront')

# CloudFront caches S3 content, reducing transfer costs
distribution = cloudfront.create_distribution(
DistributionConfig={
'Origins': {'Items': [{
'Id': 'S3Origin',
'DomainName': 'my-bucket.s3.amazonaws.com',
'S3OriginConfig': {}
}]},
'DefaultCacheBehavior': {
'TargetOriginId': 'S3Origin',
'ViewerProtocolPolicy': 'redirect-to-https'
},
'Enabled': True
}
)
# Data transfer via CloudFront is cheaper than S3 directly

🔍 Interviewer Notes: Tests CDN cost optimization.

❌ Common Mistakes:

  • Using CloudFront for private content (expensive)
  • Not configuring cache policies
  • Wrong use cases

Q157: How do you implement S3 object tagging for cost allocation?​

Technical Answer: Cost allocation tags enable tracking S3 costs by project, department, or environment. Activate tags in Billing console first.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Tag bucket for cost allocation
s3.put_bucket_tagging(
Bucket='my-bucket',
Tagging={
'TagSet': [
{'Key': 'Department', 'Value': 'Engineering'},
{'Key': 'Environment', 'Value': 'Production'},
{'Key': 'CostCenter', 'Value': 'CC123'}
]
}
)

# Also tag objects
s3.put_object_tagging(
Bucket='my-bucket',
Key='report.pdf',
Tagging={'TagSet': [{'Key': 'Project', 'Value': 'Q1Report'}]}
)

🔍 Interviewer Notes: Tests cost allocation strategies.

❌ Common Mistakes:

  • Not activating tags in Billing console
  • Not using consistent tagging
  • Forgetting tags on new objects

Q158: How do you use S3 with Amazon EBS for cost-effective storage?​

Technical Answer: Use S3 for durable object storage and EBS for block storage with compute. Don't use S3 as filesystem (use EFS/FSx instead).

Code/Config Example:

# Conceptual: S3 for data lake, EBS for processing
# Store raw data in S3 (cheap, durable)
s3.put_object(Bucket='data-lake', Key='raw/input.csv', Body=data)

# Process with EC2 + EBS (temporary processing)
# EBS volume for temporary working storage
# Results back to S3 (archive or share)

🔍 Interviewer Notes: Tests storage tier selection.

❌ Common Mistakes:

  • Using S3 as filesystem
  • Not understanding storage types
  • Wrong service for workload

Q159: How do you implement S3 replication for disaster recovery costs?​

Technical Answer: CRR replicates data to another region for DR. Consider replication costs, storage costs in destination, and use RTC only when needed.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Cost-effective DR: replicate only critical data
s3.put_bucket_replication(
Bucket='source-bucket',
ReplicationConfiguration={
'Role': 'arn:aws:iam::123456789:role/replication',
'Rules': [{
'ID': 'CriticalDataOnly',
'Status': 'Enabled',
'Filter': {'Tag': {'Key': 'Critical', 'Value': 'true'}},
'Destination': {
'Bucket': 'arn:aws:s3:::dr-bucket',
'StorageClass': 'STANDARD_IA' # Cheaper in DR region
}
}]
}
)

🔍 Interviewer Notes: Tests cost-effective DR.

❌ Common Mistakes:

  • Replicating everything (expensive)
  • Not using cheaper storage class in DR
  • RTC when not needed (extra cost)

Q160: How do you use S3 Inventory for cost reporting?​

Technical Answer: S3 Inventory provides daily reports of object metadata. Analyze with Athena to identify cost optimization opportunities.

Code/Config Example:

-- Find objects in wrong storage class
SELECT key, size, storage_class
FROM s3_inventory
WHERE storage_class = 'STANDARD'
AND size < 128 * 1024 # Small objects in Standard
ORDER BY size DESC;

-- Find duplicate data
SELECT key, COUNT(*) as count
FROM s3_inventory
GROUP BY key
HAVING COUNT(*) > 1;

🔍 Interviewer Notes: Tests cost analysis with Inventory.

❌ Common Mistakes:

  • Not including all fields in Inventory
  • Not automating analysis
  • Wrong output format (use Parquet)

Q161: How do you implement S3 troubleshooting with CloudTrail?​

Technical Answer: CloudTrail logs all S3 API calls for auditing and troubleshooting. Enable data events for object-level logging (PutObject, GetObject, DeleteObject).

Code/Config Example:

import boto3

cloudtrail = boto3.client('cloudtrail')

# Enable CloudTrail with S3 data events
cloudtrail.put_event_selectors(
TrailName='my-trail',
EventSelectors=[{
'ReadWriteType': 'All',
'IncludeManagementEvents': True,
'DataResources': [{
'Type': 'AWS::S3::Object',
'Values': ['arn:aws:s3:::my-bucket/']
}]
}]
)

# Query CloudTrail logs with Athena
# SELECT * FROM cloudtrail_logs WHERE eventname = 'DeleteObject'

🔍 Interviewer Notes: Tests auditing and troubleshooting.

❌ Common Mistakes:

  • Not enabling data events (only management by default)
  • High CloudTrail costs for busy buckets
  • Not filtering to specific buckets

Q162: How do you monitor S3 with CloudWatch metrics?​

Technical Answer: S3 publishes metrics to CloudWatch: bucket size, object count, and request metrics (if enabled). Use metrics for alerting and dashboards.

Code/Config Example:

import boto3

cloudwatch = boto3.client('cloudwatch')

# Get bucket size metric
response = cloudwatch.get_metric_statistics(
Namespace='AWS/S3',
MetricName='BucketSizeBytes',
Dimensions=[
{'Name': 'BucketName', 'Value': 'my-bucket'},
{'Name': 'StorageType', 'Value': 'StandardStorage'}
],
StartTime='2024-01-01',
EndTime='2024-01-31',
Period=86400,
Statistics=['Average']
)

🔍 Interviewer Notes: Tests monitoring and observability.

❌ Common Mistakes:

  • Not enabling request metrics
  • Wrong dimension names
  • Not creating alarms

Q163: How do you implement S3 access denied troubleshooting?​

Technical Answer: Access denied errors can be from bucket policies, IAM policies, ACLs, or Block Public Access. Check CloudTrail for policy evaluation and test with IAM Policy Simulator.

Code/Config Example:

import boto3

# Test access with IAM Policy Simulator
iam = boto3.client('iam')

response = iam.simulate_principal_policy(
PolicySourceArn='arn:aws:iam::123456789:user/testuser',
ActionNames=['s3:GetObject'],
ResourceArns=['arn:aws:s3:::my-bucket/*']
)
print(response['EvaluationResults'])

🔍 Interviewer Notes: Tests troubleshooting skills.

❌ Common Mistakes:

  • Not checking all policy layers
  • Forgetting Block Public Access
  • Not checking resource policy (bucket policy)

Q164: How do you use S3 with AWS Trusted Advisor?​

Technical Answer: Trusted Advisor checks S3 buckets for security (public access), cost optimization (unencrypted buckets), and performance (large numbers of objects).

Code/Config Example:

import boto3

support = boto3.client('support')

# Get Trusted Advisor checks
response = support.describe_trusted_advisor_checks(
language='en'
)

# Find S3-related checks
for check in response['checks']:
if 'S3' in check['category'] or 'S3' in check['name']:
print(f"Check: {check['name']}, ID: {check['id']}")

🔍 Interviewer Notes: Tests using AWS advisory tools.

❌ Common Mistakes:

  • Not using Trusted Advisor
  • Ignoring recommendations
  • Not having Business/Enterprise support for full features

Q165: How do you implement S3 replication failure troubleshooting?​

Technical Answer: Replication failures appear in S3 Replication Metrics. Check IAM role permissions, KMS key policies, and storage class compatibility.

Code/Config Example:

import boto3

cloudwatch = boto3.client('cloudwatch')

# Check replication failed operations
response = cloudwatch.get_metric_statistics(
Namespace='AWS/S3',
MetricName='OperationsFailedReplication',
Dimensions=[
{'Name': 'BucketName', 'Value': 'source-bucket'},
{'Name': 'RuleId', 'Value': 'ReplicationRule'}
],
StartTime='2024-01-01',
EndTime='2024-01-31',
Period=3600,
Statistics=['Sum']
)

🔍 Interviewer Notes: Tests replication troubleshooting.

❌ Common Mistakes:

  • Not enabling replication metrics
  • Not checking IAM role
  • Not monitoring replication backlog

Q166: How do you use S3 with AWS Health Dashboard?​

Technical Answer: AWS Health Dashboard shows S3 service disruptions and scheduled maintenance. Subscribe to events for proactive monitoring.

Code/Config Example:

import boto3

health = boto3.client('health')

# Get S3-related events
response = health.describe_events_by_organization(
filter={
'service': ['S3'],
'eventTypeCategory': ['issue', 'scheduledChange']
}
)

for event in response['events']:
print(f"Event: {event['eventTypeCode']}, Status: {event['statusCode']}")

🔍 Interviewer Notes: Tests service health awareness.

❌ Common Mistakes:

  • Not monitoring AWS Health
  • Not setting up personal health dashboard
  • Missing scheduled maintenance notifications

Q167: How do you implement S3 performance troubleshooting?​

Technical Answer: Performance issues can be from hot partitions, network latency, or throttling. Use CloudWatch metrics and distribute keys to avoid hot partitions.

Code/Config Example:

import boto3
import hashlib

# Fix hot partition issue
def get_distributed_key(key):
hash_prefix = hashlib.md5(key.encode()).hexdigest()[:4]
return f"{hash_prefix}/{key}"

# Use distributed keys
s3 = boto3.client('s3')
key = get_distributed_key('data/2024/01/file.csv')
s3.put_object(Bucket='my-bucket', Key=key, Body=b'data')

🔍 Interviewer Notes: Tests performance troubleshooting.

❌ Common Mistakes:

  • Sequential key naming
  • Not monitoring 503 errors
  • Not using multipart upload for large files

Q168: How do you use S3 with VPC Flow Logs for network troubleshooting?​

Technical Answer: VPC Flow Logs capture network traffic to S3. Analyze with Athena to troubleshoot connectivity issues to S3 endpoints.

Code/Config Example:

import boto3

ec2 = boto3.client('ec2')

# Create Flow Log to S3
ec2.create_flow_logs(
ResourceIds=['sg-12345678'],
ResourceType='SecurityGroup',
TrafficType='ALL',
LogDestinationType='s3',
LogDestination='arn:aws:s3:::flow-logs-bucket'
)

# Query with Athena to troubleshoot S3 connectivity
# SELECT * FROM vpc_flow_logs WHERE dstaddr LIKE '%s3%' AND action='REJECT'

🔍 Interviewer Notes: Tests network troubleshooting.

❌ Common Mistakes:

  • Not sending Flow Logs to S3
  • Not querying logs properly
  • Not troubleshooting security group rules

Q169: How do you implement S3 presigned URL troubleshooting?​

Technical Answer: Presigned URL issues can be from clock skew, wrong region, expired URL, or missing permissions. Test with curl and check expiration time.

Code/Config Example:

import boto3
from datetime import datetime, timedelta

# Generate URL with extended expiration for testing
url = s3.generate_presigned_url(
'get_object',
Params={'Bucket': 'my-bucket', 'Key': 'test.txt'},
ExpiresIn=86400 # 24 hours for testing
)

# Test with curl
# curl -v "url" 2>&1 | grep -i "x-amz-expiration"

🔍 Interviewer Notes: Tests URL troubleshooting.

❌ Common Mistakes:

  • Clock skew on client machines
  • Wrong region in client
  • Not handling expired URLs

Q170: How do you use S3 with AWS X-Ray for tracing?​

Technical Answer: X-Ray traces S3 API calls in distributed applications. Use X-Ray SDK to trace requests and identify performance bottlenecks.

Code/Config Example:

from aws_xray_sdk.core import xray_recorder
from aws_xray_sdk.integration import boto3 as xray_boto3

# Patch boto3 for X-Ray tracing
xray_boto3.patch()

xray_recorder.begin_segment('S3Operation')

s3 = boto3.client('s3')
response = s3.get_object(Bucket='my-bucket', Key='test.txt')

xray_recorder.end_segment()

🔍 Interviewer Notes: Tests distributed tracing.

❌ Common Mistakes:

  • Not patching boto3
  • Not configuring X-Ray daemon
  • High overhead for simple operations

Q171: How do you implement S3 storage class analysis troubleshooting?​

Technical Answer: Storage Class Analysis provides recommendations for lifecycle transitions. Check analysis results after 30 days and verify recommendations.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Get analytics configuration
response = s3.get_bucket_analytics_configuration(
Bucket='my-bucket',
Id='AccessPatternAnalysis'
)

# Check if analysis is enabled and exporting
print(response['AnalyticsConfiguration'])

🔍 Interviewer Notes: Tests analytics troubleshooting.

❌ Common Mistakes:

  • Not waiting 30 days for analysis
  • Not configuring data export
  • Not acting on recommendations

Q172: How do you use S3 with Amazon Detective for investigation?​

Technical Answer: Detective analyzes CloudTrail logs to investigate security issues in S3. It creates visualization graphs of API calls and IAM entities.

Code/Config Example:

import boto3

detective = boto3.client('detective')

# Get investigation results (after Detective processes CloudTrail)
response = detective.list_graphs()

# Detective uses CloudTrail data automatically
# No direct S3 integration - uses CloudTrail logs

🔍 Interviewer Notes: Tests security investigation.

❌ Common Mistakes:

  • Not enabling CloudTrail data events
  • Not understanding Detective analyzes CloudTrail
  • Not using for security investigations

Q173: How do you implement S3 multipart upload troubleshooting?​

Technical Answer: Failed multipart uploads leave parts in S3. Use AbortIncompleteMultipartUpload lifecycle rule and list/abort pending uploads manually.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# List incomplete multipart uploads
response = s3.list_multipart_uploads(Bucket='my-bucket')

for upload in response.get('Uploads', []):
print(f"UploadId: {upload['UploadId']}, Key: {upload['Key']}")

# Abort old uploads
s3.abort_multipart_upload(
Bucket='my-bucket',
Key=upload['Key'],
UploadId=upload['UploadId']
)

🔍 Interviewer Notes: Tests multipart troubleshooting.

❌ Common Mistakes:

  • Not configuring lifecycle rule for abort
  • Leaving orphaned parts (storage costs)
  • Not monitoring incomplete uploads

Q174: How do you use S3 with AWS Systems Manager for configuration?​

Technical Answer: Systems Manager Parameter Store can store S3 bucket configurations. Use for centralized configuration management of S3-related settings.

Code/Config Example:

import boto3

ssm = boto3.client('ssm')

# Store S3 configuration
ssm.put_parameter(
Name='/myapp/s3/bucket-name',
Value='my-app-bucket',
Type='String',
Overwrite=True
)

# Retrieve in application
response = ssm.get_parameter(Name='/myapp/s3/bucket-name')
bucket_name = response['Parameter']['Value']

🔍 Interviewer Notes: Tests configuration management.

❌ Common Mistakes:

  • Not using Parameter Store for config
  • Hardcoding bucket names
  • Not encrypting sensitive config

Q175: How do you implement S3 Glacier restore troubleshooting?​

Technical Answer: Glacier restore issues can be from wrong tier selection, expired restores, or not checking restore status. Monitor restore jobs and handle failures.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Check restore status
response = s3.head_object(Bucket='my-bucket', Key='archive.zip')

if 'Restore' in response:
print(response['Restore']) # Shows expiry date

# Monitor restore jobs
# Use S3 Batch Operations for large-scale restores

🔍 Interviewer Notes: Tests Glacier troubleshooting.

❌ Common Mistakes:

  • Not checking restore status
  • Accessing before restore completes
  • Not handling restore failures

Q176: How do you use S3 with AWS Resilience Hub?​

Technical Answer: Resilience Hub assesses S3 architecture for reliability. It evaluates replication, backup, and disaster recovery configurations.

Code/Config Example:

import boto3

resiliencehub = boto3.client('resiliencehub')

# Create resiliency assessment for S3
response = resiliencehub.create_app(
Name='S3App',
AppTemplateBody='{"resources": [{"id": "my-bucket", "type": "AWS::S3::Bucket"}]}'
)

# Publish app for assessment
resiliencehub.publish_app_version(AppArn=response['AppArn'])

🔍 Interviewer Notes: Tests resilience assessment.

❌ Common Mistakes:

  • Not assessing S3 resilience
  • Not implementing DR for critical buckets
  • Not testing failover

Q177: How do you implement S3 cost anomaly troubleshooting?​

Technical Answer: Cost anomalies can be from unexpected data transfer, storage class changes, or replication. Use Cost Explorer and S3 Storage Lens to identify anomalies.

Code/Config Example:

import boto3

ce = boto3.client('ce')

# Get S3 cost anomaly details
response = ce.get_anomalies(
DateInterval={'StartDate': '2024-01-01', 'EndDate': '2024-01-31'}
)

for anomaly in response['Anomalies']:
print(f"Anomaly: {anomaly['AnomalyId']}, Score: {anomaly['AnomalyScore']}")

🔍 Interviewer Notes: Tests cost anomaly detection.

❌ Common Mistakes:

  • Not setting up cost anomaly detection
  • Not investigating anomalies
  • Not tagging resources for cost allocation

Q178: How do you use S3 with AWS Security Hub?​

Technical Answer: Security Hub aggregates S3 security findings from GuardDuty, Macie, and Config. Use for centralized security posture management.

Code/Config Example:

import boto3

securityhub = boto3.client('securityhub')

# Get S3-related findings
response = securityhub.get_findings(
Filters={
'ResourceType': [{'Value': 'AwsS3Bucket', 'Comparison': 'EQUALS'}],
'RecordState': [{'Value': 'ACTIVE', 'Comparison': 'EQUALS'}]
}
)

for finding in response['Findings']:
print(f"Finding: {finding['Title']}, Severity: {finding['Severity']['Label']}")

🔍 Interviewer Notes: Tests centralized security management.

❌ Common Mistakes:

  • Not enabling Security Hub
  • Not enabling S3 security standards
  • Not remediating findings

Q179: How do you implement S3 folder simulation with prefixes?​

Technical Answer: S3 doesn't have real folders - use prefixes with / delimiter. List objects with prefix and delimiter to simulate folder structure.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# List "folder" contents (simulate folders)
response = s3.list_objects_v2(
Bucket='my-bucket',
Prefix='documents/',
Delimiter='/'
)

# CommonPrefixes are "folders"
for prefix in response.get('CommonPrefixes', []):
print(f"Folder: {prefix['Prefix']}")

# Contents are files
for obj in response.get('Contents', []):
print(f"File: {obj['Key']}")

🔍 Interviewer Notes: Tests understanding of S3 structure.

❌ Common Mistakes:

  • Thinking S3 has real folders
  • Not using delimiter for folder simulation
  • Not handling pagination

Q180: How do you use S3 with AWS Backup audit manager?​

Technical Answer: Backup Audit Manager generates compliance reports for S3 backups. Configure audit framework for S3 backup compliance.

Code/Config Example:

import boto3

backup = boto3.client('backup')

# Create audit report for S3 backups
backup.create_report_plan(
ReportPlanName='S3BackupAudit',
ReportDeliveryChannel={
'S3BucketName': 'audit-reports-bucket',
'Formats': ['REPORT_CSV_JSON']
},
ReportSetting={
'ReportTemplate': 'BACKUP_JOB_REPORT'
}
)

🔍 Interviewer Notes: Tests backup compliance auditing.

❌ Common Mistakes:

  • Not auditing S3 backups
  • Not generating compliance reports
  • Not automating audit workflows

Q181: How do you implement S3 data recovery strategies?​

Technical Answer: Data recovery uses versioning, replication, and backups. Restore from Glacier, recover deleted versions, and use CRR for disaster recovery.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Recover deleted version (if versioning enabled)
response = s3.list_object_versions(
Bucket='my-bucket',
Prefix='important.txt'
)

# Get previous version
for version in response.get('Versions', []):
if not version['IsLatest']:
# Copy previous version to current
s3.copy_object(
Bucket='my-bucket',
Key='important.txt',
CopySource={'Bucket': 'my-bucket', 'Key': 'important.txt', 'VersionId': version['VersionId']}
)
break

🔍 Interviewer Notes: Tests data recovery strategies.

❌ Common Mistakes:

  • Not enabling versioning before recovery needed
  • Not testing recovery procedures
  • Relying only on replication (not backup)

Q182: How do you implement S3 cross-region backup strategies?​

Technical Answer: Cross-region backups use CRR, AWS Backup, or custom scripts. Ensure backups are in different region than source for disaster recovery.

Code/Config Example:

import boto3

# Use AWS Backup for cross-region
backup = boto3.client('backup')

backup.create_backup_plan(
BackupPlan={
'BackupPlanName': 'CrossRegionBackup',
'Rules': [{
'RuleName': 'BackupToDR',
'TargetBackupVaultName': 'default',
'ScheduleExpression': 'cron(0 2 * * ? *)',
'CopyActions': [{
'DestinationBackupVaultArn': 'arn:aws:backup:us-west-2:123456789:backup-vault:default'
}]
}]
}
)

🔍 Interviewer Notes: Tests disaster recovery planning.

❌ Common Mistakes:

  • Not backing up to different region
  • Not testing restore procedures
  • Not considering backup costs

Q183: How do you use S3 with AWS Backup Vault Lock?​

Technical Answer: Backup Vault Lock prevents deletion of backups for compliance. Configure retention periods and WORM (Write Once Read Many) protection.

Code/Config Example:

import boto3

backup = boto3.client('backup')

# Create vault with lock
backup.create_backup_vault(
BackupVaultName='ComplianceVault',
BackupVaultTags={'Purpose': 'Compliance'}
)

# Add vault lock (irreversible!)
backup.put_backup_vault_lock_configuration(
BackupVaultName='ComplianceVault',
MinRetentionDays=365,
MaxRetentionDays=2555 # 7 years
)

🔍 Interviewer Notes: Tests compliance backup strategies.

❌ Common Mistakes:

  • Vault Lock is irreversible (test first!)
  • Not understanding WORM
  • Wrong retention periods

Q184: How do you implement S3 deleted object recovery?​

Technical Answer: Recover deleted objects using versioning (if delete markers present) or S3 Batch Operations to restore from backup.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Remove delete marker (restores previous version)
response = s3.list_object_versions(
Bucket='my-bucket',
Prefix='deleted-file.txt'
)

for version in response.get('DeleteMarkers', []):
if version['IsLatest']:
# Delete the delete marker = restore
s3.delete_object(
Bucket='my-bucket',
Key='deleted-file.txt',
VersionId=version['VersionId']
)
print("File restored!")
break

🔍 Interviewer Notes: Tests versioning recovery.

❌ Common Mistakes:

  • Not enabling versioning before deletion
  • Deleting delete marker (not restoring)
  • Not understanding delete markers

Q185: How do you use S3 with AWS Elastic Disaster Recovery?​

Technical Answer: AWS Elastic Disaster Recovery (DRS) replicates servers to AWS. Use for application-level DR, not just S3 data.

Code/Config Example:

# DRS is primarily console/agent-based
# Use DRS for EC2 instances that use S3

# S3 data uses CRR for DR
s3.put_bucket_replication(
Bucket='source-bucket',
ReplicationConfiguration={
'Rules': [{
'Destination': {
'Bucket': 'arn:aws:s3:::dr-bucket-us-west-2'
}
}]
}
)

🔍 Interviewer Notes: Tests comprehensive DR strategies.

❌ Common Mistakes:

  • Using DRS for S3-only workloads
  • Not testing DR failover
  • Not considering RTO/RPO requirements

Q186: How do you implement S3 data validation and integrity checks?​

Technical Answer: Use checksums (MD5, SHA256) for data integrity. S3 provides ETag (usually MD5) and supports user-defined checksums.

Code/Config Example:

import boto3
import hashlib

s3 = boto3.client('s3')

# Calculate checksum before upload
with open('file.zip', 'rb') as f:
md5 = hashlib.md5(f.read()).hexdigest()

# Upload with checksum
s3.put_object(
Bucket='my-bucket',
Key='file.zip',
Body=open('file.zip', 'rb'),
ContentMD5=md5 # Base64 encoded
)

# Verify after download
response = s3.get_object(Bucket='my-bucket', Key='file.zip')
# Compare ETag with expected MD5

🔍 Interviewer Notes: Tests data integrity patterns.

❌ Common Mistakes:

  • Not validating uploads
  • Wrong checksum format (need Base64)
  • Not handling multipart ETags (not MD5)

Q187: How do you use S3 with AWS DataSync for disaster recovery?​

Technical Answer: DataSync replicates data between S3 buckets across regions for DR. Configure continuous replication with monitoring.

Code/Config Example:

import boto3

datasync = boto3.client('datasync')

# Create locations
source_loc = datasync.create_location_s3(
S3BucketArn='arn:aws:s3:::primary-bucket',
Subdirectory='critical-data/',
S3Config={'BucketAccessRoleArn': 'arn:aws:iam::123456789:role/datasync'}
)

dest_loc = datasync.create_location_s3(
S3BucketArn='arn:aws:s3:::dr-bucket',
Subdirectory='critical-data/',
S3Config={'BucketAccessRoleArn': 'arn:aws:iam::123456789:role/datasync'}
)

# Create task with schedule
datasync.create_task(
SourceLocationArn=source_loc['LocationArn'],
DestinationLocationArn=dest_loc['LocationArn'],
Name='DRSync',
Schedule={'ScheduleExpression': 'cron(0 */1 * * ? *)'} # Hourly
)

🔍 Interviewer Notes: Tests DR data replication.

❌ Common Mistakes:

  • Not monitoring DataSync tasks
  • Not configuring IAM roles
  • Not testing failover

Q188: How do you implement S3 bucket recovery from accidental deletion?​

Technical Answer: Prevent bucket deletion with S3 Block Public Access and IAM policies. Recover objects from versioning or CRR destination if bucket is deleted.

Code/Config Example:

import boto3

# Prevent bucket deletion with IAM
iam = boto3.client('iam')

# Attach policy that denies DeleteBucket
policy = {
"Version": "2012-10-17",
"Statement": [{
"Effect": "Deny",
"Action": "s3:DeleteBucket",
"Resource": "arn:aws:s3:::critical-bucket"
}]
}

# If bucket deleted, recreate and sync from DR
# aws s3 sync s3://dr-bucket s3://new-primary-bucket

🔍 Interviewer Notes: Tests prevention and recovery.

❌ Common Mistakes:

  • Not preventing bucket deletion
  • Not having DR bucket
  • Not documenting recovery procedures

Q189: How do you use S3 with AWS Systems Manager for DR?​

Technical Answer: Systems Manager can run automation documents to failover S3 resources. Use for orchestrated DR procedures.

Code/Config Example:

import boto3

ssm = boto3.client('ssm')

# Run automation for S3 failover
ssm.start_automation_execution(
DocumentName='AWS-RestoreS3FromBackup',
Parameters={
'BucketName': ['critical-bucket'],
'BackupLocation': ['arn:aws:s3:::backup-bucket']
}
)

🔍 Interviewer Notes: Tests automated DR orchestration.

❌ Common Mistakes:

  • Not automating DR procedures
  • Not testing automation
  • Not documenting runbooks

Q190: How do you implement S3 cost anomaly recovery?​

Technical Answer: Cost anomalies can result from unexpected data uploads or replication. Use Cost Explorer and S3 Inventory to identify and remediate.

Code/Config Example:

import boto3

ce = boto3.client('ce')

# Investigate cost anomaly
response = ce.get_cost_and_usage(
TimePeriod={'Start': '2024-01-01', 'End': '2024-01-31'},
Granularity='DAILY',
Metrics=['UnblendedCost'],
Filter={
'Dimensions': {
'Key': 'SERVICE',
'Values': ['Amazon Simple Storage Service']
}
}
)

# Identify spike and investigate with S3 Inventory

🔍 Interviewer Notes: Tests cost anomaly management.

❌ Common Mistakes:

  • Not setting up cost alerts
  • Not investigating anomalies
  • Not implementing cleanup

Q191: How do you use S3 with AWS Fault Injection Simulator for DR testing?​

Technical Answer: FIS tests S3 resilience by injecting faults. Simulate region failures and test DR procedures.

Code/Config Example:

import boto3

fis = boto3.client('fis')

# Create experiment template for S3 DR test
fis.create_experiment_template(
Name='S3DRTest',
Description='Test S3 DR failover',
Actions={
'StopReplication': {
'ActionId': 'aws:ssm:sendCommand',
'Parameters': {
'DocumentName': ['StopS3Replication'],
'Targets': ['i-1234567890']
}
}
},
RollbackConfiguration={'RollbackTriggers': [{'Type': 'SSM_DOCUMENT', 'Value': 'RollbackS3'}]}
)

🔍 Interviewer Notes: Tests DR testing practices.

❌ Common Mistakes:

  • Not testing DR regularly
  • Not automating DR tests
  • Not documenting test results

Q192: How do you implement S3 data archiving best practices?​

Technical Answer: Archive data using lifecycle policies to Glacier tiers. Consider retrieval times, costs, and compliance requirements.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Archive infrequently accessed data
lifecycle = {
'Rules': [{
'ID': 'ArchiveOldData',
'Status': 'Enabled',
'Filter': {'Prefix': 'archive/'},
'Transitions': [
{'Days': 90, 'StorageClass': 'GLACIER_IR'},
{'Days': 365, 'StorageClass': 'DEEP_ARCHIVE'}
]
}]
}

s3.put_bucket_lifecycle_configuration(
Bucket='my-bucket',
LifecycleConfiguration=lifecycle
)

🔍 Interviewer Notes: Tests archiving strategies.

❌ Common Mistakes:

  • Not considering retrieval times
  • Archiving data needed frequently
  • Not testing restore procedures

Q193: How do you use S3 with AWS Backup for S3 (new feature)?​

Technical Answer: AWS Backup now supports S3 continuous backups and point-in-time recovery. Enable via Backup plan with S3 as resource.

Code/Config Example:

import boto3

backup = boto3.client('backup')

# Create backup plan for S3
backup.create_backup_plan(
BackupPlan={
'BackupPlanName': 'S3ContinuousBackup',
'Rules': [{
'RuleName': 'S3Continuous',
'TargetBackupVaultName': 'default',
'BackupVaultName': 'default',
'EnableContinuousBackup': True
}]
}
)

# Assign S3 bucket
backup.create_backup_selection(
BackupPlanId='plan-id',
Selection={
'SelectionName': 'S3Bucket',
'IamRoleArn': 'arn:aws:iam::123456789:role/backup-role',
'Resources': ['arn:aws:s3:::my-bucket']
}
)

🔍 Interviewer Notes: Tests modern backup capabilities.

❌ Common Mistakes:

  • Not knowing S3 is now supported by Backup
  • Not enabling continuous backup
  • Not testing point-in-time recovery

Q194: How do you implement S3 region failure recovery?​

Technical Answer: During region failures, use CRR to access data in DR region. Update applications to use DR bucket endpoints.

Code/Config Example:

import boto3

# Primary region fails - switch to DR region
s3_dr = boto3.client('s3', region_name='us-west-2')

# Access data from DR bucket
try:
response = s3_dr.get_object(
Bucket='dr-bucket',
Key='critical-data.txt'
)
print("Accessed from DR region!")
except Exception as e:
print(f"DR access failed: {e}")

🔍 Interviewer Notes: Tests region failure handling.

❌ Common Mistakes:

  • Not having DR region configured
  • Not updating application endpoints
  • Not testing region failover

Q195: How do you use S3 with AWS Global Accelerator for DR?​

Technical Answer: Global Accelerator provides fixed anycast IPs for S3 access across regions. Use for faster failover during DR.

Code/Config Example:

import boto3

globalaccelerator = boto3.client('globalaccelerator')

# Create accelerator with S3 endpoints
accelerator = globalaccelerator.create_accelerator(
Name='S3GlobalAccelerator',
IdempotencyToken='unique-token'
)

# Add S3 endpoints in multiple regions
# Applications use accelerator IP for S3 access
# Failover is handled by Global Accelerator

🔍 Interviewer Notes: Tests global access patterns.

❌ Common Mistakes:

  • Not using Global Accelerator for S3
  • Not configuring health checks
  • Additional cost not justified

Q196: How do you implement S3 replication failure handling?​

Technical Answer: Monitor replication with S3 Replication Time metrics. Handle failures by investigating IAM roles, KMS keys, and network connectivity.

Code/Config Example:

import boto3

cloudwatch = boto3.client('cloudwatch')

# Check replication failures
response = cloudwatch.get_metric_statistics(
Namespace='AWS/S3',
MetricName='OperationsFailedReplication',
Dimensions=[
{'Name': 'BucketName', 'Value': 'source-bucket'},
{'Name': 'RuleId', 'Value': 'ReplicationRule'}
],
StartTime='2024-01-01',
EndTime='2024-01-31',
Period=3600,
Statistics=['Sum']
)

# Investigate failures and re-sync if needed

🔍 Interviewer Notes: Tests replication monitoring.

❌ Common Mistakes:

  • Not monitoring replication
  • Not handling failed replications
  • Not understanding replication is async

Q197: How do you use S3 with Route53 for failover?​

Technical Answer: Route53 health checks can failover DNS to DR region S3 bucket (with CloudFront) or update application endpoints.

Code/Config Example:

import boto3

route53 = boto3.client('route53')

# Create health check for primary
route53.create_health_check(
CallerReference='unique-ref',
HealthCheckConfig={
'Type': 'HTTPS',
'ResourcePath': '/health',
'FullyQualifiedDomainName': 's3-primary.example.com'
}
)

# Create failover record
route53.change_resource_record_sets(
HostedZoneId='Z123456789',
ChangeBatch={
'Changes': [{
'Action': 'CREATE',
'ResourceRecordSet': {
'Name': 's3.example.com',
'Type': 'CNAME',
'Failover': 'PRIMARY',
'ResourceRecords': [{'Value': 's3-primary.cloudfront.net'}]
}
}]
}
)

🔍 Interviewer Notes: Tests DNS-based failover.

❌ Common Mistakes:

  • Not configuring health checks
  • Not testing failover
  • Wrong DNS configuration

Q198: How do you implement S3 data lifecycle during DR events?​

Technical Answer: During DR events, suspend lifecycle transitions to preserve data. Resume after recovery.

Code/Config Example:

import boto3

s3 = boto3.client('s3')

# Get current lifecycle
lifecycle = s3.get_bucket_lifecycle_configuration(Bucket='dr-bucket')

# Suspend by removing transitions (keep rules but disable)
for rule in lifecycle.get('Rules', []):
rule['Status'] = 'Disabled'

s3.put_bucket_lifecycle_configuration(
Bucket='dr-bucket',
LifecycleConfiguration={'Rules': lifecycle.get('Rules', [])}
)

🔍 Interviewer Notes: Tests DR data protection.

❌ Common Mistakes:

  • Not suspending lifecycle during DR
  • Losing data due to expiration
  • Not documenting procedures

Q199: How do you use S3 with AWS Resilience Hub for DR testing?​

Technical Answer: Resilience Hub assesses S3 application resilience. Create resiliency policy and test against DR scenarios.

Code/Config Example:

import boto3

resiliencehub = boto3.client('resiliencehub')

# Create resiliency policy for S3
policy = resiliencehub.create_resiliency_policy(
PolicyName='S3DRPolicy',
PolicyDescription='DR policy for S3',
DataLocationConstraint='DifferentFromAnotherAz',
Policy={
'S3Bucket': {
'S3Replication': {
'RtoInSecs': 3600, # 1 hour RTO
'RpoInSecs': 900 # 15 min RPO
}
}
}
)

🔍 Interviewer Notes: Tests resilience assessment.

❌ Common Mistakes:

  • Not assessing S3 resilience
  • Unrealistic RTO/RPO
  • Not testing policies

Q200: How do you implement S3 monitoring for DR readiness?​

Technical Answer: Monitor S3 replication lag, bucket sizes, and health checks. Use CloudWatch dashboards and alarms for DR readiness.

Code/Config Example:

import boto3

cloudwatch = boto3.client('cloudwatch')

# Create dashboard for DR monitoring
cloudwatch.put_dashboard(
DashboardName='S3DRDashboard',
DashboardBody=json.dumps({
"widgets": [{
"type": "metric",
"properties": {
"metrics": [
["AWS/S3", "BucketSizeBytes", "BucketName", "dr-bucket"],
["AWS/S3", "OperationsReplicationLag", "BucketName", "source-bucket"]
]
}
}]
})
)

🔍 Interviewer Notes: Tests DR monitoring.

❌ Common Mistakes:

  • Not monitoring replication lag
  • Not having DR dashboards
  • Not testing alarms

Q201: How do you implement S3 troubleshooting methodologies?​

Technical Answer: S3 Inventory provides scheduled exports of object metadata. Storage Lens provides analytics.

S3 Inventory:

# Configure inventory
s3.put_bucket_inventory_configuration(
Bucket='my-bucket',
Id='daily-inventory',
InventoryConfiguration={
'Destination': {
'S3BucketDestination': {
'Bucket': 'arn:aws:s3:::inventory-reports',
'Format': 'Parquet', # or 'CSV', 'ORC'
'Prefix': 'daily/',
'Encryption': {
'SSES3': {}
}
}
},
'IsEnabled': True,
'Filter': {
'Prefix': 'data/' # Only inventory objects under data/
},
'IncludedObjectVersions': 'Current', # or 'All'
'OptionalFields': [
'Size', 'LastModifiedDate', 'StorageClass',
'ETag', 'IsMultipartUploaded', 'ReplicationStatus',
'EncryptionStatus', 'ObjectLockRetainUntilDate',
'ObjectLockMode', 'ObjectLockLegalHoldStatus',
'IntelligentTieringAccessTier', 'BucketKeyStatus'
],
'Schedule': {
'Frequency': 'Daily' # or 'Weekly'
}
}
)

Storage Lens for Analytics:

s3control = boto3.client('s3control')

# Create Storage Lens configuration
s3control.put_storage_lens_configuration(
AccountId='123456789',
ConfigId='organization-storage-lens',
StorageLensConfiguration={
'Id': 'organization-storage-lens',
'IsEnabled': True,
'DataExport': {
'S3BucketDestination': {
'OutputSchemaVersion': 'V_1',
'AccountId': '123456789',
'Arn': 'arn:aws:s3:::storage-lens-exports',
'Prefix': 'storage-analytics/',
'Format': 'CSV',
'Encryption': {'SSES3': {}}
}
},
'Exclude': {
'Buckets': ['arn:aws:s3:::logs-bucket'],
'Regions': ['eu-west-1']
},
'AccountLevel': {
'ActivityMetrics': {'IsEnabled': True},
'AdvancedCostOptimizationMetrics': {'IsEnabled': True},
'AdvancedDataProtectionMetrics': {'IsEnabled': True},
'DetailedStatusCodesMetrics': {'IsEnabled': True}
}
}
)

🔍 Interviewer Notes: Testing data governance and analytics capabilities.

❌ Common Mistakes:

  • Not using inventory for large buckets (API too slow)
  • Not enabling Storage Lens for visibility
  • Wrong output format for analysis needs

Q202: How do you implement S3 replication (same and cross-region)?​

Technical Answer: S3 replication copies objects to another bucket for redundancy.

Same-Region Replication (SRR):

# Enable versioning on both buckets first

# Configure replication
s3.put_bucket_replication(
Bucket='source-bucket',
ReplicationConfiguration={
'Role': 'arn:aws:iam::123456789:role/s3-replication-role',
'Rules': [{
'ID': 'replicate-all',
'Status': 'Enabled',
'Priority': 1,
'Filter': {'Prefix': ''}, # Replicate all
'DeleteMarkerReplication': {'Status': 'Enabled'},
'Destination': {
'Bucket': 'arn:aws:s3:::destination-bucket',
'StorageClass': 'STANDARD',
'ReplicationTime': {
'Status': 'Enabled',
'Time': {'Minutes': 15}
},
'Metrics': {
'Status': 'Enabled',
'Minutes': 15
},
'EncryptionConfiguration': {
'ReplicaKmsKeyID': 'arn:aws:kms:us-west-2:123456789:key/...'
}
},
'SourceSelectionCriteria': {
'SseKmsEncryptedObjects': {
'Status': 'Enabled'
}
}
}]
}
)

Cross-Region Replication (CRR):

# Same as SRR but destination is in different region
s3.put_bucket_replication(
Bucket='us-east-bucket',
ReplicationConfiguration={
'Role': 'arn:aws:iam::123456789:role/s3-replication-role',
'Rules': [{
'ID': 'crr-to-west',
'Status': 'Enabled',
'Destination': {
'Bucket': 'arn:aws:s3:::us-west-bucket',
'StorageClass': 'STANDARD_IA' # Different storage class
}
}]
}
)

Bi-Directional Replication:

# Both buckets replicate to each other
# Configure replication on both buckets
# Use different prefixes to avoid loops

🔍 Interviewer Notes: Testing disaster recovery and data replication.

❌ Common Mistakes:

  • Not enabling versioning (required for replication)
  • Not setting up IAM role properly
  • Replicating to same region when CRR needed

Q203: How do you implement S3 Transfer Acceleration?​

Technical Answer: Transfer Acceleration uses CloudFront edge locations to accelerate uploads.

# Enable Transfer Acceleration
s3.put_bucket_accelerate_configuration(
Bucket='my-bucket',
AccelerateConfiguration={'Status': 'Enabled'}
)

# Use accelerated endpoint
import boto3
from boto3.s3.transfer import TransferConfig

s3 = boto3.client('s3', endpoint_url='https://s3-accelerate.amazonaws.com')

# Or use accelerate endpoint for specific upload
s3.upload_file(
'large-file.zip',
'my-bucket',
'large-file.zip',
ExtraArgs={
'ServerSideEncryption': 'AES256'
},
Config=TransferConfig(
use_threads=True,
max_concurrency=10,
multipart_threshold=8 * 1024 * 1024,
multipart_chunksize=8 * 1024 * 1024
)
)

When to use:

  • Long-distance uploads (geographically far from bucket)
  • Large files
  • Unreliable networks

When NOT to use:

  • Same region uploads (slower due to extra hop)
  • Small files (<1MB)
  • Can be 2x more expensive

🔍 Interviewer Notes: Testing performance optimization knowledge.

❌ Common Mistakes:

  • Using for same-region transfers
  • Not considering cost implications
  • Not using multipart uploads with acceleration

Additional Core Questions Summary​

Key S3 Concepts Checklist:​

  • Storage classes (Standard, IA, Glacier, Intelligent-Tiering)
  • Bucket policies and ACLs
  • Block Public Access
  • Encryption (SSE-S3, SSE-KMS, SSE-C)
  • Lifecycle policies
  • Versioning
  • Cross-region replication
  • Event notifications
  • Multipart uploads
  • S3 Select
  • S3 Object Lambda

Interview Quick Reference:​

ConceptKey Point
Storage ClassesStandard → IA → Glacier → Deep Archive
11 9s Durability99.999999999% durability
EncryptionServer-side (SSE-S3, SSE-KMS) or client-side
LifecycleAutomated transition/expiration
VersioningCannot disable, only suspend
ConsistencyRead-after-write for new, eventual for overwrites
PerformancePrefix hash for high throughput

Senior / Principal — Real World S3 Scenarios​

Q204: S3 "slow prefix" — high latency listing objects​

Level: Senior

Scenario: An S3 bucket has millions of objects under one prefix (uploads/). ListObjectsV2 takes 30+ seconds. Applications time out. Lambda enumerators fail.

Impact: Slow file operations. Timeouts. Lambda failures. Poor UX.

Root Cause: S3 prefixes are not folders. Listing requires scanning keys lexicographically. Millions of keys under one prefix = slow listings and high latency.

Simple explanation: Looking for one file in a warehouse with millions of items all in one aisle. You must scan the whole aisle.

Technical Answer:

  1. Use S3 Intelligent-Tiering or organize by date/id prefix (uploads/2026/01/15/).
  2. Use S3 Batch Operations or S3 Inventory for large-scale enumeration instead of ListObjects.
  3. Use S3 Select or Athena for querying object metadata without listing.
  4. For user-facing file access, store the S3 key in a database (DynamoDB/PostgreSQL) and look up directly instead of listing.
  5. Use random prefix hashing to distribute keys across partitions.

Code/Syntax Justification:

# Bad: listing millions
objs = s3.list_objects_v2(Bucket="bucket", Prefix="uploads/")

# Good: direct key lookup from DB
key = db.get_s3_key(file_id)
url = s3.generate_presigned_url("get_object", Params={"Bucket": "bucket", "Key": key})

Workflow Diagram:

List millions under one prefix: Direct key lookup from DB:
scan all keys under prefix DB lookup by file_id -> S3 key
| |
v v
30+ seconds timeout < 100ms

🔍 Behind the Question: S3 prefix design, listing performance, S3 Inventory, key lookup pattern, partitioning.

❌ The Red Flags: Listing millions of objects; one flat prefix; no DB index for S3 keys.


Q205: Accidental public S3 bucket — data breach​

Level: Principal

Scenario: An S3 bucket storing customer documents is set to public read access. A security researcher finds it via public scan. All customer data is exposed.

Impact: Data breach. Regulatory fines (GDPR, CCPA). Brand damage. Lawsuits.

Root Cause: Misconfigured S3 bucket policy or ACL granting public access. No public access block. No automated misconfiguration detection.

Simple explanation: You left the front door of your house unlocked with a sign "come in." Anyone can walk in and take everything.

Technical Answer:

  1. Enable S3 Block Public Access at account and bucket level (default on).
  2. Use S3 bucket policies with least privilege: specific principals, conditions (VPC, source IP).
  3. Use S3 Object Lock / Versioning for immutability.
  4. Enable S3 Public Access Block + IAM Access Analyzer to alert on public buckets.
  5. Use pre-signed URLs for time-limited access instead of making buckets public.

Code/Syntax Justification:

{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": ["arn:aws:s3:::bucket", "arn:aws:s3:::bucket/*"],
"Condition": {"Bool": {"aws:SecureTransport": "false"}}
}]
}

Workflow Diagram:

Bucket set to public
|
v
Public scan discovers bucket
|
v
Data exposed
|
v
Prevention: Block Public Access + IAM Access Analyzer + pre-signed URLs

🔍 Behind the Question: S3 public access, bucket policies, least privilege, pre-signed URLs, Access Analyzer.

❌ The Red Flags: Public bucket for customer data; no Block Public Access; no Access Analyzer.


Senior / Principal — Amazon S3 Real World Scenarios (Continued)​

Q206: S3 eventual consistency on overwrites — read-after-write inconsistency​

Level: Senior

Scenario: An application uploads a new version of a JSON config file to S3 with the same key. Immediately reads it back. Gets the old version. The application uses stale config. Feature flag doesn't take effect.

Impact: Stale data. Feature flags don't work. Configuration drift.

Root Cause: S3 provides read-after-write consistency for NEW objects, but EVENTUAL consistency for OVERWRITES and DELETES. After PUT overwrite, reads may return old version for a short period.

Simple explanation: You replace a page in a binder. For a few seconds, someone opening the binder might still see the old page underneath.

Technical Answer:

  1. Use unique object keys with version (e.g., config-v2.json) instead of overwriting same key.
  2. Enable S3 Versioning — keeps all versions, can retrieve specific version ID.
  3. Use If-Match / ETag checks or read the specific version ID.
  4. For immediate consistency needs, use DynamoDB or ElastiCache instead of S3 for config.
  5. Add retry with backoff when reading after overwrite.

Code/Syntax Justification:

# Enable versioning and read specific version
s3 = boto3.client('s3')

# Upload with versioning
s3.put_object(Bucket='bucket', Key='config.json', Body=new_config)

# Read specific version
response = s3.get_object(Bucket='bucket', Key='config.json', VersionId='abc123')

Workflow Diagram:

PUT overwrite same key: PUT new key (versioned):
Read immediately -> may get old Read immediately -> gets new
| |
v v
Eventual consistency Strong consistency (new key)
| |
v v
Fix: Use versioned keys or S3 Versioning

🔍 Behind the Question: S3 consistency model, read-after-write vs eventual, versioning, config patterns.

❌ The Red Flags: Overwriting same key expecting immediate consistency; no versioning; using S3 for real-time config.


Q207: S3 multipart upload — failed large file upload leaves orphaned parts​

Level: Senior

Scenario: A user uploads a 5GB video file via multipart upload. The upload fails at part 7 of 10. The uploaded parts (1-6) remain in S3 as orphaned parts. You're charged for storage of these parts. No way to easily find/clean them.

Impact: Wasted storage cost. Orphaned parts accumulate. No cleanup mechanism.

Root Cause: Multipart upload parts are stored even if the CompleteMultipartUpload is never called. No automatic cleanup.

Simple explanation: You're building a LEGO set. You open bags 1-6 but never finish. The pieces sit on the table forever. You paid for them but never used them.

Technical Answer:

  1. Use S3 Lifecycle rule to abort incomplete multipart uploads after N days (e.g., 7 days).
  2. Call AbortMultipartUpload on failure in application code.
  3. Use S3 Storage Lens or ListMultipartUploads to find orphaned uploads.
  4. Consider S3 Batch Operations for bulk cleanup.
  5. Monitor BytesUploaded vs BytesStored to detect orphaned parts.

Code/Syntax Justification:

import boto3

s3 = boto3.client('s3')

# Abort multipart upload on failure
try:
# ... upload parts ...
s3.complete_multipart_upload(Bucket='bucket', Key='video.mp4', UploadId=upload_id, MultipartUpload={'Parts': parts})
except Exception:
s3.abort_multipart_upload(Bucket='bucket', Key='video.mp4', UploadId=upload_id)
raise

Workflow Diagram:

Multipart upload started
|
v
Parts 1-6 uploaded
|
v
Part 7 fails -> application crashes
|
v
Without abort: With abort:
Parts 1-6 remain (orphaned) AbortMultipartUpload called
| |
v v
Charged for storage forever Parts deleted, no charge
|
v
Fix: Lifecycle rule to abort incomplete uploads after 7 days

🔍 Behind the Question: Multipart upload, abort incomplete uploads, S3 lifecycle, storage cost optimization.

❌ The Red Flags: Not aborting failed multipart uploads; no lifecycle rule for incomplete uploads; not monitoring orphaned parts.


Q208: S3 event notifications — Lambda throttling on high object creation rate​

Level: Senior

Scenario: An S3 bucket triggers a Lambda on every s3:ObjectCreated:* event. During bulk upload (10,000 files/minute), Lambda is invoked 10,000 times/minute. Lambda concurrency limit hit. Events are lost or throttled.

Impact: Missed events. Incomplete processing. Backlog in S3 event notifications.

Root Cause: S3 event notifications invoke Lambda per object. High object creation rate exceeds Lambda concurrency. No batching or buffering.

Simple explanation: A mail carrier delivers 10,000 letters. Each letter triggers a separate phone call. The phone system can only handle 1000 calls/minute. Calls are dropped.

Technical Answer:

  1. Use S3 Batch Operations for bulk processing instead of event notifications.
  2. Use S3 Event Bridge (EventBridge) with rules to filter and route.
  3. Use SQS as a buffer between S3 events and Lambda (SQS smooths spikes).
  4. Set Lambda reserved concurrency to handle expected peak.
  5. Use S3 Inventory for periodic bulk processing instead of real-time events.

Code/Syntax Justification:

# S3 -> SQS -> Lambda (buffered)
# S3 event notification sends to SQS queue
# Lambda polls SQS with batch size of 10

def lambda_handler(event, context):
for record in event['Records']:
body = json.loads(record['body'])
process_s3_event(body)

Workflow Diagram:

S3 -> Lambda direct (throttled): S3 -> SQS -> Lambda (buffered):
10,000 objects/min 10,000 objects -> SQS queue
| |
v v
Lambda throttled Lambda polls SQS (10 msgs per call)
Events lost Smooths spikes, no lost events

🔍 Behind the Question: S3 event notifications, Lambda concurrency, SQS buffer, S3 Batch Operations, EventBridge.

❌ The Red Flags: S3 event -> Lambda without buffer for high throughput; no reserved concurrency; not using S3 Batch Operations for bulk.


Q209: S3 Intelligent-Tiering — cost optimization for unknown access patterns​

Level: Senior

Scenario: A bucket has 10TB of data. Access patterns are unknown — some files accessed daily, some once a year. Standard storage is expensive. The team manually moves files to S3 Glacier but doesn't know which ones.

Impact: High storage cost. Manual tiering is error-prone. Data in wrong tier.

Root Cause: Static storage class selection. No automated tiering based on access patterns.

Simple explanation: You keep all your clothes in the front closet (expensive prime space) even though you only wear winter coats once a year. You should move coats to the attic automatically.

Technical Answer:

  1. Use S3 Intelligent-Tiering: automatically moves objects between access tiers (Frequent, Infrequent, Archive) based on access pattern.
  2. No retrieval charges in Intelligent-Tiering (unlike Glacier).
  3. Small monthly monitoring and automation fee per object.
  4. Ideal for unknown or changing access patterns.
  5. Use S3 Storage Lens to analyze access patterns before choosing tier.

Code/Syntax Justification:

# Set Intelligent-Tiering on upload
s3.put_object(
Bucket='bucket',
Key='data.csv',
Body=data,
StorageClass='INTELLIGENT_TIERING'
)

# Or transition existing objects via Lifecycle
# Transition to INTELLIGENT_TIERING after 0 days (immediate)

Workflow Diagram:

Standard storage: Intelligent-Tiering:
All data at standard rate ($0.023/GB) Auto-tier based on access
| |
v v
Pay for all data at high rate Frequent access tier -> Infrequent -> Archive
Manual tiering (error-prone) Automatic, no retrieval charges

🔍 Behind the Question: S3 storage classes, Intelligent-Tiering, access pattern analysis, cost optimization.

❌ The Red Flags: Manual tiering; all data in Standard; not using Storage Lens; Glacier with retrieval charges for frequently accessed data.


Q210: S3 Cross-Region Replication (CRR) — disaster recovery​

Level: Principal

Scenario: A company has S3 buckets in us-east-1. They want disaster recovery in us-west-2. They enable CRR. New objects replicate automatically. But existing objects (before CRR was enabled) don't replicate. DR gap.

Impact: Incomplete DR. Data in us-west-2 is incomplete. Failover would lose data.

Root Cause: CRR only replicates objects created AFTER replication is enabled. Existing objects are not backfilled.

Simple explanation: You start photocopying new documents to a backup office. Old documents already filed are not copied. The backup office is missing history.

Technical Answer:

  1. Use S3 Batch Operations to replicate existing objects before/enabling CRR.
  2. Enable S3 Versioning on both source and destination buckets (required for CRR).
  3. CRR replicates new objects and delete markers (with delete marker replication).
  4. Monitor replication status via ReplicationStatus (PENDING, COMPLETED, FAILED).
  5. Test failover: verify destination bucket has all data before relying on it.

Code/Syntax Justification:

# Enable versioning (required for CRR)
s3.put_bucket_versioning(Bucket='source-bucket', Status='Enabled')
s3.put_bucket_versioning(Bucket='dest-bucket', Status='Enabled')

# Set up replication via CloudFormation/Console
# Then batch replicate existing objects

Workflow Diagram:

CRR enabled: CRR + Batch Operations:
New objects replicated New objects replicated
Existing objects NOT replicated Existing objects batch-replicated
| |
v v
DR gap (missing history) Complete DR coverage
|
v
Fix: S3 Batch Operations to replicate existing objects

🔍 Behind the Question: CRR, S3 Versioning requirement, batch replication, DR, replication status monitoring.

❌ The Red Flags: CRR without versioning; not replicating existing objects; not testing failover; not monitoring replication failures.


Q211: S3 pre-signed URLs — temporary access without AWS credentials​

Level: Senior

Scenario: A mobile app needs to let users upload profile photos directly to S3. The app doesn't have AWS credentials. Generating pre-signed URLs on the backend allows direct upload without exposing credentials.

Impact: Secure direct uploads. No credential exposure. Reduced backend load (file doesn't pass through app server).

Root Cause: Without pre-signed URLs, files must go through the application server (backend becomes bottleneck, incurs data transfer costs).

Simple explanation: Instead of receiving a package and forwarding it, you give the courier a key to the storage locker. They deliver directly.

Technical Answer:

  1. Generate pre-signed URL on backend with s3.generate_presigned_url('put_object', ...).
  2. Set expiration (e.g., 5 minutes).
  3. Client uploads directly to S3 using the URL.
  4. Use S3 event notification to trigger processing after upload.
  5. Validate file type/size on backend before generating URL (or use S3 Object Lambda).

Code/Syntax Justification:

import boto3
from botocore.client import Config

s3 = boto3.client('s3', config=Config(signature_version='s3v4'))

url = s3.generate_presigned_url(
'put_object',
Params={'Bucket': 'bucket', 'Key': 'uploads/photo.jpg'},
ExpiresIn=300 # 5 minutes
)
# Return URL to client; client PUTs directly to S3

Workflow Diagram:

Without pre-signed URL: With pre-signed URL:
Client -> backend -> S3 Client requests URL from backend
| |
v v
Backend uploads to S3 Backend generates pre-signed URL
| |
v v
Backend bottleneck URL returned to client
High data transfer cost Client uploads directly to S3

🔍 Behind the Question: Pre-signed URLs, direct-to-S3 upload, backend offloading, expiration, signature version.

❌ The Red Flags: Files proxied through backend (bottleneck); long expiration (security risk); no validation of upload content; using signature v2.


Q212: S3 Object Lambda — processing data on GET without changing stored copy​

Level: Principal

Scenario: Multiple applications read the same S3 CSV. App A needs raw data. App B needs PII redacted. App C needs data converted to JSON. Without Object Lambda, you'd store 3 copies or process in each app.

Impact: Data duplication. Inconsistent processing. Higher storage cost.

Root Cause: S3 returns the stored object as-is. Each consumer must process separately. Multiple copies for different formats.

Simple explanation: A library book has the original text. Reader A wants it as-is. Reader B wants it redacted. Reader C wants it summarized. Instead of 3 copies, one copy with on-demand redaction/summarization.

Technical Answer:

  1. Use S3 Object Lambda: Lambda function intercepts GET requests, transforms data, returns modified object.
  2. Original object unchanged in S3.
  3. Different access points for different transformations.
  4. Supports redaction, format conversion (CSV→JSON), image resizing.
  5. Pay for Lambda invocations + data processed, not storage of copies.

Code/Syntax Justification:

# S3 Object Lambda Lambda function
import boto3

s3 = boto3.client('s3')

def lambda_handler(event, context):
# Get original object
get_context = event['getContext']
request_route = get_context['inputRequestRoute']
request_token = get_context['inputRequestToken']

original = s3.get_object(Bucket='source-bucket', Key='data.csv',
RequestRoute=request_route, RequestToken=request_token)

# Transform (e.g., redact PII)
transformed = redact_pii(original['Body'].read())

# Write transformed object back to S3 Object Lambda
s3.write_get_object_response(
Body=transformed,
RequestRoute=request_route,
RequestToken=request_token
)
return {'status_code': 200}

Workflow Diagram:

Without Object Lambda: With Object Lambda:
3 copies of data 1 original object
(raw, redacted, json) |
| |
v v
Higher storage cost Object Lambda intercepts GET
transforms on-the-fly
returns modified object

🔍 Behind the Question: S3 Object Lambda, on-the-fly transformation, PII redaction, format conversion, access points.

❌ The Red Flags: Multiple copies for different formats; processing in each app; not using Object Lambda for common transformations.


Q213: S3 Select / Athena — querying without downloading full object​

Level: Senior

Scenario: A 1GB CSV file in S3. Application needs only 3 rows matching a condition. Downloads full 1GB, filters in application. High cost, high latency, high memory.

Impact: High data transfer cost. Slow queries. Memory pressure.

Root Cause: Downloading entire object to read a small subset. S3 Select or Athena can query in-place.

Simple explanation: Buying a whole newspaper to read one article. You pay for and carry the whole paper when you only need one page.

Technical Answer:

  1. Use S3 Select: SQL query on S3 object, returns only matching rows. Less data transferred.
  2. Use Amazon Athena: serverless SQL on S3 data, good for analytical queries across many files.
  3. S3 Select: single object, row/column filtering, CSV/JSON/Parquet.
  4. Athena: multiple objects, partitioned data, BI integration.
  5. Compress data (gzip/Parquet) to reduce scanned size and cost.

Code/Syntax Justification:

# S3 Select - query only matching rows
response = s3.select_object_content(
Bucket='bucket',
Key='data.csv',
ExpressionType='SQL',
Expression="SELECT * FROM S3Object s WHERE s.amount > 1000",
InputSerialization={'CSV': {}},
OutputSerialization={'CSV': {}}
)

Workflow Diagram:

Download full object: S3 Select:
Download 1GB CSV Query S3 directly
Filter in application Return only matching rows
| |
v v
1GB transferred, high cost Few KB transferred, low cost
Memory pressure No application filtering

🔍 Behind the Question: S3 Select, Athena, in-place querying, data transfer cost, Parquet compression.

❌ The Red Flags: Downloading full object to filter; not using columnar formats (Parquet); not using S3 Select/Athena for analytical queries.