AWS Migration Use Case 1
A complete on-premises to AWS migration: assessment and the 7 Rs, landing zone, hybrid networking, EC2, serverless, DMS database migration, the data platform, security, CI/CD, cutover and multi-region disaster recovery, with architecture diagrams.
1. The Scenario: Closing a Data Centre in 12 Months
Acme (a fictional company) runs everything in one data centre that must be closed within 12 months: web servers, a REST API, Oracle and SQL Server databases, a 10 TB Oracle data warehouse, a 60 TB Hadoop cluster, 25 TB of file shares, clickstream collectors and a licensed risk engine. This card walks through the complete migration to AWS: assessment, landing zone, every migration path, the data platform, security, monitoring, CI/CD, cutover and disaster recovery.
| On-premises system | Size | Decision (7 Rs) | Target on AWS |
|---|---|---|---|
| Customer Portal (Tomcat web servers) | 2 servers | Rehost | EC2 Auto Scaling behind an ALB |
| Accounts API (Spring Boot, REST/JSON) | 1 server | Refactor | Lambda + API Gateway |
| Core accounts database (Oracle 19c) | 3.5 TB | Replatform | Amazon RDS for Oracle, migrated with DMS |
| Payments database (SQL Server 2016) | 1.2 TB | Replatform | RDS for SQL Server, migrated with DMS |
| HR portal (vendor app + MySQL) | small (80 GB) | Rehost | MGN for the app server + RDS MySQL |
| Reporting data warehouse (Oracle) | 10 TB | Replatform | Amazon Redshift (DMS → S3 → COPY) |
| Hadoop / Spark 2.4 cluster | 60 TB HDFS | Replatform | Amazon EMR + S3 + Glue Data Catalog |
| File shares (NFS / SMB) | 25 TB | Replatform | S3 via DataSync (or Snowball Edge) |
| Clickstream collectors (Flume) | — | Refactor | Kinesis Data Streams + Firehose |
| Licensed risk engine (per-core licence) | 1 server | Rehost | EC2 Dedicated Host (bring your own licence) |
| Old fax server | almost unused | Retire | Switched off |
Constraints that shape every decision
| Constraint | Design consequence |
|---|---|
| Data must stay in India | Primary region Mumbai (ap-south-1), DR region Hyderabad (ap-south-2); no service or replica outside India |
| Minimal downtime for databases | DMS full load + change data capture (CDC); cutover window of minutes, not days |
| Everything encrypted | KMS keys per data class, CloudHSM for the most sensitive keys, TLS everywhere, IPsec on the VPN |
| Every change through a pipeline | Terraform + SAM + CodePipeline; no console changes |
| A tested DR plan | Recovery targets per tier, scripted failover, daily readiness checks, quarterly drills |
Everything in this use case uses placeholders: account IDs, IP ranges, domains and the company name are examples. The code it refers to is written to be read and learned from, not deployed as-is.
2. The Target Architecture
The diagram shows the end state, read left to right: the on-premises data centre, the hybrid network links, the primary AWS region with its VPC and regional services, and the DR region on the right. Security, monitoring and DR summaries run along the bottom.
Solid arrows are traffic and data flow; dashed red arrows are replication to the DR region.
| # | Layer | What it contains | Why |
|---|---|---|---|
| 1 | On-premises | Existing systems, plus agents: MGN (server replication), DataSync (files), DRS (DR after rehost), Discovery (inventory) | The data centre keeps running until each wave is cut over |
| 2 | Hybrid connectivity | Direct Connect (1 Gbps, primary), Site-to-Site VPN (backup), DX Gateway (reaches both regions) | Predictable bandwidth for TBs of migration traffic, with an encrypted fallback |
| 3 | Network hub | Transit Gateway with route tables | One hub for VPCs, VPN and DX instead of a mesh of peerings |
| 4 | VPC (3 AZs) | Public, app and data subnets in each Availability Zone; VPC endpoints; flow logs | Survive the loss of a data centre; keep data tiers off the internet |
| 5 | Regional services | S3 data lake, Glue, Athena, Kinesis + Firehose, DynamoDB | Serverless, managed services that live outside the VPC and are reached privately through endpoints |
| 6 | Edge | Route 53, WAF, API Gateway, ALB (optional CloudFront) | All user traffic enters over HTTPS through a firewall |
| 7 | DR region | Smaller copy kept current by replicas, backups and replication | Business continuity if the whole primary region fails |
| 8 | Around everything | IAM, KMS, CloudHSM, CloudWatch, CloudTrail, Config, GuardDuty, CodePipeline | Security, observability and change control for every component |
3. The Migration Journey, Phase by Phase
AWS migrations follow three phases, Assess → Mobilize → Migrate & Modernize, followed by operating and optimising. Skipping Assess is the most common cause of failed migrations: undiscovered dependencies break applications at cutover.
Phase 1: Assess
- Discover: collect servers, utilisation and dependencies with AWS Application Discovery Service (agent or agentless) or Migration Evaluator. Dependencies matter most: two servers that talk constantly must move in the same wave, or latency over the WAN will break them
- Decide per application with the 7 Rs (below), based on business value, technical fit and effort
- Plan waves: low-risk first to build confidence and the runbook; databases together with or before their applications; the big data platform last
- Build the business case: compare On-Demand, Spot, Savings Plans, Dedicated Instances and Dedicated Hosts per workload
| Strategy | Meaning | Example in this project | When it fits |
|---|---|---|---|
| Retire | Switch off | Fax server | Unused or duplicated systems; typically 10–20% of a portfolio |
| Retain | Keep on-premises for now | — | Not ready, recently upgraded, or regulatory blockers |
| Rehost | Lift and shift, no code change (MGN) | Web servers, HR app, risk engine | Fastest path; optimise later |
| Relocate | Move a VMware estate as-is | — | Large VMware estates (VMware Cloud on AWS) |
| Repurchase | Replace with SaaS | — | Commodity functions: email, CRM, HR |
| Replatform | Small changes to use managed services | Oracle → RDS, Hadoop → EMR, files → S3 | Remove undifferentiated operations work |
| Refactor | Re-architect cloud-native | REST API → Lambda, Flume → Kinesis | Where scalability, agility or cost justify the effort |
Phase 2: Mobilize (build the landing zone)
A landing zone is the secure, well-architected base (accounts, network, identity, logging, guardrails) that workloads land on. Everything here is Terraform, applied by the pipeline:
| Step | What | File |
|---|---|---|
| 1 | State bucket and lock table; providers for both regions | main.tf |
| 2 | KMS keys, CloudHSM, IAM roles, Secrets Manager, WAF, ACM | security.tf |
| 3 | VPCs in both regions from one reusable module | modules/network/ |
| 4 | Transit Gateways, VPN, Direct Connect, inter-region peering, security groups | network.tf |
| 5 | CloudTrail, CloudWatch, Config, GuardDuty, SNS | monitoring.tf |
| 6 | CI/CD pipeline | cicd.tf |
Exit criteria before any workload moves: connectivity tested from the data centre, logging on, Config guardrails green, and the pipeline deploying to a dev account.
Phase 3: Migrate and modernize, in waves
| Wave | Applications | Tools | Why this order |
|---|---|---|---|
| 0 | Retire the fax server | — | Quick win; shrinks the estate |
| 1 | Customer Portal web tier, HR portal | MGN (rehost), CodeDeploy | Low risk; proves network, security and runbook |
| 2 | Oracle core + SQL Server payments | DMS full load + CDC, cutover runbook | Databases before the API that depends on them |
| 3 | Accounts API → serverless | SAM, API Gateway, Lambda, RDS Proxy | Refactor once the database is already in AWS |
| 4 | Data platform: Hadoop, DW, files, clickstream | EMR, Glue, Redshift, DataSync, Kinesis | Largest volume; benefits from a stable foundation |
| 5 | Risk engine on a Dedicated Host + DR for rehosted servers | MGN, DRS | Licence-sensitive; done after licensing is agreed |
Phase 4: Operate and optimise
Right-size instances with CloudWatch data, buy Savings Plans for the steady baseline, run DR drills every quarter, review Config and GuardDuty findings, and finally close the data centre.
4. Networking and Hybrid Connectivity
Open full size ↗
The VPC: three tiers in three Availability Zones
| Subnet tier | Contains | Internet access | Why |
|---|---|---|---|
| Public | ALB, NAT gateways | Yes, through the Internet Gateway | Only the components that must face the internet |
| App | EC2, Lambda (VPC-attached), EMR | Outbound only, through NAT | Servers can download patches but cannot be reached from outside |
| Data | RDS, Redshift, DMS, OpenSearch, CloudHSM | None | Even a compromised server cannot exfiltrate directly to the internet |
- One subnet per tier in each of three AZs, so losing one data centre does not stop the service
- VPC endpoints (gateway endpoints for S3 and DynamoDB, interface endpoints for KMS, Secrets Manager, SSM) keep AWS API traffic on the AWS network: more secure, and cheaper than sending it through NAT gateways
- VPC flow logs record every accepted and rejected connection for security investigations
- The same Terraform module builds the DR VPC, with one NAT gateway instead of three to save cost
Plan IP ranges first. AWS (10.20.0.0/16 primary, 10.30.0.0/16 DR) must not overlap the data centre (172.16.0.0/12). Overlapping ranges make routing over VPN or Direct Connect impossible, and re-addressing later is very painful.
Direct Connect vs Site-to-Site VPN
| Direct Connect (DX) | Site-to-Site VPN | |
|---|---|---|
| Path | Private fibre to an AWS Direct Connect location | Encrypted tunnel over the public internet |
| Bandwidth / latency | 1–100 Gbps, predictable | Up to about 1.25 Gbps per tunnel, variable |
| Encryption | Not by default: use TLS, MACsec (on supported ports), or a VPN over DX | IPsec (AES-256-GCM, IKEv2) |
| Lead time | Weeks (physical cross-connect) | Hours |
| Role here | Primary path for migration traffic (DMS, MGN, DataSync) | Backup path and day-one connectivity |
- Both attach to the Transit Gateway. BGP prefers the DX route; if DX fails, traffic moves to the VPN automatically
- The DX Gateway is a global object, so the same Direct Connect also reaches the DR region's Transit Gateway
- The two regional Transit Gateways are peered: inter-region traffic stays private and encrypted on the AWS backbone
- A second VPN goes straight to the DR region, in case the primary region is the thing that failed
How long will the data take to move?
A quick calculation decides between network transfer and Snowball. At 1 Gbps with realistic 80% utilisation, 25 TB of file shares takes about 25×8,000 / (1×0.8) ≈ 250,000 seconds, roughly 3 days; the 60 TB HDFS and 10 TB DW history add about 10 more days, competing with DMS and MGN replication. That is why bulk history can go by Snowball Edge while DataSync handles the changing delta over the network.
"I build a three-tier VPC across three AZs (public for the ALB and NAT, private app subnets, and data subnets with no internet route), with VPC endpoints and flow logs. On-premises connects through Direct Connect as the primary path and a Site-to-Site VPN as the encrypted backup, both on a Transit Gateway with BGP preferring DX. A DX Gateway and Transit Gateway peering extend connectivity to the DR region. I plan non-overlapping CIDRs before anything else."
5. Compute and Cost (EC2)
| Purchase option | Use it for | In this project |
|---|---|---|
| On-Demand | Steady or unknown load, short-lived | Web tier baseline (2 instances), HR app |
| Spot (up to about 90% cheaper, can be reclaimed with 2 minutes' notice) | Fault-tolerant, interruptible work | Web tier burst capacity, EMR task nodes, CI builds |
| Savings Plans / Reserved Instances | The always-on baseline, 1- or 3-year commitment | Covers the On-Demand baseline once usage is known |
| Dedicated Instance | Hardware not shared with other customers (compliance) | Example in the CLI scripts |
| Dedicated Host | A whole physical server: visibility of sockets and cores for per-core licences (BYOL) | Risk engine |
How the web tier is built
- Launch template: encrypted gp3 disk, IMDSv2 only (blocks credential theft through server-side request forgery), no SSH key (admins use SSM Session Manager), CloudWatch and CodeDeploy agents installed at boot
- Auto Scaling group with a mixed instances policy: 2 On-Demand instances always, and above that 25% On-Demand / 75% Spot across four instance types. More instance types means more Spot capacity pools and fewer interruptions
- Capacity rebalance launches a replacement when AWS signals a Spot instance is at elevated risk of interruption, before it is reclaimed
- Target tracking keeps average CPU near 50%
- ALB: HTTPS with an ACM certificate (TLS 1.2+), HTTP redirected to HTTPS, WAF attached, access logs to S3
- Dedicated Host with host recovery for the BYOL risk engine, so the licence stays bound to known cores
resource "aws_autoscaling_group" "web" {
name = "acme-web"
min_size = 2
max_size = 12
vpc_zone_identifier = module.network.app_subnet_ids # three AZs
target_group_arns = [aws_lb_target_group.web.arn]
health_check_type = "ELB"
capacity_rebalance = true
mixed_instances_policy {
instances_distribution {
on_demand_base_capacity = 2 # always On-Demand
on_demand_percentage_above_base_capacity = 25 # then 25% On-Demand / 75% Spot
spot_allocation_strategy = "price-capacity-optimized"
}
launch_template {
launch_template_specification {
launch_template_id = aws_launch_template.web.id
version = "$Latest"
}
override { instance_type = "m6i.large" }
override { instance_type = "m6a.large" }
override { instance_type = "m5.large" }
override { instance_type = "m7i.large" }
}
}
}
Illustrative Terraform following the AWS provider's syntax; not applied here.
"I match purchase options to workload shape: On-Demand for the baseline, covered by Savings Plans once usage is stable; Spot for interruptible capacity such as web burst, EMR task nodes and CI, spread across several instance types with capacity rebalancing; and Dedicated Hosts for per-core licensed software. Instances use IMDSv2, encrypted gp3 volumes and SSM instead of SSH."
6. Applications: Serverless API and the Web Tier
Open full size ↗
The serverless Accounts API
Client -HTTPS-> WAF -> API Gateway (REST, API key, JSON schema validation, throttling)
|
+-----------+------------------------+
v v v
GET /accounts/{id} POST /transactions (Kinesis) -> stream processor Lambda
DynamoDB summary 1 idempotency key (DynamoDB) |
(single-digit ms) 2 insert in RDS MySQL via RDS Proxy v
3 publish event to Kinesis DynamoDB running balances
| Concern | How it is handled | Why it matters |
|---|---|---|
| Bad input | API Gateway validates the JSON body against a model before Lambda runs | Invalid requests cost nothing and never reach code |
| Double posting on retries | Idempotency-Key header + DynamoDB conditional write + unique key in MySQL | A client retrying after a timeout must not move money twice |
| Database connection storms | RDS Proxy pools connections; Lambda concurrency capped at 100 | Thousands of concurrent Lambdas would otherwise exhaust database connections |
| Database password | None: Lambda uses an IAM authentication token; TLS enforced | No long-lived secret to leak |
| Safe releases | Canary deployment: 10% of traffic for 5 minutes, automatic rollback on errors | A bad release affects few users, briefly |
| Bad stream records | Partial batch failure responses, bisect on error, SQS dead-letter queue | One poison record cannot block the stream |
| Tracing | AWS X-Ray end to end | Find which hop is slow |
Idempotency: the pattern behind "no double posting"
import boto3
from botocore.exceptions import ClientError
table = boto3.resource("dynamodb").Table("idempotency-keys")
def handle_post_transaction(event, context):
key = event["headers"]["Idempotency-Key"]
try:
table.put_item( # succeeds only for a NEW key
Item={"key": key, "status": "IN_PROGRESS", "ttl": ttl_in_24h()},
ConditionExpression="attribute_not_exists(#k)",
ExpressionAttributeNames={"#k": "key"},
)
except ClientError as e:
if e.response["Error"]["Code"] == "ConditionalCheckFailedException":
return previous_response(key) # a retry: return the first result, do nothing
raise
result = insert_transaction_via_rds_proxy(event) # unique constraint in MySQL is the second guard
publish_to_kinesis(result)
save_response(key, result)
return result
Illustrative handler; helper functions such as insert_transaction_via_rds_proxy are placeholders.
The web tier on EC2
The rehosted portal is made Auto Scaling-friendly: stateless (no sessions on disk), configuration from SSM Parameter Store, a /health endpoint and JSON logs. CodeDeploy updates one instance at a time, removes it from the ALB while updating, checks /health, and rolls back automatically if the ALB 5xx alarm fires.
"The Accounts API was refactored to API Gateway and Lambda: schema validation at the gateway, idempotency keys with DynamoDB conditional writes and a unique key in MySQL so retries never double-post, RDS Proxy with IAM authentication to protect the database, canary deployments with automatic rollback, and Kinesis plus a stream processor for derived balances with partial batch failures and a DLQ."
7. Databases and the DMS Migration
Open full size ↗
Target databases
All RDS instances are Multi-AZ (synchronous standby with automatic failover), encrypted with KMS, TLS required, with passwords generated and rotated through Secrets Manager, 14 days of point-in-time recovery, Performance Insights, Enhanced Monitoring and deletion protection. MySQL also has a cross-region read replica in the DR region.
How DMS moves a live database with minimal downtime
day 1 -- full load (copy all tables) -- CDC: keep applying every change --+
|
applications still use on-premises the whole time v
cutover window (minutes):
freeze -> drain -> validate -> switch
| Step | What happens | Command / file |
|---|---|---|
| 1. Source prerequisites | DBA enables archive logging and supplemental logging (Oracle) or MS-CDC / MS-Replication (SQL Server), and creates a migration user | — |
| 2. Schema conversion | Only when engines differ (Oracle DW → Redshift): AWS SCT or DMS Schema Conversion | — |
| 3. Connectivity test | DMS replication instance reaches both endpoints | dms_runbook.sh test-connections |
| 4. Full load + CDC | Copy all tables in parallel while capturing ongoing changes | dms_runbook.sh start core-accounts |
| 5. Monitor | Per-table progress, CDC latency, DMS validation | dms_runbook.sh status core-accounts, dashboard |
| 6. Cutover | Freeze writes, wait for CDC latency ≈ 0, validate, stop task, switch connection strings | dms_runbook.sh cutover core-accounts |
| 7. Independent validation | Row counts, column sums, sampled row hashes per table | validate_migration.py |
DMS settings that decide success
| Setting | Why it matters |
|---|---|
| Parallel load (table and partition level) | A 3.5 TB load finishes in hours, not days |
| LOB handling (limited vs full LOB mode) | Full LOB mode is slow; limited mode with a correct max size is much faster but truncates bigger LOBs, so measure the largest LOB first |
| Batch apply for CDC | Applies changes in batches to keep up with busy sources |
| Row-level validation | DMS compares source and target rows and reports mismatches |
| Error policies | Decide whether a failed table stops the task or is logged and suspended |
Validate independently: counts can hide errors
# validate_migration.py (idea): compare per table on source and target
checks = {
"row_count": "SELECT COUNT(*) FROM {t}",
"amount_sum": "SELECT SUM(amount) FROM {t}", # catches changed values
"sample_hash": "SELECT {hash}(id || '|' || amount || '|' || status) "
"FROM {t} WHERE MOD(id, 1000) = 7", # deterministic sample of rows
}
for table in ["accounts", "transactions", "payments"]:
for name, sql in checks.items():
src, tgt = run(source_db, sql, table), run(target_db, sql, table)
print(table, name, "OK" if src == tgt else f"MISMATCH {src} != {tgt}")
Illustrative outline; the hash function differs per engine (for example STANDARD_HASH in Oracle, HASHBYTES in SQL Server). Matching row counts with different sums is a real failure mode, which is why counts alone are never enough.
Other migration paths
| What | Tool | Notes |
|---|---|---|
| Servers (rehost) | AWS Application Migration Service (MGN) | Continuous block-level replication, test launches, then cutover |
| File shares (still changing) | AWS DataSync, scheduled and verified | Incremental transfers with checksum verification |
| Bulk exports | aws s3 sync with multipart and checksums | Simple and scriptable |
| Too much data for the network | AWS Snowball Edge, then DataSync for the delta | Ship the bulk, sync the changes |
| Historical DW data into Redshift | DMS → S3 Parquet → COPY ... MANIFEST | Columnar files loaded in parallel by Redshift slices |
"For databases I use DMS full load plus CDC, so applications keep running on-premises while data copies, and the cutover is minutes: freeze writes, wait for CDC latency near zero, validate, switch connection strings. Prerequisites like Oracle supplemental logging and SQL Server MS-CDC come first, schema conversion only when engines differ, and I validate with counts, sums and sampled hashes, not counts alone."
8. Data Engineering Platform
BATCH STREAMING
DMS (databases, DW history) Kinesis Data Streams (clickstream)
-> S3 raw -> Firehose -> S3 raw
-> Glue crawler (Data Catalog)
-> Glue ETL with job bookmarks -> S3 curated
-> EMR Spark (PySpark + Scala) -> S3 analytics
-> Redshift COPY / MERGE -> BI dashboards
SIDE PATHS
Athena: ad-hoc SQL on S3
Redshift Spectrum: reads S3 directly
DynamoDB: API state
OpenSearch: search
| Component | Role in the platform | Expert notes |
|---|---|---|
| S3 | Data lake in zones: raw / curated / analytics | SSE-KMS with bucket keys, versioning, lifecycle tiers, TLS-only bucket policies |
| Glue | Data Catalog via crawlers, ETL jobs, nightly workflow | Job bookmarks process only new data; the catalog replaces the Hive metastore |
| EMR | Spark batch replacing Hadoop: PySpark and Scala jobs | Transient clusters (created per batch, terminated after); core nodes On-Demand, task nodes Spot |
| Redshift | Warehouse replacing the Oracle DW | DISTKEY/SORTKEY design, COPY + MERGE, Spectrum for lake data, materialized views, UNLOAD |
| Kinesis + Firehose | Real-time clickstream replacing Flume | On-demand streams; Firehose buffers and writes to S3 raw |
| DynamoDB | Idempotency keys and running balances for the API | Point-in-time recovery; global table for DR |
| Athena | Serverless SQL on S3 | Partition projection; a 50 GB per-query scan limit protects cost |
| OpenSearch | Search over transactions and logs | Encryption at rest, HTTPS, node-to-node encryption |
What changes when Hadoop moves to EMR
| On-premises Hadoop | On AWS | Consequence |
|---|---|---|
hdfs:// paths | s3:// paths | Storage is separate from compute and never lost when a cluster ends |
| Hive metastore | Glue Data Catalog | One catalog shared by EMR, Athena, Redshift Spectrum and Glue |
| Long-lived 10-node cluster | Transient clusters per job | Pay only while jobs run; upgrade Spark versions per job |
| Spark 2.4 | Current Spark on EMR | Test jobs for API changes (Scala 2.11 → 2.12/2.13, deprecated configs) |
-- Load historical warehouse data exported by DMS as Parquet COPY analytics.fact_transactions FROM 's3://acme-lake-analytics/dw-history/fact_transactions/manifest.json' IAM_ROLE 'arn:aws:iam::111122223333:role/acme-redshift-copy' FORMAT AS PARQUET MANIFEST;
Illustrative Redshift SQL; the account ID and role are placeholders.
Related guides: AWS Glue, Amazon EMR, Amazon Redshift, AWS DMS, Amazon Kinesis, Amazon Athena.
9. CI/CD: Every Change Through a Pipeline
GitHub -> CodePipeline
1 Source
2 Build CodeBuild: pytest, cfn-lint, checkov (IaC security scan), terraform plan
3 Approve manual approval of the saved plan (change management)
4 Infra CodeBuild: terraform apply of exactly that saved plan
5 Deploy ServerlessApi: SAM -> primary + DR regions
WebAppEc2: CodeDeploy rolling update
DataJobs: Glue / EMR scripts and jar -> S3
| Principle | How it is applied | Why |
|---|---|---|
| Apply what was approved | The plan file from the build stage is the one applied | No surprise changes between review and apply |
| Shift security left | Checkov and cfn-lint scan infrastructure code on every change | Misconfigurations caught before they exist |
| DR never drifts | Serverless code is deployed to the DR region on every release | Failover runs the same version as production |
| Automatic rollback | CodeDeploy and Lambda canaries roll back on CloudWatch alarms | Failed releases recover without a human |
| Data jobs are artefacts too | Glue and EMR scripts and the Scala jar are versioned and published to S3 | Reproducible data pipelines |
10. Security and Encryption
Open full size ↗
Encryption at rest and in motion
| Layer | At rest | In motion |
|---|---|---|
| EC2 / EBS | KMS-encrypted gp3 volumes | TLS at the ALB; IMDSv2 |
| RDS | KMS for storage, snapshots and Performance Insights | TLS required (parameter groups; Oracle native network encryption) |
| S3 | SSE-KMS with bucket keys | Bucket policy denies non-TLS requests (aws:SecureTransport) |
| Redshift | KMS (or an HSM-backed key) | SSL connections; enhanced VPC routing |
| DynamoDB, Kinesis, SQS | KMS | HTTPS APIs |
| OpenSearch | KMS | HTTPS enforced, node-to-node encryption |
| Backups / replicas | KMS (multi-region keys in DR) | AWS backbone |
| On-premises link | — | IPsec VPN (AES-256-GCM); TLS over Direct Connect |
Identity, keys and other controls
| Control | Implementation | Expert point |
|---|---|---|
| IAM | One role per workload with only the actions it needs; a permission boundary blocking IAM, KMS-admin and CloudTrail tampering; IAM Access Analyzer; no access keys | Permission boundaries cap what even a delegated admin can grant |
| KMS | One key per data class, yearly rotation, multi-region keys for DR | Separate keys limit the blast radius and let key policies differ per data class |
| CloudHSM | Custom key store for the most sensitive keys (single-tenant, FIPS 140-3 Level 3) | Used when regulation requires keys in dedicated hardware |
| Secrets Manager | Source DB credentials for DMS; RDS master passwords generated and rotated by RDS | No passwords in code or Terraform state |
| WAF | AWS managed rules (common, known bad inputs, SQL injection, IP reputation) + per-IP rate limits on ALB and API Gateway; credentials redacted from WAF logs | Managed rule groups are kept current by AWS |
| No SSH | SSM Session Manager, sessions recorded | No open port 22, no key distribution, full audit |
| Detective controls | AWS Config rules, GuardDuty, VPC flow logs | Detect drift and threats continuously |
"Everything is encrypted at rest with KMS (one key per data class, multi-region keys for DR, CloudHSM-backed keys for the most sensitive data) and in motion with TLS 1.2+ and IPsec. IAM uses one least-privilege role per workload plus a permission boundary, secrets live in Secrets Manager with rotation, WAF protects the ALB and API Gateway, admins use SSM instead of SSH, and Config, GuardDuty and flow logs provide detection."
11. Monitoring and Audit
| Tool | Answers | In this project |
|---|---|---|
| CloudWatch metrics + alarms | Is it healthy? | ALB 5xx and latency, unhealthy hosts, RDS CPU and storage, replica lag, Kinesis iterator age, DMS CDC latency, Redshift health |
| CloudWatch Logs | What happened inside? | JSON application logs, Lambda, API access logs, VPN, WAF, RDS and Redshift audit logs |
| Log metric filters | Business and security signals | Payment failures, root login, unauthorised calls, IAM, KMS and security-group changes |
| CloudWatch dashboard | One view for operations and migration progress | monitoring.tf |
| CloudTrail | Who did what, when? | Multi-region, log file validation, S3 and Lambda data events, Object Lock bucket retained 7 years |
| X-Ray | Where is the latency? | API Gateway → Lambda → RDS / DynamoDB traces |
| SNS | Who gets told? | One alert topic → on-call |
Two migration-specific alarms deserve special attention: DMS CDC latency (if it grows, the cutover window grows) and Kinesis iterator age (if it grows, consumers are falling behind real time).
12. Cutover and Rollback
| When | Checklist (per wave) |
|---|---|
| T-2 weeks | DMS and MGN replication healthy, test instances verified, validation report green, rollback plan approved, stakeholders informed |
| T-1 day | Lower DNS TTLs (e.g. 60 seconds), freeze changes, confirm backups |
| Cutover window | Stop writes on-premises → wait for DMS CDC latency ≈ 0 → final validation → MGN cutover / stop DMS → switch connection strings (SSM parameters) and DNS → smoke tests → go / no-go |
| Hyper-care (2–4 weeks) | Watch dashboards and alarms; keep on-premises systems available but read-only |
| Decommission | Switch off on-premises once the rollback window has passed |
Rollback during the migration
Until decommissioning, on-premises is the fallback. For databases, a reverse DMS task (AWS → on-premises CDC) keeps the old system current after cutover, so going back does not lose the transactions made in AWS. Without reverse replication, rollback after hours of live traffic would mean losing data, and the go/no-go decision becomes far more stressful.
Lowering DNS TTLs a day in advance matters because resolvers cache records for the old TTL; if it was 24 hours, some users would keep reaching on-premises for a day after the switch.
13. Disaster Recovery and Business Continuity
In one sentence: if the primary region (Mumbai) becomes unavailable, the platform is brought up in the DR region (Hyderabad) using data that is continuously replicated or backed up there, following a scripted and regularly tested runbook, with recovery targets agreed per application tier. Both regions are in India, so data residency holds even during a disaster.
Key terms
| Term | Question it answers | Example |
|---|---|---|
| RPO (Recovery Point Objective) | How much data can we afford to lose? | "At most 5 minutes of transactions" |
| RTO (Recovery Time Objective) | How long can we be down? | "Back online within 1 hour" |
| Failover | Switching production to the DR region | Promote replica, scale up, move DNS |
| Failback | Returning to the primary region afterwards | Reverse replication, planned switch |
| DR drill | Practising failover without a real disaster | Quarterly |
Lower RPO and RTO cost more. That is why targets are set per tier, not as one number for everything.
What protects against what
| Event | Handled by | Category |
|---|---|---|
| Server or instance failure | Auto Scaling replaces it; EC2 host recovery | High availability |
| One Availability Zone fails | Multi-AZ RDS, subnets in 3 AZs, ALB across AZs | High availability |
| Accidental delete, bad change, corruption | RDS point-in-time restore, S3 versioning, DynamoDB PITR, AWS Backup | Operational recovery |
| Ransomware or a malicious admin | Backup Vault Lock, CloudTrail Object Lock, KMS key policies | Resilience |
| Whole region unavailable | Failover to ap-south-2 | Disaster recovery |
High availability and DR are different things: Multi-AZ protects against a data-centre failure inside a region, but replicates corruption and deletions instantly. Only backups and point-in-time recovery protect against bad data, and only a second region protects against a regional outage.
The four AWS DR strategies
| Strategy | What runs in DR | RPO / RTO | Cost | Used here for |
|---|---|---|---|---|
| Backup & restore | Nothing, only backups | Hours / hours | Lowest | Oracle, SQL Server, Redshift, EMR |
| Pilot light | Data replicated, compute off | Minutes / tens of minutes | Low | Web tier + MySQL |
| Warm standby | A small running copy | Seconds–minutes / minutes | Medium | Serverless API + DynamoDB |
| Multi-site active/active | Full copy serving traffic | ≈0 / ≈0 | Highest | Not needed (DynamoDB global tables are already active) |
Tiers and targets
| Tier | Components | Strategy | RPO | RTO |
|---|---|---|---|---|
| 0 | Accounts API (Lambda + API Gateway), DynamoDB state | Warm standby / active data | ≈0 (seconds) | 15 min |
| 1 | Customer Portal (EC2) + MySQL | Pilot light, replica promotion | ≤ 5 min | 1 h |
| 1 | Core accounts (Oracle), payments (SQL Server) | Backup & restore from 4-hourly cross-region copies | ≤ 4 h | 4 h |
| 1 | Rehosted servers (risk engine) | AWS Elastic Disaster Recovery | Seconds | Minutes |
| 2 | Data lake (S3), Glue catalog | S3 replication with 15-minute Replication Time Control; catalog re-created | 15 min | 24 h |
| 2 | Redshift | Snapshot copies | 24 h | 24 h |
| 2 | EMR | Nothing to replicate (no data on clusters); re-created | — | 24 h |
If the business needs Oracle or SQL Server below a 4-hour RPO, the next step is a cross-region read replica (RDS for Oracle with Active Data Guard licensing, or SQL Server Enterprise), at extra licence and instance cost.
How each component is protected
| Component | Mechanism |
|---|---|
| VPC, subnets, security groups, TGW, VPN | Pre-built in DR by the same Terraform module |
| Connectivity to on-premises | Global DX Gateway reaches the DR Transit Gateway; second VPN to DR |
| Web tier | DR launch template + Auto Scaling group at 0; ALB pre-created; AMIs copied by the pipeline |
| Serverless API | Deployed to both regions on every release |
| MySQL | Cross-region read replica → promote |
| Oracle, SQL Server, EBS | AWS Backup every 4 hours + daily, copied to the DR vault |
| DynamoDB | Global tables (replica in DR, active) |
| S3 raw / curated | Cross-region replication with Replication Time Control (15 minutes) |
| Redshift | Automatic snapshot copy to DR |
| Rehosted servers | Elastic Disaster Recovery (block replication, point-in-time) |
| Encryption keys | Multi-region KMS keys for S3, DynamoDB and Backup; separate DR keys for logs and RDS |
| Secrets and configuration | SSM parameters per region; RDS secrets re-created on promotion |
| DNS | Route 53 health checks + failover records |
| Audit logs | Multi-region CloudTrail; Object Lock bucket |
Failover runbook
Decision: the incident commander declares a disaster when the primary region is impaired beyond the tier RTOs and AWS Health does not indicate a quick recovery. Never fail over automatically on a single alarm: a wrong failover is itself an outage.
| # | Step | How | Target time |
|---|---|---|---|
| 1 | Declare, notify, freeze changes; stop writes reaching the primary if it is partly alive | Incident call | 0–10 min |
| 2 | Dry run the script to see the plan | python dr/failover.py --env prod | 10 min |
| 3 | Promote the MySQL replica, then enable Multi-AZ | failover.py --execute | 15–25 min |
| 4 | Restore Oracle and SQL Server from the latest DR backup copies | failover.py --execute | 1–3 h |
| 5 | Scale the web Auto Scaling group from 0 to production size | failover.py --execute | 10 min |
| 6 | Point configuration (SSM) at DR endpoints | failover.py --execute | 5 min |
| 7 | Route 53 fails over on the health check (verify or force) | Route 53 | 1–3 min |
| 8 | Recover rehosted servers | dr/drs_setup.sh recover <id> | 15–30 min |
| 9 | Smoke tests, alarms green, communicate | Dashboard | — |
| 10 | Tier 2: restore Redshift snapshot, re-run data jobs in DR, re-create EMR | Pipeline | Within 24 h |
Failback
- Wait until the primary region is stable (AWS Health), then rebuild missing pieces there with Terraform
- Reverse the replication: create a MySQL replica of the DR database in the primary region; back up the restored Oracle and SQL Server in DR and copy back; DynamoDB global tables re-sync automatically; enable S3 replication DR → primary for objects written during the outage
- Plan a short maintenance window, then run the failover runbook in the opposite direction
- Re-establish the normal replication direction and run the readiness checks
Keeping DR ready
| Practice | Frequency | Tool |
|---|---|---|
| Readiness check: backup age, replica lag, S3 replication latency, DynamoDB replica, Redshift snapshot | Daily | dr/verify_backups.py (alerts on failure) |
| Automated restore test of backups | Monthly | AWS Backup restore testing |
| DRS recovery drill (non-disruptive) | Quarterly | dr/drs_setup.sh drill |
| Full DR game day: fail over a non-production copy, measure real RPO and RTO | Twice a year | dr/failover.py, runbook |
| Review targets with the business | Yearly | DR document |
Record the RPO and RTO actually achieved in every drill. If they miss the targets, either invest (for example warm standby instead of pilot light) or agree new targets with the business; never leave the gap undocumented.
Cost of DR, and DR during the migration
| Item | Standing cost in DR |
|---|---|
| Pilot-light web tier | ALB + 1 NAT gateway only (no instances) |
| MySQL replica | One instance (single-AZ until promoted) |
| DynamoDB global tables | Replicated writes + storage |
| Backups, S3 replicas, Redshift snapshots | Storage (infrequent-access and cold tiers) |
| Elastic Disaster Recovery | Small replication servers + low-cost staging volumes |
| Oracle / SQL Server | No running instances: restored only when needed, so no standing licence cost |
Until the data centre is closed, on-premises is the DR site for migrated applications: reverse DMS tasks keep on-premises databases current, VPN and DX paths and on-premises servers stay available read-only during hyper-care, and the cloud-only DR model takes over only after decommission sign-off.
"DR targets are set per tier because lower RPO and RTO cost more. The API and DynamoDB are warm standby with global tables, RPO seconds and RTO 15 minutes; the portal is pilot light with a MySQL cross-region replica, RPO 5 minutes and RTO 1 hour; Oracle and SQL Server use 4-hourly cross-region backups, RPO and RTO 4 hours; rehosted servers use Elastic Disaster Recovery; the data platform recovers within 24 hours. Failover is a human decision executed by a script with a dry run, Route 53 moves traffic, readiness is checked daily and drills run quarterly."
14. Interview-Ready Summary and Questions
"I led the migration of a data centre to AWS in 12 months, with data kept in India: Mumbai primary, Hyderabad DR. We assessed with Application Discovery and the 7 Rs, then built a Terraform landing zone: a three-tier, three-AZ VPC, Transit Gateway with Direct Connect primary and VPN backup, KMS and CloudHSM, CloudTrail, Config and GuardDuty, and a CodePipeline that applies only approved plans."
"We migrated in waves: rehosted web servers and a licensed risk engine with MGN (the engine on a Dedicated Host), replatformed Oracle and SQL Server to Multi-AZ RDS with DMS full load and CDC for minutes of downtime, refactored the REST API to API Gateway and Lambda with idempotency and RDS Proxy, moved the Oracle DW to Redshift via S3 Parquet and COPY, Hadoop to transient EMR on S3 with the Glue catalog, file shares with DataSync and Snowball, and Flume to Kinesis and Firehose."
"Every wave had a cutover checklist, independent validation with counts, sums and hashes, reverse DMS for rollback, and hyper-care. After migration, DR is tiered (warm standby, pilot light, backup and restore, Elastic Disaster Recovery) with scripted failover, daily readiness checks and quarterly drills."
| Question | Answer |
|---|---|
| What are the 7 Rs, and how did you choose? | Retire, retain, rehost, relocate, repurchase, replatform, refactor. Rehost for speed (web, risk engine), replatform to remove operations work (Oracle → RDS, Hadoop → EMR), refactor where cloud-native gives clear value (API → Lambda, Flume → Kinesis), retire what nobody uses |
| How do you migrate a 3.5 TB Oracle database with minimal downtime? | DMS full load plus CDC while applications stay on-premises; prerequisites (archive and supplemental logging); parallel load and tuned LOB settings; then freeze writes, wait for CDC latency ≈ 0, validate, switch connection strings. Downtime is minutes |
| Direct Connect or VPN? | Both: DX for predictable bandwidth and latency (primary), VPN for encrypted backup and day-one connectivity. BGP prefers DX. DX is not encrypted by default, so use TLS, MACsec or VPN over DX for sensitive traffic |
| Why a Dedicated Host for the risk engine? | Its licence is per core; a Dedicated Host exposes physical sockets and cores and keeps the instance on the same host (affinity), so BYOL licensing stays compliant |
| How do you prevent double posting in a serverless API? | An Idempotency-Key header, a DynamoDB conditional write that only succeeds for new keys, and a unique constraint in the database as a second guard |
| Why RDS Proxy with Lambda? | Lambda scales to many concurrent executions, each opening connections; RDS Proxy pools and reuses them, and supports IAM authentication instead of stored passwords |
| What changes when Hadoop moves to EMR? | hdfs:// becomes s3://, the Hive metastore becomes the Glue Data Catalog, and clusters become transient because no data lives on them |
| How do you validate a migration? | Row counts, column sums and sampled row hashes per table, plus DMS validation and business reconciliation. Counts alone can hide changed values |
| How do you roll back after cutover? | Keep on-premises read-only during hyper-care and run a reverse DMS task (AWS → on-premises) so switching back loses no transactions |
| What is the difference between pilot light and warm standby? | Pilot light replicates data with compute switched off (scale up on failover); warm standby runs a small but working copy. Warm standby recovers faster and costs more |
| Multi-AZ vs cross-region replica vs backups? | Multi-AZ survives a data-centre failure inside a region; a cross-region replica survives a regional outage; backups and PITR protect against corruption and deletion, which replicas copy instantly |
| Why not fail over automatically? | A wrong failover is itself an outage and can cause split-brain; a human declares the disaster, a script executes it |
15. Glossary
| Term | Meaning |
|---|---|
| 7 Rs | The seven migration strategies: retire, retain, rehost, relocate, repurchase, replatform, refactor |
| AZ | Availability Zone: an isolated group of data centres inside a region |
| CDC | Change data capture: streaming every insert, update and delete from a database |
| Cutover | The moment users switch from the old system to the new one |
| Direct Connect (DX) | Private network connection between a data centre and AWS |
| DMS | Database Migration Service: copies databases with full load + CDC |
| DRS | Elastic Disaster Recovery: continuous replication of servers to another region |
| IMDSv2 | Session-based version of the EC2 instance metadata service; blocks credential theft through SSRF |
| Landing zone | The base AWS setup (accounts, network, security, logging) before workloads move |
| MGN | Application Migration Service: lift-and-shift of servers by block replication |
| Multi-AZ | A synchronous standby copy in another AZ with automatic failover |
| Pilot light | DR strategy: data replicated, compute switched off until needed |
| RPO / RTO | How much data you can lose / how long you can be down |
| Transit Gateway | Regional network hub connecting VPCs, VPNs and Direct Connect |
| Warm standby | DR strategy: a scaled-down but running copy of production |