πŸ’‘ Ask Tutor

AWS Security Best Practices

Build Secure, Resilient, and Compliant Architectures on AWS

Security is foundational to everything in the cloud. AWS provides a wide range of built-in services, tools, and controls to help secure infrastructure, applications, and data. But you share responsibility for securing what you build on AWS.

This chapter explores best practices, encryption, IAM boundaries, logging, monitoring, and proactive threat detection using AWS-native tools.


🧱 AWS Shared Responsibility Model

πŸ” Who Secures What?

LayerAWS ResponsibilityYour Responsibility
Hardware, Networking, Regionsβœ…βŒ
Virtualization Layerβœ…βŒ
IAM, VPC, EC2, LambdaβŒβœ… Configure and monitor access
S3 Buckets, RDS, AppsβŒβœ… Secure data, patch apps

πŸ“Œ AWS secures the cloud; you secure what’s in the cloud.

Core Pillars of Cloud Security

  1. Identity & Access Management
  2. Data Protection
  3. Network Security
  4. Monitoring & Logging
  5. Incident Detection & Response
  6. Compliance & Governance

Identity & Access Management (IAM)

  • Follow least privilege: grant only what’s necessary
  • Use IAM roles for applications and services
  • Avoid root user for daily use
  • Enforce MFA for all accounts
  • Create IAM permission boundaries for scoped access
  • Monitor unused users/roles via IAM Access Analyzer

πŸ” Data Encryption: Protecting Data at Rest & In Transit

βœ… At Rest:

ServiceEncryption Options
S3SSE-S3, SSE-KMS, SSE-C
EBSEncrypted volumes
RDSEnable encryption at launch
DynamoDBDefault KMS encryption

In Transit:

  • Use TLS (HTTPS) for web apps
  • Enable encryption between Lambda + RDS
  • Use SSL for S3 endpoints, API Gateway

πŸ” Always use KMS-managed keys (SSE-KMS) for better auditability and control.

AWS Key Management Service (KMS)

AWS KMS allows you to:

  • Create and manage encryption keys (Customer Master Keys)
  • Use KMS for encryption in S3, EBS, Lambda, RDS
  • Rotate keys automatically
  • Define Key Policies and grants for fine-grained control

βœ… Sample Policy: Restrict KMS Key Use

JSON
{
  "Effect": "Deny",
  "Action": "kms:Encrypt",
  "Resource": "*",
  "Condition": {
    "StringNotEquals": {
      "aws:RequestedRegion": "us-east-1"
    }
  }
}

🧠 Use alias names (e.g., alias/app-key) instead of hardcoded key IDs.

Monitoring & Threat Detection Tools

ToolPurpose
CloudTrailLogs all API activity
CloudWatch LogsSystem & app logs
AWS ConfigResource state tracking
VPC Flow LogsNetwork packet visibility
Amazon GuardDutyThreat detection & anomalies
AWS InspectorVulnerability scanner for EC2, Lambda

Amazon GuardDuty

  • Analyzes CloudTrail, DNS logs, VPC Flow Logs
  • Detects: credential exfiltration, port scans, malware behavior
  • Sends alerts via CloudWatch Events

βœ… No agents needed. Just enable and monitor.

πŸ§ͺ AWS Inspector (Now Inspector V2)

  • Agent-based vulnerability scanner
  • Scans:
    • EC2 for CVEs
    • Lambda for code risks
    • ECR container images for package vulnerabilities
  • Integrated with Security Hub

🌐 Network Security – Control Ingress & Egress

βœ… VPC Best Practices:

  • Use private subnets for sensitive workloads
  • Only expose public-facing apps to the internet
  • Use NAT Gateways, not public IPs, for backend services
  • Use VPC endpoints to connect privately to S3, DynamoDB
  • Use security groups + NACLs to restrict traffic

πŸ” Shield & WAF

ToolRole
AWS ShieldDDoS protection (included by default)
AWS Shield AdvancedEnhanced detection, mitigation
AWS WAFProtect web apps from common attacks (SQLi, XSS)

πŸ›‘οΈ Shield integrates with CloudFront + Route 53. Use with WAF for full protection.


πŸ“Š Logging Best Practices

ActionTool
Record all API activityCloudTrail
Send logs to central accountS3 log bucket + SSE
Detect unauthorized changesAWS Config + Rules
Monitor login patternsIAM Credential Reports
Detect sudden traffic spikesCloudWatch Alarms

Compliance & Governance

  • Enable AWS Config conformance packs
  • Use Service Control Policies (SCP) in AWS Organizations
  • Set up tagging policies for cost governance
  • Enable Access Analyzer to detect risky configurations
  • Integrate with Security Hub to centralize alerts

βœ… AWS complies with HIPAA, PCI-DSS, ISO 27001, FedRAMP, and many more.

Summary of Best Practices

CategoryBest Practice
IAMLeast privilege, use roles, MFA
EncryptionKMS, SSE-KMS, TLS for all endpoints
NetworkPrivate subnets, VPC endpoints
LoggingCloudTrail, VPC logs, central S3
Threat DetectionEnable GuardDuty, use Inspector
ComplianceUse Config + Security Hub
Vulnerability MgmtRegular patching, CVE scanning