Home› Blog› Week 29 - The Migration That Said It Was Done
AWS Weekly Lab AWS Terraform

The migration that said it was done

A migration tool reports how many rows it moved. It does not report whether those rows still mean the same thing. Mine reported the load 100 percent complete over an empty database.

Verified against current vendor documentation on 27 November 2026. Pricing, limits and API behaviour were checked against the official docs on that date. Cloud services change fast — if you are reading this much later, treat the specifics as a starting point and re-check the linked sources.
AWS Platform Engineering Lab · Week 29 of 52

Lab Overview

A removal firm delivers your boxes and hands you a sheet saying forty boxes loaded, forty boxes delivered. The sheet is accurate. Nobody opened a single box, so nobody can tell you the glasses are intact.

Database migration runs on the same sheet. The tool reports rows read, rows written, and a progress bar reaching a hundred percent. None of those says whether a row on the new database means what it meant on the old one. Moving a row and preserving its meaning are separate questions, and only one is being counted.

So this week I migrated MySQL to PostgreSQL with AWS Database Migration Service, kept writing to the source while the migration ran, switched validation on, and seeded the table with values that are perfectly legal in MySQL and have no equivalent in PostgreSQL. Then I asked the target what it actually held.

Cloud Services and Concepts

ServicePurpose hereWhat it is
AWS DMSThe migration itself, on a dms.t3.micro replication instance, running full load plus change data capture with validation onA managed service that copies a database to another database, optionally of a different engine, while the first one keeps serving
Amazon RDS for MySQLThe source, db.t4g.micro, with binary logging turned on so changes can be capturedA managed MySQL instance
Amazon RDS for PostgreSQLThe target, db.t4g.micro. A different engine, which is where meaning gets lostA managed PostgreSQL instance
AWS LambdaWrites the awkward rows, then keeps writing during the load. Inside the VPC, because neither database is publicShort-lived functions; nothing runs between invocations
Amazon CloudWatch LogsThe task's own log, which turned out to be half the answer and only halfThe log store; DMS writes task progress and errors here
HCP TerraformRemote applies into the sandbox account through OIDC, so no AWS keys are stored anywhereHosted Terraform runs, authenticating with short-lived credentials

What validation actually does, and when

Validation is not on by default. You set EnableValidation to true, and then, in AWS's words, "validation begins immediately after a full load is performed for a table". It reads every row from both databases and compares them, which costs real query load on both sides.

During validation DMS creates a table on the target called awsdms_control.awsdms_validation_failures_v1, and writes a row into it per failure, with a DETAILS column naming the columns that differ. That table is the evidence, and it is worth knowing that it may not be there at all: a query against it before validation has run fails outright, which is a different thing from finding it empty.

One limitation worth knowing before you plan around it: validation requires a primary key or unique index. A table without one reports No primary key rather than an error.

Complete and correct are different questions

DMS publishes a table state and a validation state, and they are not the same field. Table error is defined by AWS as "the table wasn't validated because it was in an error state and some data wasn't migrated". A table in that state never leaves Pending validation, because there is nothing to compare against.

Which is the trap. A failed table and a slow validator look identical in the counters: both sit at zero failures, pending. One means "not finished checking". The other means "nothing arrived, and nothing ever will".

Architecture and Workflow

aws Sandbox account · us-east-1 VPC — no public endpoint on either database writer seeds + churns MySQL source db.t4g.micro DMS replication dms.t3.micro PostgreSQL target db.t4g.micro 1 2 4 3 written during the load — 2,000 rows, carried by CDC WITHOUT THE TYPE RULE: full load 100% complete 0 rows in the target — Table error validation never ran, so 0 failures WITH IT: 4,020 full load + 2,000 by CDC 6,020 rows, 0 validation failures validation state: Validated

The numbers in the diagram are the order things happen:

  1. Seed the awkward rows. A Lambda function writes values that are legal MySQL and have no exact PostgreSQL equivalent: BIGINT UNSIGNED at its maximum, a TINYINT(1) holding 2, binary floating point, and a DECIMAL(18,6) whose scale has to survive.
  2. Full load, which is a snapshot. Whatever the source looked like when it began is what gets copied.
  3. Keep writing during the load. Two thousand rows, written after the snapshot started. These are the cutover question: they have to arrive by change data capture, and the full load counter says nothing about them.
  4. Validation reads both databases and compares. This is the only step that is about meaning rather than volume.

Prerequisites

  • An AWS account, and Terraform 1.10 or later.
  • Binary logging on the MySQL source. Change data capture reads the binary log, so binlog_format = ROW and a non-zero binlog retention are requirements, not tuning.
  • A primary key on every table you intend to validate.
  • Two IAM roles with exact names: dms-vpc-role and dms-cloudwatch-logs-role. The console creates these silently the first time you use DMS in an account. Terraform does not, and DMS will not accept substitutes.

