Migrate Aws To Google Cloud

Migrate Aws To Google Cloud

Reading time1 min
#Cloud#Migration#AWS#GoogleCloud#CloudMigration#AWSMigration#GCP

Downtime-Minimized Migration: AWS to Google Cloud (GCP)

Migrating production workloads across clouds imposes serious risks: downtime, data drift, surprise dependencies. The challenge isn’t tooling—it’s process and orchestration. Below is a pragmatic approach for moving from AWS to Google Cloud, focusing on uptime and detail.


Inventory – Catch What’s Not Obvious

Skip high-level lists and export a full resource inventory, including ephemeral and “forgotten” assets. Here’s an example using AWS CLI:

aws ec2 describe-instances --output table
aws s3 ls --recursive
aws rds describe-db-instances

Don’t ignore IAM users or third-party integrations (Slack bots, GitHub Actions runners). Use aws application-discovery-service for dependency mapping. Many outages during migration occur because a narrow resource was missed—a Lambda doing S3 event processing, for example.


Service Mapping – Resolve “Almost-Equivalent” Services Early

Direct mapping isn’t always available. Operate with a table in your engineering docs, capturing major candidates:

AWSGCPMigration Notes
EC2Compute EnginePay attention to instance metadata.
ECS/EKSGKEGKE 1.28+ for parity w/ EKS.
S3Cloud StorageConsider storage class mapping.
RDS (Postgres/MySQL)Cloud SQLSlightly different maintenance windows.
DynamoDBFirestore / DatastoreFirestore is closest, not identical.
ELBCloud Load BalancingTLS provisioning has API differences.

Note: Some IAM policies or networking patterns (e.g., Security Groups vs. Firewall Rules) behave differently. Revisit expressivity and defaults.


Prepare the GCP Landing Zone

  • Create a dedicated GCP project per environment (production, staging).
  • Configure VPCs. If overlapping CIDR blocks exist with AWS, consider temporary NATting during migration.
  • Establish custom IAM roles, not just the premade editor/owner model—define least privilege.
  • Enable and configure APIs: Compute, Cloud SQL, Monitoring, Logging.
  • Bootstrap Cloud Logging and Monitoring; skip this, and it’s post-cutover triage when something fails.

For large S3-to-Cloud Storage migrations, set up Storage Transfer Service:

gcloud transfer jobs create s3://YOUR_BUCKET gs://YOUR_BUCKET \
  --source-aws-access-key-id=... \
  --source-aws-secret-access-key=... \
  --status=ENABLED

Gotcha: Some object metadata (like user-defined metadata headers) aren’t copied by default—document these gaps.


Data Sync – Continuous Replication First, Final Sync Last

Running services demand near-real-time sync. Options:

Continuous Replication

  • AWS DMS for DB migration (cdc mode for ongoing changes):

    Set up a replication task in DMS:

    • Source: AWS RDS
    • Target: Cloud SQL (using public/private IP with authorized networks configured)
    • Configure change data capture (CDC) mode.

    Monitor lag with this Cloud SQL metric:

    gcloud sql operations list --instance=[INSTANCE]
    
  • For object storage: Rsync S3 to Cloud Storage (for smaller buckets); for TB-scale, use Google’s transfer appliance but note the lead time (weeks).

Known issue: IAM role remapping: S3 bucket policies must be manually reflected in Cloud Storage IAM.

Dual Write

Where feasible, adjust your application to write to both source and target for the cutover window. This requires interface abstraction—rarely trivial unless engineered from day one.


Traffic Cutover – Avoiding the “Big Switch”

Blue-green or canary deployments provide surgical control:

  • Deploy in GCP behind a new LB; configure readiness checks matching production.
  • Use Route53 or your DNS provider’s weighted routing to send a subset (as little as 1%) to the new stack.
  • Watch logs for 5xx errors, latency spikes (Stackdriver Monitoring metrics: latency, error_rate).
  • If critical issues appear, re-route in seconds.

Example (weighted canary via Route53):

aws route53 change-resource-record-sets \
    --hosted-zone-id ZZZZZZ \
    --change-batch file://canary-weighted.json

Typical JSON:

{
  "Changes": [
    {
      "Action": "UPSERT",
      "ResourceRecordSet": {
        "Name": "yourapp.example.com.",
        "Type": "A",
        "Weight": 10,
        "SetIdentifier": "GCP",
        "ResourceRecords": [{ "Value": "GCP_LB_IP" }]
      }
    }
  ]
}

Infrastructure as Code – Consistency or Misery

Use Terraform (>=1.4) to define all environments, GCP and AWS, in code; never click-provision. Split state files across providers:

terraform/
  modules/
    app/
      main.tf
  aws/
    backend.tf
    main.tf
  gcp/
    backend.tf
    main.tf

Example: Minimal GCP Compute Engine instance

resource "google_compute_instance" "app" {
  name         = "migrated-app"
  machine_type = "n2-standard-2"
  zone         = "us-central1-a"
  boot_disk {
    initialize_params {
      image = "debian-cloud/debian-12"
    }
  }
  network_interface {
    network = "default"
    access_config {}
  }
}

Tip: Avoid “terraform import” for ephemeral resources; rebuilding is cleaner.


Rigorous Validation Before Cutover

  • Provision an isolated staging environment, restore a recent data snapshot, and simulate peak load (k6, locust, or JMeter with production traffic scripts).
  • Run integration and security regression tests (CVE scan, misconfiguration sweeps).
  • Confirm that cloud-native logging and alerting (Cloud Logging, Opsgenie integration) fire as expected.

Non-obvious failure: Default VPC-level egress rules differ between AWS and GCP—test all third-party API outbound calls.


Planned Cutover – Managing Inevitable Gaps

  • Schedule for low-traffic windows from real analytics (bigquery or AWS Athena).
  • Pre-warm GCP CDN and cache layers—DNS cutovers are only “instant” for some users due to global propagation.
  • Use DNS TTL=60s, but expect some clients to cache far longer.

Rollback: Document all steps to revert traffic, including Terraform destroy/apply commands and DNS swaps.


Post-Migration: Watch and Tune

  • Scrutinize for cost drift—GCP instance types and persistent disks aren’t always price-matched to AWS defaults.
  • Enable and tune autoscaling (instance groups, Cloud SQL High Availability).
  • Harden IAM: Disable legacy accounts, rotate service keys, validate with gcloud iam policies lint.
  • Monitor with Stackdriver and third-party tools (Datadog, Prometheus federation).

Side note: Some transient issues—especially around session stickiness—will only surface under steady real-user traffic. Plan to keep AWS resources “warm” for at least a week post-migration.


High-Level Checklist

  • Inventory and dependency map (including least obvious components)
  • Service equivalence mapping (keep live doc)
  • GCP project/VPC/IAM/monitoring pre-configuration
  • Continuous data replication configured and tested
  • Blue-green/canary cutover with DNS or load-balancer-based routing
  • All infrastructure defined as code, with documented diffs
  • Full-load staging validation (performance, security, observability, network paths)
  • Cutover during low-impact window, full rollback steps documented
  • Robust post-migration monitoring and tuning

There’s no fully “safe” cloud migration. This approach narrows the risk envelope and surfaces hidden failure modes early. If trouble surfaces, at least you’ll know precisely where in the pipeline to look.