Publishing a Pulumi provider for Loopia: what I learned

Publishing a Pulumi provider for Loopia: what I learned

Loopia is where I register my domains, and it has no Pulumi provider. For a long time that didn’t matter much, because I set up DNS by hand. Once I started describing everything else in Pulumi, the one thing still living in a web form began to bother me.

So I wrote a Pulumi provider for it. It was a single file that talked to Loopia’s XML-RPC API, and it worked well enough that I copied it into the next project. And the next. This post is about how that file turned into a small public package, @technowobble/loopia-provider, and what I ran into on the way.

One thing up front: this is an unofficial package. I’m not affiliated with Loopia, and they haven’t endorsed it.

Why bother sharing something this small

It’s a niche. If you don’t use Loopia, you can stop reading the first half of this post. But a lot of the problems are general to any Pulumi provider: rate limits, idempotency, what to do when an API can write a value but can’t read it back. I would have liked someone to contribute a ready-made package when I started, so here it is.

The provider

A few design decisions in the original provider turned out to matter, and they all survived into the package:

  • Rate limiting. LoopiaAPI allows 60 calls per minute, and 15 of those can be domain searches. The provider waits three seconds before every call and retries “Rate Limit Exceeded” with a growing back-off. In practice you run Pulumi with --parallel 1.
  • Idempotent create. Before adding a record, it looks for an identical one and adopts it. That makes it safe to bring an existing zone under Pulumi, and it recovers from a run that died after the record was added but before state was saved.
  • Hostname normalisation. Loopia adds a trailing dot to hostname data and may change its case. For MX, CNAME, NS, PTR and SRV records that’s ignored when comparing. TXT records, such as DKIM keys, are compared exactly.
  • Record ids. Loopia identifies a record by a numeric record_id, so that’s stored in Pulumi state and used for updates and deletes.

Using it looks like this:

import * as pulumi from "@pulumi/pulumi";
import { LoopiaZoneRecord } from "@technowobble/loopia-provider";

const cfg = new pulumi.Config();
const creds = {
  loopiaUser: cfg.requireSecret("loopiaUser"),
  loopiaPassword: cfg.requireSecret("loopiaPassword"),
};

new LoopiaZoneRecord("apex-a", {
  domain: "example.com",
  subdomain: "@",
  type: "A",
  ttl: 3600,
  rdata: "192.0.2.10",
  ...creds,
});

Credentials come from Pulumi config as secrets, and the resource marks them as secret outputs as well, so they’re encrypted in state.

The copy-paste problem

Here’s what happens when you copy a file between projects and write “do not modify” in the docs: nothing, until you want to change something. I ended up with five copies, each with its own xmlrpc dependency, and a note in each repo saying the copies should be kept in sync by hand.

Making it a package

The packaging itself is boring, which is what I wanted. TypeScript compiled to CommonJS with declarations, dist as the only published folder, @pulumi/pulumi v3 as a peer dependency and xmlrpc as the only runtime dependency.

The part I was careful about was keeping the resource contract identical, so that existing stacks wouldn’t notice anything had changed. LoopiaZoneRecord still extends pulumi.dynamic.Resource directly. I did not wrap it in a component resource, because that would change the resource URNs and Pulumi would want to replace everything. Same inputs, same outputs, same id format, same secret outputs. The provider code itself was ported unchanged.

Then the tests, with the Loopia API mocked, so none of them can reach the network. There were 25 for 1.0.0 and there are 50 now.

The proof

Tests tell you the package works. They don’t tell you that your real stacks won’t change. For that, I took a pulumi preview --diff of one real project, swapped in the package, and ran the preview again.

The output was identical: 36 resources unchanged. I repeated the same exercise for the other projects. Nothing was ever applied as part of the migration. After that, each project needed one small pull request: install the package, change one import line, delete the local file, uninstall xmlrpc and its types, and fix the docs that still called it a local copy.

Nameservers: set and trust

Version 1.1.0 added LoopiaDomainNameservers, which sets the nameservers a domain is delegated to. I needed it after moving a domain’s DNS to Cloudflare:

import * as cloudflare from "@pulumi/cloudflare";
import { LoopiaDomainNameservers } from "@technowobble/loopia-provider";

const zone = new cloudflare.Zone("example-com", {
  account: { id: cloudflareAccountId },
  name: "example.com",
  type: "full",
});

new LoopiaDomainNameservers("example-com-ns", {
  domain: "example.com",
  nameservers: zone.nameServers,
  ...creds,
});

The awkward part is that the API can set nameservers but can’t read them back. I checked that against the documentation and with read-only calls to the live API. getDomain has no nameserver field, and the zone’s own NS records always say ns1.loopia.se and ns2.loopia.se, even for a domain that’s delegated elsewhere. Public DNS showed Cloudflare’s servers, so the zone data clearly wasn’t the truth.

So the resource is deliberately “set and trust”:

  • Pulumi state is whatever it last wrote.
  • pulumi refresh looks up the domain’s NS records in public DNS and treats that as a hint. If a nameserver you configured is missing, it’s recorded as drift. Extra apex records are tolerated.
  • Deleting the resource does nothing. Removing code can never move a domain’s delegation, and I think that’s the right default for something where a mistake means an outage.
  • DNSSEC isn’t handled at all, because the API has no DNSSEC methods. The README says to remove or update the DS record before switching delegation.

How it was built

I did most of this in one long session with Claude Code. I set the goals, approved the plan and the decisions, reviewed the output, and approved every merge. The repository is public, main is protected by a ruleset that requires a pull request and passing CI, and CI runs typecheck, build, tests, and a check that the npm tarball contains only dist, the README, the licence and package.json.

If you use Loopia and Pulumi, you can install it with npm install @technowobble/loopia-provider. It needs Node 22 or later, and @pulumi/pulumi v3 as a peer dependency. Issues and pull requests are welcome on GitHub.