04 · Drift
Someone changed it in the console. Now what?
Drift is found within minutes, named with whoever caused it, and handled by the namespace's policy. Most of the work is making sure drift means something: that a difference in format, or a value AWS is supposed to change, never sets off a correction.
How drift is found
Three ways, and the event is only ever a hint.
- From events. CloudTrail write events reach the reactor within minutes. It reads the resource from AWS and compares; it never takes the event's contents as the new state.
- From the sweep. On a schedule, every managed resource is read, in case an event never came. It reads only what's in the tree, so its cost follows the tree, not AWS.
- From convergence. Every action reads state before it acts.
The control plane's own changes arrive as events too. The reactor reads the resource, finds it stable, and does nothing.
Notification to lending-team (10:05:31):
Drift corrected: /tidewater/lending/dev/s3.bucket/documents
versioning-configuration status: Suspended -> Enabled
changed by jordan@tidewater.com via console
(PutBucketVersioning, 10:02:47)
corrected at 10:05:29 under COMMIT-8
What happens next
The namespace decides.
An owned namespace remediates (the default) or reports. A namespace set to ownership learning does neither: it writes changes made outside a commit into the tree, which is how a sandbox stays useful (see Supervision).
| Policy | On drift | State shown | Typical use |
|---|---|---|---|
drift remediate | Pulled back to the configuration; a correction is recorded with the CloudTrail identity it reversed; the owner is told | converging briefly | The default; production |
drift report | Recorded and reported; nothing changes until a commit or request reconcile | drifted | During a move from Terraform |
ownership learning | Written into the tree as a commit, crediting whoever made the change | stable | Sandboxes |
Drift that means something
Three things that keep corrections honest.
This is where most tools spend their effort, and where a control plane that remediates by default must be careful. Correcting a difference nobody caused changes a resource for no reason.
Normalise before comparing.
AWS returns policy documents with keys reordered, lists in another order, ARNs where you wrote names, 17.4 where you wrote 17. The type table names one of six fixed normalisers per property: json, set, arn-or-name, version-prefix, case-insensitive, numeric. No custom functions.
The create phase.
A desired count under auto scaling, storage under storage autoscaling: needed at creation, owned by AWS afterwards. Written inside create { }, they are applied when the resource is made and never compared again. When AWS itself made a change, the reason says so, changed by AWS (application-autoscaling).
By reference, never by value.
A secret never enters the tree, which lives in Postgres, Git, exports, plans, and logs. Prefer what AWS keeps (manage-master-user-password); otherwise reference Secrets Manager, read at the moment of the call. Write-only properties are compared with a hash of what was last sent.
Handled carefully, whatever the policy
Fights, and things that go missing.
A resource that keeps drifting. If it's corrected more than three times in an hour, remediation stops for it and an alarm fires. Something is fighting the control plane, and a person needs to find out what. When AWS is the one fighting, the alarm suggests moving the property into create.
A missing stateful resource. A deleted bucket or database is reported, never recreated, even under remediate. An empty database in place of a deleted one would hide the loss.
Alarm: gravity-keep/fighting-resource (09:42:18) /tidewater/lending/dev/intake/lambda.function/fn corrected 4 times in 60 minutes remediation stopped (CTL-032); drift is still observed changed by: role/legacy-deployer (UpdateFunctionConfiguration) jordan@tidewater> request remediation resume .../lambda.function/fn remediation resumed; memory-size 512 -> 1024: corrected
Holds
Break glass, without leaving a mess.
During an incident a reviewed commit can take longer than the outage budget. A hold suspends remediation beneath a path, for a reason and a time, so a person can change things in the console. Drift is still recorded. It's always available to anyone granted hold, and it's never silent.
The holder, the owners, and the incident channel are told exactly what will be pulled back, and how to keep it or get more time.
Anyone granted hold can extend it, each time with a reason, so the original holder needn't be awake. Each extension is limited by policy (four hours), and all of them by a total (24 hours). A hold can't quietly become permanent.
request hold capture writes the held changes into the tree by the namespace's own route: a candidate, a commit request, or lines for a pull request. Once everything held is committed, the hold ends itself.
Remediation resumes, and only what wasn't committed is pulled back.
sam@tidewater> request hold /tidewater/lending/prod/east/intake duration 2h reason "INC-2291: vendor diagnostics" hold 3 active until 00:41; remediation suspended beneath the path; drift is still recorded Hold 3 ends in 30 minutes. will be pulled back: ec2.security-group/intake-lambda egress + tcp 8443 203.0.113.0/24 (sam, console, 22:43) sam@tidewater> request hold capture 3 /tidewater/lending/prod is reviewed: commit request 15 created
The rules
Drift.
- CTL-030
A change event only says where to look; the reactor reads current state from AWS, and a scheduled sweep reads every managed resource whether or not an event arrived.
- CTL-031
A missing stateful resource is reported and never recreated automatically.
- CTL-032
A resource corrected more than three times in one hour stops being remediated, and an alarm fires.
- CTL-033
A hold suspends remediation beneath one path for a stated reason; it warns before it ends, naming what will be pulled back; each extension has its own reason and its own limit, and all of them stop at the policy's total; at expiry only what wasn't committed is pulled back; and every step is recorded in history.
- CTL-061
Every drift is recorded; a drifted resource the control plane is correcting is shown as
converging, and a resource isdriftedonly when the control plane won't correct it on its own. - CTL-075
A held change is kept only by committing it, by capture or by hand, through the namespace's own route (a commit, a commit request, or a Git pull request), and a hold whose held changes are all committed ends itself.