Skip to main content

Module aws_fake

Module aws_fake 

Source
Expand description

An in-process stand-in for the AWS surface this deployment talks to.

The AWS interactions in this workspace are its own code end to end: crate::route53 signs its own SigV4 requests and reads IMDSv2 itself, with no AWS SDK anywhere in the dependency graph. That makes every one of them reachable from a test with no cloud account, provided there is something on the other end of the wire — which is what this module is.

Two pieces, matching the two AWS services that code calls:

  • FakeImds answers the instance metadata service’s credential read, hands out a fresh access key id per read, and can expire the credential it last issued — on command, or after a set number of API calls, so a single long-running operation can outlive the credential it started with.
  • FakeAws is a Route53 hosted zone that holds record sets, applies ChangeResourceRecordSets batches atomically, answers ListResourceRecordSets a page at a time, and takes a change through PENDING before INSYNC. It refuses what the real service refuses: a CREATE onto a name and type it already holds, a DELETE whose values do not match, and a batch that would push the zone past its record-set quota. It can be told to throttle, to return a server error, or to drop the connection for a set number of calls.

route53_provider joins them: a Route53Dns whose transport is a FakeAws, with retry and polling intervals wound down to milliseconds so a test that drives a retry or a PENDING change resolves it in ordinary test time. Nothing here sleeps for longer than that, and no outcome depends on how long anything took.

Behind the aws-fake feature, which a crate turns on as a dev-dependency — didbot-dns = { workspace = true, features = ["aws-fake"] } under [dev-dependencies] — so that a production build links none of it.

The ACME side of a deployment has its own fake, FakeAcmeServer in didbot-tls’s tests/support, which speaks instant_acme’s HTTP client trait rather than AWS’s wire format. A DNS-01 test wants both: that one for the CA, this one for the zone the challenge is written into.

Structs§

FakeAws
A Route53 hosted zone, in process.
FakeImds
The instance metadata service, as far as InstanceCredentials is concerned: a source of temporary credentials, each with a stated expiry.
ImdsState 🔒
PendingChange 🔒
A change accepted by the zone and not yet INSYNC.
RecordSet 🔒
One record set in the fake hosted zone.
WireChange 🔒
One <Change> out of a ChangeResourceRecordSets body.
ZoneState 🔒

Functions§

error_body 🔒
escape 🔒
normalize 🔒
A record set name as the zone keys it: lowercased, no trailing dot.
parse_changes 🔒
route53_provider
A Route53Dns backed by aws, wound down to test timings.
tag 🔒
Text of the first <tag> at or after from, and the offset past it.
unescape 🔒

Type Aliases§

Key 🔒
A record set’s identity, and the order a zone listing walks: name first, then type.