Skip to content

DNS automation

On the hosted service, sharing an app on its own hostnames needs DNS records at your provider: the TXT record that verifies the domain, then a CNAME for each shared hostname (see Domains and addresses). DNS automation creates and removes those records for you. You give Houseguest™ an API credential for that one zone; nothing else in the zone is touched.

Providers: Cloudflare, Amazon Route 53 and DigitalOcean.

With DNS automation on for a domain:

  1. While the domain is unverified, Houseguest creates _houseguest.<domain> TXT "houseguest-verify=…" and checks it at once. It is also checked every 10 minutes, as for a record made by hand.
  2. Once the domain is verified, every name under it that your agents forward, or an open preview uses, gets name CNAME <short name>.edge.houseguest.dev (DNS-only, TTL 300 seconds), unless that name is set to be made by hand (see Each hostname).
  3. A name that stops being forwarded loses the CNAME Houseguest made for it. Changes are picked up every 5 minutes, or at once with Update records on the domain’s page.

Rules that always hold:

  • Houseguest changes only records it created. It keeps the provider’s id of every record it makes, and never edits or deletes any other. On Cloudflare its records also carry the comment Managed by Houseguest.
  • A record you made is never overwritten. If a name already has a record Houseguest did not create, the domain’s page lists it as Conflict and leaves it. If it already points at your target, it is listed as Made outside Houseguest and left as it is.
  • A record you changed is yours. If you edit a record Houseguest created, it is listed as Changed by hand, no longer managed, and never deleted.
  • A zone apex takes no CNAME. If a shared name is the zone itself (for example example.com in the zone example.com), the page lists it as By hand: create an ALIAS, a flattened CNAME or A records yourself.
  • Off by default, per domain. A credential can be stored and left off.

The domain’s switch is the master switch. Within it, each hostname has its own choice, Create the DNS record (the default) or made by hand:

  • Turning a name on (the agent’s page, or Turn on a hostname on the Agents list) shows the checkbox Create the DNS record at Cloudflare (or the domain’s provider), ticked. Untick it to make that name’s record yourself. With DNS automation off the form says so instead; without a credential it says nothing.
  • On the domain’s page, each hostname in Records has Stop managing or Manage. Stopping offers to delete the record Houseguest created for it (unticked by default); otherwise the record stays at the provider, no longer managed. Houseguest never creates a record for a name made by hand.
  • Changing a name’s choice needs Manage DNS automation. Someone who can turn names on but lacks it gets the domain’s default: the checkbox shows, read-only.

A name managed again after its record was left in place shows Made outside Houseguest: the record stays as it is, and Houseguest does not take it back.

  1. Create a credential at your provider, limited as described below.
  2. Open Domains & addresses, then the domain’s name.
  3. Under DNS provider credential, pick the provider, check the Zone (the domain itself or a domain above it), paste the credential and choose Check and save.
  4. Turn on Create and remove records automatically.

Needs the Manage DNS automation permission. Owners and Admins hold it; Members and Preview managers do not. It includes Manage domains.

The credential is write-only. It is stored encrypted, with a key kept apart from the database, used only by the servers that hold the database, and never sent to the edges. No page, API or export shows it again; the domain’s page shows only Cloudflare token, saved 29 Oct, last used 3 min ago. Saving, replacing and removing a credential are recorded in the activity log, without the value.

Before it stores a credential, Houseguest confirms it reaches the zone you named, and refuses it if not: Cloudflare refused the token: zone example.com not found. Where the provider’s API can tell, it also checks that the credential reaches no other zone:

Provider Confirmed Not knowable in advance
Cloudflare The token sees this zone and reads its records. A token that sees any other zone is refused. Edit access, until the first change
Route 53 The hosted zone ID names this zone, the zone is public, the key reads its records. A key that cannot list other hosted zones (as a one-zone policy cannot) is reported as limited Whether a key that may list other zones can also change them: Route 53 cannot say without trying. It is saved, and the page says so
DigitalOcean The token reads this domain and its records. The page states how many other domains the team has Nothing narrower: DigitalOcean tokens cannot be limited to one domain

An API token with DNS edit on this one zone:

  1. In the Cloudflare dashboard: My Profile → API Tokens → Create Token, then Edit zone DNS → Use template.
  2. Permissions: Zone · DNS · Edit (the template’s only permission; add nothing).
  3. Zone Resources: Include · Specific zone · example.com. Not All zones: a token that reaches another zone is refused.
  4. Optionally set an end date (TTL). Houseguest stops with a provider error when it lapses; paste a new token with Replace credential.
  5. Continue to summary → Create Token, and paste the token into the console.

Records Houseguest creates are DNS-only (never proxied): the edge must answer directly to obtain each name’s certificate.

An IAM user with an access key, whose policy reaches one hosted zone:

  1. Find the hosted zone ID in the Route 53 console (Hosted zones, for example Z0123456789ABCDEFGHIJ).

  2. In IAM, create a user for Houseguest (no console access), and attach this inline policy, with your hosted zone ID:

    {
    "Version": "2012-10-17",
    "Statement": [
    {
    "Sid": "HouseguestOneHostedZone",
    "Effect": "Allow",
    "Action": [
    "route53:GetHostedZone",
    "route53:ListResourceRecordSets",
    "route53:ChangeResourceRecordSets"
    ],
    "Resource": "arn:aws:route53:::hostedzone/Z0123456789ABCDEFGHIJ"
    }
    ]
    }

    Nothing else: no route53:ListHostedZones, no * resource. Houseguest asks to list hosted zones only to confirm it is refused.

  3. Optionally narrow the changes further to the record types and names Houseguest uses, by adding a condition to the statement (lab.example.com is the verified domain):

    "Condition": {
    "ForAllValues:StringEquals": {
    "route53:ChangeResourceRecordSetsRecordTypes": ["TXT", "CNAME"]
    },
    "ForAllValues:StringLike": {
    "route53:ChangeResourceRecordSetsNormalizedRecordNames": [
    "_houseguest.lab.example.com",
    "*.lab.example.com"
    ]
    }
    }
  4. Security credentials → Create access key (third-party service), and paste the access key ID and secret access key into the console, with the hosted zone ID.

Route 53 changes always name the record they replace: if anyone edits a Houseguest record in between, Route 53 itself refuses the change, so your edit is never lost.

A personal access token with the domain scopes only.

  1. In the DigitalOcean control panel: API → Tokens → Generate New Token.
  2. Choose Custom Scopes and select only domain: read, create, update and delete. No other resource.
  3. Set an expiration if you want one, generate the token and paste it into the console.

The domain’s page states how many other domains the token reaches.

  • Turn off: Houseguest stops changing records. The dialog offers to delete the records it created (unticked by default: names stop reaching previews once their CNAME goes). The credential stays stored.
  • Replace credential: paste a new one, for example after rotating a token. Same provider and zone: the switch stays as it was. Another provider or zone: remove the current credential first.
  • Remove credential: deletes it, optionally deleting the records Houseguest created first.
  • Remove the domain (Domains & addresses) also deletes its credential, and offers to delete the records Houseguest created (ticked by default; needs Manage DNS automation). Records changed by hand are left in every case.

If a provider refuses a change, the domain’s page shows the reason in the provider’s words, for example Cloudflare refused the token: authentication error. Records already made stay as they are, and the change is retried every 5 minutes.