AWS Infrastructure Operations Handbook
A practical production reference covering core AWS resource provisioning (EC2, S3, RDS, Lambda), Infrastructure as Code (Terraform, AWS CDK, CloudFormation), least-privilege IAM governance with the security team, and ongoing reliability/cost improvement reviews.
Companion Docs:
1. Core AWS Provisioning & Production Hardening
Amazon EC2 (Compute)
- Enforce IMDSv2 everywhere: Disable IMDSv1 (
http_tokens = "required") to block SSRF-based credential theft against the instance metadata endpoint. - Eliminate open SSH/RDP ports & bastions: Never allow
0.0.0.0/0on ports22or3389. Use AWS Systems Manager (SSM) Session Manager for audited, IAM-controlled shell access with zero inbound management ports. - Dedicated Instance Profiles: Attach narrowly scoped IAM instance profiles per workload—never reuse broad shared roles across different services.
- Storage & Compute Defaults: Default to gp3 EBS volumes (cheaper and independently tunable IOPS/throughput vs.
gp2), encrypt volumes with KMS, and evaluate Graviton (ARM64) instances (t4g,m7g,c7g) for better price-performance.
Amazon S3 (Object Storage)
- Block Public Access by Default: Enable
Block Public Accessat both the AWS account level and individual bucket level unless explicitly serving public assets behind CloudFront. - Enforce Encryption in Transit & at Rest: Deny non-HTTPS requests using a bucket policy condition (
aws:SecureTransport = false) and default to SSE-S3 or SSE-KMS customer-managed keys (CMKs) for sensitive datasets. - Scoped Policies & Lifecycle Rules: Restrict bucket policies to explicit key prefixes rather than broad
arn:aws:s3:::bucket/*wildcards, configure S3 Lifecycle transitions (Intelligent-Tiering / Glacier / expiration) to prevent unbounded storage growth, and run IAM Access Analyzer for S3 to catch accidental public or cross-account exposure.
Amazon RDS (Managed Relational Databases)
- Strict Private Subnet Isolation: Always set
publicly_accessible = false. Allow inbound database traffic only from explicit application Security Group IDs—not CIDR blocks. - Credential & Encryption Hygiene: Avoid static hardcoded passwords. Use IAM Database Authentication or AWS Secrets Manager with automated rotation, enforce TLS connections, and enable KMS storage encryption at creation time.
- Operational Readiness: Enable Performance Insights, Enhanced Monitoring, automated backups with sensible retention windows, and Multi-AZ deployments for production databases.
AWS Lambda (Serverless Compute)
- One Execution Role per Function: Never share a single execution role across multiple Lambda functions; scope downstream resource ARNs (specific S3 prefixes, Secrets Manager secrets, SQS queues, or DynamoDB tables) explicitly.
- VPC Attachment Discipline: Attach Lambda to private VPC subnets only when it must reach private resources like RDS or ElastiCache. Functions talking solely to public AWS APIs should stay outside a VPC to avoid unnecessary ENI complexity and NAT Gateway costs.
- Safety Controls: Configure explicit timeouts, memory right-sizing, reserved concurrency limits (to prevent runaway invocations from exhausting downstream DB pools), and Dead-Letter Queues (DLQs) or destinations for async failures.
2. Infrastructure as Code (IaC): Terraform vs. AWS CDK vs. CloudFormation
All production AWS changes should flow through version-controlled IaC pipelines—never untracked console clicks—so environments stay reproducible, reviewable, and auditable.
| Criteria | Terraform (v1.10+) | AWS CDK | AWS CloudFormation |
|---|---|---|---|
| Authoring Language | HCL (declarative) | TypeScript, Python, Go, Java, C# | YAML / JSON |
| State Management | Remote state in S3 (native S3 locking in v1.10+) | AWS-managed (via synthesized CloudFormation stacks) | AWS-managed (Stacks & StackSets) |
| Ecosystem Scope | Multi-cloud + SaaS (AWS, Datadog, GitHub, Cloudflare, K8s) | AWS-first (high-level reusable Constructs) | AWS-only (zero external state tooling) |
| Multi-Region Pattern | Provider aliases (provider "aws" { alias = "dr" }) | Multi-stack / multi-environment CDK apps | Native CloudFormation StackSets |
| Drift Detection | terraform plan (scheduled CI checks) | cdk diff + CloudFormation drift detection | Built-in CloudFormation Drift Detection |
Modern Terraform 1.10+ Backend Pattern (S3 Native State Locking)
Historically, remote Terraform state on AWS required an S3 bucket plus a separate DynamoDB table for locking. Starting with Terraform 1.10+, S3 conditional writes enable native S3 state locking (use_lockfile = true), removing the DynamoDB table, lowering cost, and simplifying IAM policies:
terraform {
required_version = ">= 1.10.0"
backend "s3" {
bucket = "org-terraform-state-prod"
key = "core/network-and-rds/terraform.tfstate"
region = "ap-southeast-1"
encrypt = true
use_lockfile = true # Native S3 state locking — no DynamoDB table needed
}
}
IaC Governance Standards
- Remote Plan on PR, Apply on Merge: Run
terraform fmt,validate,tflint/checkov(orcdk-nag), andterraform planautomatically on every pull request; require peer review beforeapply. - Standardized Cost & Ownership Tags: Apply mandatory default tags (
Environment,Team,Service,Owner,ManagedBy) via providerdefault_tagsso every provisioned resource is traceable in Datadog and AWS Cost Explorer. - Modular Structure: Split state by blast radius (e.g.,
network/,iam/,data/,app-services/) rather than keeping an entire AWS account in one monolithic state file.
3. Least-Privilege AWS IAM & Security Collaboration
Identity is the primary perimeter in AWS. Treat IAM changes with the same rigor as production application code:
- Zero Long-Lived Access Keys for Workloads or CI:
- Workloads assume IAM Roles (EC2 IMDSv2, EKS IRSA / Pod Identity, Lambda execution roles).
- CI/CD pipelines (GitHub Actions, CircleCI) authenticate via OIDC Federation to assume short-lived IAM roles instead of storing static
AWS_ACCESS_KEY_IDsecrets. - Humans access AWS via IAM Identity Center (AWS SSO) with MFA and time-bound sessions.
- Operationalize Least Privilege with IAM Access Analyzer:
- Enable Unused Access findings to surface roles, policies, and credentials untouched for 90+ days and prune them regularly with the security team.
- Use Access Analyzer Policy Generation (backed by CloudTrail activity) to turn broad initial dev policies into tight, action-level production policies based on real API calls.
- Use IAM Permission Boundaries for Safe Delegation:
- Whenever developers or CI pipelines are allowed to create roles, attach a Permission Boundary setting a hard upper limit on effective permissions so no one can escalate privileges (e.g., attaching
AdministratorAccessor modifying IAM guardrails).
- Whenever developers or CI pipelines are allowed to create roles, attach a Permission Boundary setting a hard upper limit on effective permissions so no one can escalate privileges (e.g., attaching
- Security Review Workflow:
- Require
CODEOWNERSreview from the security team on any PR modifyingiam/, KMS key policies, S3 bucket policies, or Organizations Service Control Policies (SCPs).
- Require
4. Staying Current & Continuous Improvement Cadence
To keep AWS infrastructure aligned with evolving AWS services and the AWS Well-Architected Framework, run a lightweight recurring review:
- Monthly FinOps & Utilization Check: Review AWS Cost Explorer + Datadog Cloud Cost Management recommendations (idle EC2/RDS, gp2 → gp3 migrations, unattached EBS volumes, Savings Plans coverage, NAT Gateway egress).
- Quarterly Security & IAM Audit: Review IAM Access Analyzer unused-access and external-access findings, rotate secrets, and verify IMDSv2 / TLS / KMS coverage.
- Bi-Annual Resilience & AWS Service Review: Evaluate new AWS managed capabilities (e.g., Graviton generations, RDS Multi-AZ DB Clusters, Terraform/CDK upgrades) and validate backup restore + failover drills against target RPO/RTO.