Implementation

What was deployed

ResourceHow manyIts job
aws_db_instance2MySQL source and PostgreSQL target, both db.t4g.micro
aws_dms_replication_instance1dms.t3.micro, the machine the migration runs on
aws_dms_endpoint2How DMS reaches each database, including the SSL mode for each
aws_dms_replication_task1Full load plus CDC, validation enabled, and the type rule
aws_dms_certificate1The RDS CA bundle, so the source endpoint can verify the server
aws_iam_role3The two exactly-named DMS roles, plus the one the writer runs as
aws_security_group3Source, target, and the replication instance
aws_lambda_function1Seeds the awkward rows and writes during the load
Rules, policies, subnet groups, parameter group, password14Ingress and egress rules, role attachments, the binlog parameter group, generated credential

Twenty-eight resources. Three of them cost anything worth counting.

The HCP Terraform run page for workspace week-29-dev, showing a plan that finished with 23 resources to create and the apply in progress.
The first apply, into the sandbox account. The stack grew to twenty-eight once the two DMS service roles and the CA bundle were added.
The HCP workspace variables page showing TFC_AWS_PROVIDER_AUTH set to true and the sandbox role ARN marked sensitive and write-only.
No stored keys. The run assumes a role in the sandbox account through OIDC.

The one thing that is not obvious in the Terraform

The two endpoints do not take the same SSL settings. For the MySQL source, require is rejected outright; it wants verify-ca with the RDS certificate bundle imported as a DMS certificate resource. The PostgreSQL target accepts require on its own. Same service, same week, two different answers, and the error message for the wrong one does not suggest the right one.

The DMS endpoints page showing the source and target endpoints with successful connection tests.
Both endpoints reachable, each with its own SSL mode. A connection test here is the cheapest failure available all week.

Validation and Evidence

I ran the same load twice: once without the type rule that widens the offending column, once with it. Here is the console during the first run.

The DMS tasks list showing week29-dms with full load progress at 100 percent and a full blue progress bar, beside a status reading Load completed with errors, replication ongoing.
Full load progress: 100%, bar filled. Status: "Load completed with errors". The target behind this screen holds nothing at all, and the progress bar is still telling the truth about the only thing it measures.
TestExpectedActualStatus
Both endpoints reach their databaseconnection test succeedsboth successful, each with its own SSL mode✅
Full load completesprogress reaches 100%100% in both runs, including the failed one✅
Rows present in the target, unwidenedall of them0 — Table error❌
Rows present in the target, widenedall of them6,020 of 6,020✅
Rows written during the load arrivecarried by CDC2,000 beyond the full load's 4,020✅
Validation runs and comparesstate reaches ValidatedValidated, 0 mismatches✅
Failure count distinguishes the two runsnon-zero when rows are missing0 in both — it cannot❌

The last row is the finding. A counter reading zero whether the migration worked or never happened is not a check, however prominently it is displayed.

With the rule in place the same console screen reads differently, in exactly one column:

The DMS task table statistics tab showing full load rows 2,012, zero failed rows, and validation state Validated.
Validation state: Validated. This is an earlier run of the same task, which is why its full load figure is 2,012 rather than the 4,020 of the final run recorded below; what matters here is the column on the right.

The working run is worth its own sentence. Of 6,020 rows in both databases, the full load carried 4,020. The other 2,000 were written while it ran and arrived separately. Plan a cutover on the full load counter alone and those 2,000 are invisible to you, and they are exactly the rows your customers wrote during the migration window.

A terminal showing the recorded result of both runs: without the type rule, 100 percent progress, zero rows loaded, zero rows in the target, table state Table error; with it, 6,020 rows in source and target and validation state Validated. Below, the DMS log says to check the target database logs, and the PostgreSQL log reports value 18446744073709551615 is out of range for type bigint.
Both halves, and the reason. The DMS log sends you somewhere else; the database's own log has the answer.
What the task reportedWithout the type ruleWith it
Full load progress100%100%
Rows loaded04,020
Rows arriving by CDC02,000
Rows actually in the target06,020
Table stateTable errorTable completed
Validation statePending validationValidated
Validation failures00

The figure contains the most useful thing I found all week, and it is not a number. The DMS task log says:

Command failed to load data with exit error code 0 and exitwhy 1.
Please check target database logs for more information.

That is the whole explanation DMS offers. The actual reason is in the target database's own log, which DMS does not surface anywhere in its console:

ERROR:  value "18446744073709551615" is out of range for type bigint
STATEMENT:  COPY "shop"."orders" FROM STDIN WITH DELIMITER ',' CSV

MySQL's BIGINT UNSIGNED goes up to 18446744073709551615. PostgreSQL's bigint stops at 9223372036854775807, less than half that. One row held a value above the ceiling, the bulk COPY of the whole table was rejected because of it, and the table went to Table error with nothing loaded. One row out of range cost the entire table.

The fix is a table-mapping transformation rule that changes the column's type on the way across, to a 20 character string, so the value arrives as what it is rather than being forced into a type that cannot hold it:

{
  "rule-type": "transformation",
  "rule-name": "widen-big-unsigned",
  "rule-target": "column",
  "object-locator": { "schema-name": "shop", "table-name": "orders",
                      "column-name": "big_unsigned" },
  "rule-action": "change-data-type",
  "data-type": { "type": "string", "length": "20" }
}

Security and Cost

Neither database has a public endpoint, and the replication instance reaches them through security group references rather than CIDR ranges. The database password is generated in Terraform and never leaves state; the Lambda reads it from its environment, and the only identity with a route to either database lives in the VPC.

This was also the first week deployed into the sandbox account rather than the management account, which is where every week goes from here on. Service control policies cannot restrict the management account at all, so a deny guardrail only binds the work once the work moves out of it.

What this means for a platform team

Validation costs query load on both databases and is off until you ask for it, so the default configuration of a migration tool is the one that cannot tell you whether the migration worked. Defensible as a default, since the checking is expensive. Not defensible at cutover.

Cost

The stack ran about two and a half hours: two db.t4g.micro databases, a dms.t3.micro replication instance, and storage.

The measured figure is not in yet, and this section will carry it rather than an estimate. The usage straddles 26 and 27 November UTC, and Cost Explorer keeps revising a day for hours after it closes; reading it early is how the last two weeks here published numbers that later moved 58% and 84%. It goes in once it stops moving, read from the bill.

Troubleshooting and Lessons

Problem. The task reported full load progress 100% and zero validation failures. The target held zero rows.

Root cause. One seeded value above PostgreSQL's bigint ceiling made the bulk COPY fail for the whole table, so the table went to Table error. Validation never ran, which is why the failure count stayed at zero, and the progress percentage refers to the load finishing rather than succeeding.

Resolution. A change-data-type transformation rule widening that column.

Lesson. A zero in a failure counter means one of two opposite things: nothing failed, or nothing was checked. Read the table state before reading the failure count, and treat a count of rows in the target as the only answer that cannot be misread.

Problem. Re-running the migration after fixing the mapping failed with "Start Type : START_REPLICATION, valid only for tasks running for the first time".

Root cause. The start type is not a property of what you want to happen, it is a property of whether the task has ever run. AWS is explicit: start-replication is only valid the first time, and "any other action used for the first time on a given task … will result in data errors".

Resolution. Pick the start type from the task's current status: start-replication when it is ready, reload-target when it has run before and the whole table needs loading again.

Lesson. Any script that re-runs a migration after a fix is, by definition, never on the first run. Writing the first-run call and testing it once is the easiest way to build something that works exactly once.

Cleanup and Key Takeaways

A terminal showing the signed-in role with the account number masked, then six API queries returning empty lists: DMS replication instances, DMS endpoints, RDS instances, week29 Lambda functions, week29 security groups and manual RDS snapshots.
Asked of the API, not read from the destroy output. The first line is who is asking, because a check pointed at the wrong account reports "gone" for something still running.

Everything is destroyed, verified against the API rather than read from the destroy output, and checked while signed in to the sandbox account, because a check pointed at the wrong account reports "gone" for something still running.

Key takeaways

  • A progress bar measures effort, not outcome. One hundred percent complete and zero rows in the target are not contradictory readings. They are answers to different questions.
  • Zero failures can mean nothing was checked. A table in error never reaches validation, so its failure count stays at zero permanently. The table state is the field that tells you which zero you have.
  • The tool's log is not always where the reason is. DMS reported that the load failed and told me to look elsewhere. The target database said which value broke it. Both logs were needed.
  • Type ranges are a migration risk, not a detail. One value beyond the target type's ceiling cost the entire table, not the row.
  • Rows written during the load need their own answer. Two thousand of mine arrived by change data capture, and nothing in the full load counter would have told me whether they made it.

The whole week comes down to one sentence worth taking to any migration, in any tool: the question is never "did it finish", it is "does the new database say what the old one said", and those are not answered by the same number.

Lab guide and Terraform: week-29-dms-migration-validation

Comments

How was your experience?
Your feedback helps improve this site.
PoorExcellent