DEV Community

Cover image for Route 53 Record Set Protection: Lock Critical DNS Records
Sascha Mirow-Stanitzok
Sascha Mirow-Stanitzok

Posted on Originally published at sascha-ms.de

Route 53 Record Set Protection: Lock Critical DNS Records

Route 53 record set protection has been available since November 12, 2026, and it solves a problem I used to think needed a lot of IAM acrobatics: a single wrong DNS record can take down an entire production system. An overwritten A record at the zone apex, a deleted MX record, a “cleaned up” CNAME for certificate validation, and suddenly the website is gone, mail stops arriving or the TLS certificate fails to renew. Usually nobody meant any harm. It was a deployment with the wrong variable or a tired click in the console.

That is exactly why I find the new feature so useful. You can now decide directly in the hosted zone which records nobody may change while the protection exists. In this article we set up the protection step by step with the AWS CLI, change a protected record in a controlled way with a script and finally build a small Lambda function with the Serverless Framework that checks every weekday whether all protections are still in place.

In short

With Route 53 record set protection you lock DNS records per name and type right inside the hosted zone, so even admins with full permissions can only change them after removing the protection. It only becomes effective when just a few roles are allowed to delete protections. The biggest pitfall: CloudFormation deployments also fail on protected records, so your pipeline has to know about it.

What you will learn in this article

  • How record set protection works and what it does not do
  • Which DNS records you should protect and which you should leave alone
  • How to create, check and deliberately remove protections with the AWS CLI
  • Who may remove a protection: IAM and service control policies
  • A Lambda function that reports and repairs missing protections

What is Route 53 record set protection?

First, a few terms: in Route 53, a hosted zone is the container for all DNS records of a domain, for example bikerental.example. A record set is the group of all records with the same name and type, such as all A records for www.bikerental.example. The zone apex is the record without a subdomain, in other words the bare domain itself.

A protection always refers to exactly one combination of name and type in a hosted zone. As long as it exists, Route 53 rejects every ChangeResourceRecordSets request that would create, modify or delete those records. According to the documentation, this applies to all users and roles, including those with route53:*. Anyone who wants to make a change has to remove the protection deliberately first.

The most important rules at a glance

A few details matter a lot in practice, so I collected them from the AWS documentation:

  • One protection applies to every record sharing that name and type, regardless of the set identifier. Three weighted A records for www are therefore protected together; you cannot protect just one of them.
  • You can protect a name that does not exist yet. That reserves it: nobody can create this record until the protection is gone.
  • If a single change in a batch hits a protection, the entire request fails with InvalidChangeBatch (HTTP 400). Nothing is changed partially.
  • An UPSERT with exactly the same values does not count as a change and goes through.
  • Each protection can carry a comment of up to 256 characters. Route 53 puts it into the error message, which makes it the ideal place for “Read the runbook first”.
  • Protections cannot be edited. For a new comment, you delete the protection and create it again.
  • The feature works for public and private hosted zones. It does not affect DNS answers; it only controls changes.

How was this solved before?

Until now, you had to add record-level conditions to the IAM policy of every role allowed to change records, for example with the condition keys route53:ChangeResourceRecordSetsNormalizedRecordNames and route53:ChangeResourceRecordSetsRecordTypes. That worked, but it was spread across many policies and hard to keep track of. On top of that, the caller only got a generic “Access Denied” without knowing why. The new protection, by contrast, lives on the zone itself, is visible to everyone and explains itself through its comment.

Which DNS records should you protect?

The rule of thumb from the documentation fits well: protect records that rarely change and would cause an outage if changed by accident. I would also look at how often a team needs to work on a record on purpose. Every protection adds an extra step to intended changes, and too many protections quickly lead people to click past the hurdle out of habit.

Record Why protect it? My recommendation
Apex A/AAAA or alias website and API depend on it protect
MX no MX means no incoming mail protect
Apex TXT (SPF, verifications) a broken SPF lands mail in spam protect, but plan for changes
_dmarc TXT, DKIM CNAME mail authentication protect
ACM validation CNAME otherwise certificates will not renew protect
Apex NS and SOA delegation of the zone protect; Route 53 still manages them
Test and preview subdomains change all the time do not protect
Names that should never exist (e.g. admin) prevents shadow hosts protect as a reservation

The apex TXT deserves a second thought: SPF and many domain verifications for SaaS services pile up there. Every new verification then means “remove protection, change, protect again”. That is acceptable, but your team should know about it. For NS and SOA at the apex, the documentation states explicitly that the protection only blocks your changes and Route 53 can still maintain them itself.

🎬 How a change flows with Route 53 record set protection – this animated diagram only runs on my site: watch it on sascha-ms.de

Set up Route 53 record set protection with the AWS CLI

For this guide I use a fictional zone called bikerental.example. Simply replace the name with your own domain.

Prerequisites

  • A current AWS CLI v2. Older versions do not know the new commands yet; aws route53 create-resource-record-set-protections help quickly shows whether your version is recent enough.
  • Permissions for route53:CreateResourceRecordSetProtections, route53:ListResourceRecordSetProtections and, for testing, route53:DeleteResourceRecordSetProtections on the hosted zone.
  • A hosted zone where you can practice safely. I recommend trying this in a test account first.

Step 1: Find the hosted zone ID

ZONE_ID=$(aws route53 list-hosted-zones-by-name \
  --dns-name bikerental.example \
  --query "HostedZones[0].Id" --output text)
ZONE_ID=${ZONE_ID##*/}   # strip "/hostedzone/"
echo "$ZONE_ID"
Enter fullscreen mode Exit fullscreen mode

The output is an ID like Z0123456789EXAMPLE. Double-check that it really is the right zone, especially if you have public and private zones with the same name.

Step 2: Protect the most important records

aws route53 create-resource-record-set-protections \
  --hosted-zone-id "$ZONE_ID" \
  --protections '[
    {"RecordName":"bikerental.example","RecordType":"A","Comment":"Production. Read runbook DNS-01 before changing."},
    {"RecordName":"bikerental.example","RecordType":"AAAA","Comment":"Production. Read runbook DNS-01 before changing."},
    {"RecordName":"bikerental.example","RecordType":"MX","Comment":"Mail delivery. Change only after agreement."},
    {"RecordName":"www.bikerental.example","RecordType":"CNAME"}
  ]'
Enter fullscreen mode Exit fullscreen mode

On success you get an empty response. A request may contain at most 100 entries, and it is all or nothing. If an entry is already protected, the batch fails with InvalidResourceRecordSetProtectionBatch, and the error names the affected entry.

Step 3: List the protections

aws route53 list-resource-record-set-protections --hosted-zone-id "$ZONE_ID"
Enter fullscreen mode Exit fullscreen mode

You get a list under ResourceRecordSetProtections with RecordName, RecordType and, if set, Comment. Note that the names come back fully qualified with a trailing dot, i.e. bikerental.example.. This matters as soon as you compare the list in a script.

Step 4: Test the protection

Now for the actual test: we deliberately try to overwrite the MX record. Create a file called mx-change.json:

{
  "Comment": "Test: change MX",
  "Changes": [
    {
      "Action": "UPSERT",
      "ResourceRecordSet": {
        "Name": "bikerental.example",
        "Type": "MX",
        "TTL": 3600,
        "ResourceRecords": [{ "Value": "10 mail.new-provider.example" }]
      }
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode
aws route53 change-resource-record-sets \
  --hosted-zone-id "$ZONE_ID" \
  --change-batch file://mx-change.json
Enter fullscreen mode Exit fullscreen mode

Expected result: the call fails with InvalidChangeBatch. The message contains the name, the type and your comment and points to DeleteResourceRecordSetProtections. That is exactly what we want: whoever ends up here immediately sees why it does not work and where the instructions are.

Step 5: Reserve a name

aws route53 create-resource-record-set-protections \
  --hosted-zone-id "$ZONE_ID" \
  --protections '[{"RecordName":"admin.bikerental.example","RecordType":"A","Comment":"Reserved. No public admin host."}]'
Enter fullscreen mode Exit fullscreen mode

Afterwards the name appears among your protections, while the record list stays empty for it. Anyone trying to create admin.bikerental.example as an A record gets the same error as in step 4.

How do I change a protected record?

Sooner or later you will need to change a protected record on purpose, for example when switching mail providers. The procedure is always the same: remove the protection, apply the change, restore the protection. The most dangerous part is the last step, because it is easy to forget under stress. That is why I would not do it by hand but use a small script that restores the protection in a finally block, whether the change succeeds or not.

The script reads a change batch, remembers only the affected protections including their comments, removes exactly those, applies the change and waits until Route 53 reports it as INSYNC. After that, it restores the protection.

// src/change-protected.ts
// Usage: npm run change -- <HostedZoneId> <change-batch.json>
import { readFile } from "node:fs/promises";
import {
  ChangeResourceRecordSetsCommand,
  DeleteResourceRecordSetProtectionsCommand,
  waitUntilResourceRecordSetsChanged,
  type ChangeBatch,
} from "@aws-sdk/client-route-53";
import { normalizeName, type WantedProtection } from "./protections.js";
import { createProtections, listProtections, route53 } from "./route53.js";

const [hostedZoneId, file] = process.argv.slice(2);
if (!hostedZoneId || !file) {
  console.error("Usage: npm run change -- <HostedZoneId> <change-batch.json>");
  process.exit(1);
}

const changeBatch: ChangeBatch = JSON.parse(await readFile(file, "utf8"));
const touched = new Set(
  (changeBatch.Changes ?? []).map(
    (c) => `${normalizeName(c.ResourceRecordSet!.Name!)}|${c.ResourceRecordSet!.Type}`,
  ),
);

// 1. Remember only the protections this change touches (including comments)
const affected: WantedProtection[] = (await listProtections(route53, hostedZoneId))
  .filter((p) => touched.has(`${normalizeName(p.name)}|${p.type}`))
  .map((p) => ({ name: normalizeName(p.name), type: p.type as WantedProtection["type"], comment: p.comment }));

console.log(`Affected protections: ${affected.length}`);

try {
  // 2. Remove exactly those protections
  if (affected.length > 0) {
    await route53.send(
      new DeleteResourceRecordSetProtectionsCommand({
        HostedZoneId: hostedZoneId,
        Protections: affected.map((p) => ({ RecordName: p.name, RecordType: p.type })),
      }),
    );
  }

  // 3. Apply the change and wait until it is on all Route 53 servers
  const { ChangeInfo } = await route53.send(
    new ChangeResourceRecordSetsCommand({ HostedZoneId: hostedZoneId, ChangeBatch: changeBatch }),
  );
  await waitUntilResourceRecordSetsChanged(
    { client: route53, maxWaitTime: 300 },
    { Id: ChangeInfo!.Id! },
  );
  console.log(`Change ${ChangeInfo!.Id} is INSYNC.`);
} finally {
  // 4. Always restore the protection, even if step 3 fails
  if (affected.length > 0) {
    await createProtections(route53, hostedZoneId, affected);
    console.log("Protection restored.");
  }
}
Enter fullscreen mode Exit fullscreen mode

You run it with npm run change -- Z0123456789EXAMPLE mx-change.json. The script uses the same helper functions as the Lambda function further down; you will find the complete files in the DNS guard section. If you introduce such a script in your team, also embed it in a runbook. I described how I structure runbooks in How to Write a Runbook: Template and Lambda Examples.

Who may remove a protection?

This is the real crux: a protection is worth exactly as much as your control over route53:DeleteResourceRecordSetProtections. Anyone allowed to run this action on the hosted zone can delete every protection in it. The three new actions only know the hosted zone as a resource and have no condition keys of their own, so you cannot restrict them to individual records.

In an AWS organization, I would therefore deny deleting protections to everyone except one clearly named role for DNS administration, using a service control policy (SCP). An SCP is a policy that AWS Organizations applies to entire accounts and that even administrators inside the account cannot override.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "OnlyDnsAdminsMayRemoveProtections",
      "Effect": "Deny",
      "Action": "route53:DeleteResourceRecordSetProtections",
      "Resource": "*",
      "Condition": {
        "ArnNotLike": {
          "aws:PrincipalArn": "arn:aws:iam::*:role/dns-admin"
        }
      }
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

Without Organizations, you can get something similar with a permissions boundary or simply by allowing the action in a single role only. CloudTrail helps as well: it records creating, deleting and listing protections. An EventBridge pattern on DeleteResourceRecordSetProtections with a notification is quick to build and makes every removal visible. I made a similar argument for Secrets Manager cross-account replication: the feature itself is only half the story, the permissions around it decide.

What happens with CloudFormation, CDK and the Serverless Framework?

This is the part you should clarify with your team before adding the first protection. According to the documentation, changes to protected records via CloudFormation, the CLI and SDKs fail with the same InvalidChangeBatch error. CDK and the Serverless Framework generate CloudFormation in the end, so the same applies to them.

If a deployment changes a protected record, the resource update fails and CloudFormation rolls the stack back. That is intended, but it can turn a pipeline red unexpectedly. Deleting behaves similarly: a stack that wants to remove a protected record gets stuck, and a hosted zone with protections cannot be deleted at all, even if the protection only covers a reserved name. If you ever end up in UPDATE_ROLLBACK_FAILED along the way, my article on force rollback in CloudFormation will help.

Is there a CloudFormation resource for protections?

As of today, I have not found one. I went through the Route 53 resources in aws-cdk-lib 2.277.0, and there is nothing for record set protection yet. Until that arrives, you manage protections outside your stacks: via the CLI, a script or the Lambda function from the next section. I actually like that: the protection should not disappear with the very deployment that accidentally breaks the record.

My recommendation for everyday work: protect records whose definition in code is stable. For the rare planned changes, add a “remove protection” step before the deployment and a “restore protection” step after it, run by the DNS admin role and not by the regular pipeline role.

Check protections automatically: a DNS guard with Lambda

A protection that someone deleted and never restored is worse than none at all, because everyone feels safe. So now we build a small Lambda function that regularly compares the desired protections with the actual state, recreates missing ones and writes a CloudWatch metric. If something is missing, an alarm goes off.

Diagram: EventBridge schedule starts the dns-guard Lambda, which checks Route 53 protections and raises an alarm via a metric

The DNS guard: schedule, Lambda, Route 53 and an alarm based on an EMF metric.

Project structure

dns-guard/
├── serverless.yml
├── package.json
├── tsconfig.json
├── src/
│   ├── config.ts            # desired protections
│   ├── protections.ts       # comparison, normalization, batches
│   ├── route53.ts           # SDK calls
│   ├── handler.ts           # Lambda
│   └── change-protected.ts  # script for planned changes
└── test/
    └── protections.test.ts
Enter fullscreen mode Exit fullscreen mode

Step 1: Create the project

mkdir dns-guard && cd dns-guard
npm init -y
npm install @aws-sdk/client-route-53
npm install -D typescript tsx @types/node
Enter fullscreen mode Exit fullscreen mode

Add "type": "module" and the scripts to package.json. The TypeScript configuration is deliberately simple:

{
  "name": "dns-guard",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "scripts": {
    "typecheck": "tsc --noEmit",
    "test": "node --import tsx --test test/*.test.ts",
    "change": "tsx src/change-protected.ts"
  },
  "dependencies": {
    "@aws-sdk/client-route-53": "^3.1169.0"
  },
  "devDependencies": {
    "@types/node": "^22.0.0",
    "tsx": "^4.20.0",
    "typescript": "^5.9.0"
  }
}
Enter fullscreen mode Exit fullscreen mode
{
  "compilerOptions": {
    "target": "ES2022",
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "strict": true,
    "skipLibCheck": true,
    "noEmit": true,
    "types": ["node"]
  },
  "include": ["src", "test"]
}
Enter fullscreen mode Exit fullscreen mode

Step 2: Define the desired protections

The configuration is the target state. It belongs in the repository so that every change to a protection gets a review.

// src/config.ts
import type { WantedProtection } from "./protections.js";

const zone = "bikerental.example";
const why = "Production. Read runbook DNS-01 before changing.";

export const wantedProtections: WantedProtection[] = [
  { name: zone, type: "A", comment: why },
  { name: zone, type: "AAAA", comment: why },
  { name: zone, type: "MX", comment: "Mail delivery. Change only after agreement." },
  { name: zone, type: "TXT", comment: "SPF and domain verifications." },
  { name: `www.${zone}`, type: "CNAME", comment: why },
  { name: `_dmarc.${zone}`, type: "TXT" },
  // Reserve a name that does not exist (yet): nobody can create it
  { name: `admin.${zone}`, type: "A", comment: "Reserved. No public admin host." },
];
Enter fullscreen mode Exit fullscreen mode

Step 3: Comparison and normalization

Route 53 returns names with a trailing dot. For ListResourceRecordSets, it is also documented that special characters such as * appear in octal as \052. I therefore normalize both as a precaution before comparing target and actual state.

// src/protections.ts
import type { RRType } from "@aws-sdk/client-route-53";

export interface WantedProtection {
  name: string; // full name, e.g. "bikerental.example"
  type: RRType;
  comment?: string; // max. 256 characters, shown in the error message
}

export interface ProtectionKey {
  name: string;
  type: string;
}

// Route 53 returns names with a trailing dot and special characters in octal (\052 = *)
export function normalizeName(name: string): string {
  return name.replace(/\\052/g, "*").replace(/\.$/, "").toLowerCase();
}

const keyOf = (p: ProtectionKey) => `${normalizeName(p.name)}|${p.type}`;

export function diffProtections(
  wanted: WantedProtection[],
  existing: ProtectionKey[],
): { missing: WantedProtection[]; unexpected: ProtectionKey[] } {
  const existingKeys = new Set(existing.map(keyOf));
  const wantedKeys = new Set(wanted.map(keyOf));
  return {
    missing: wanted.filter((w) => !existingKeys.has(keyOf(w))),
    unexpected: existing.filter((e) => !wantedKeys.has(keyOf(e))),
  };
}

export function chunk<T>(items: T[], size: number): T[][] {
  const result: T[][] = [];
  for (let i = 0; i < items.length; i += size) {
    result.push(items.slice(i, i + size));
  }
  return result;
}
Enter fullscreen mode Exit fullscreen mode

Step 4: Route 53 calls

The SDK client comes with a paginator that automatically loads pages of up to 300 entries. When creating protections, we split them into batches of 100, because that is the limit per request.

// src/route53.ts
import {
  Route53Client,
  CreateResourceRecordSetProtectionsCommand,
  paginateListResourceRecordSetProtections,
} from "@aws-sdk/client-route-53";
import { chunk, type ProtectionKey, type WantedProtection } from "./protections.js";

// Route 53 is a global service, the API runs in us-east-1
export const route53 = new Route53Client({ region: "us-east-1" });

export async function listProtections(
  client: Route53Client,
  hostedZoneId: string,
): Promise<(ProtectionKey & { comment?: string })[]> {
  const result: (ProtectionKey & { comment?: string })[] = [];
  const pages = paginateListResourceRecordSetProtections(
    { client },
    { HostedZoneId: hostedZoneId },
  );
  for await (const page of pages) {
    for (const p of page.ResourceRecordSetProtections ?? []) {
      result.push({ name: p.RecordName!, type: p.RecordType!, comment: p.Comment });
    }
  }
  return result;
}

export async function createProtections(
  client: Route53Client,
  hostedZoneId: string,
  protections: WantedProtection[],
): Promise<void> {
  // at most 100 entries per request, each request is all or nothing
  for (const batch of chunk(protections, 100)) {
    await client.send(
      new CreateResourceRecordSetProtectionsCommand({
        HostedZoneId: hostedZoneId,
        Protections: batch.map((p) => ({
          RecordName: p.name,
          RecordType: p.type,
          ...(p.comment ? { Comment: p.comment } : {}),
        })),
      }),
    );
  }
}
Enter fullscreen mode Exit fullscreen mode

Step 5: The Lambda handler

The handler writes the metric in Embedded Metric Format (EMF). EMF is a JSON format for log lines from which CloudWatch creates metrics automatically, without any extra API call. It matters to me that repaired gaps are counted too: if a protection was missing, someone removed it, and you want to know about that.

// src/handler.ts
import { wantedProtections } from "./config.js";
import { diffProtections } from "./protections.js";
import { createProtections, listProtections, route53 } from "./route53.js";

const hostedZoneId = process.env.HOSTED_ZONE_ID!;
const autoRepair = process.env.AUTO_REPAIR === "true";

export const handler = async () => {
  const existing = await listProtections(route53, hostedZoneId);
  const { missing, unexpected } = diffProtections(wantedProtections, existing);

  if (missing.length > 0 && autoRepair) {
    await createProtections(route53, hostedZoneId, missing);
  }

  // Embedded Metric Format: CloudWatch turns this log line into a metric
  console.log(
    JSON.stringify({
      _aws: {
        Timestamp: Date.now(),
        CloudWatchMetrics: [
          {
            Namespace: "DnsGuard",
            Dimensions: [["HostedZoneId"]],
            Metrics: [
              { Name: "MissingProtections", Unit: "Count" },
              { Name: "RepairedProtections", Unit: "Count" },
            ],
          },
        ],
      },
      HostedZoneId: hostedZoneId,
      // Count repaired gaps too: someone removed a protection
      MissingProtections: missing.length,
      RepairedProtections: autoRepair ? missing.length : 0,
      missing: missing.map((m) => `${m.name} ${m.type}`),
      unexpected: unexpected.map((u) => `${u.name} ${u.type}`),
    }),
  );

  return { missing: missing.length, unexpected: unexpected.length, repaired: autoRepair };
};
Enter fullscreen mode Exit fullscreen mode

Step 6: serverless.yml

The function’s role may read and create protections, but not delete them. That way the guard itself can never become the problem. You can check the schedule with my EventBridge cron explainer; the times are in UTC.

# serverless.yml
service: dns-guard
frameworkVersion: "4"

params:
  default:
    hostedZoneId: Z0123456789EXAMPLE

provider:
  name: aws
  runtime: nodejs22.x
  architecture: arm64
  region: eu-central-1
  memorySize: 256
  timeout: 60
  logRetentionInDays: 30
  environment:
    HOSTED_ZONE_ID: ${param:hostedZoneId}
    AUTO_REPAIR: "true"
  iam:
    role:
      statements:
        # Read and create yes, delete deliberately not
        - Effect: Allow
          Action:
            - route53:ListResourceRecordSetProtections
            - route53:CreateResourceRecordSetProtections
          Resource: arn:aws:route53:::hostedzone/${param:hostedZoneId}

functions:
  check:
    handler: src/handler.handler
    events:
      - schedule: cron(0/30 6-20 ? * MON-FRI *)

resources:
  Resources:
    MissingProtectionsAlarm:
      Type: AWS::CloudWatch::Alarm
      Properties:
        AlarmDescription: A DNS protection was missing (Route 53 record set protection)
        Namespace: DnsGuard
        MetricName: MissingProtections
        Dimensions:
          - Name: HostedZoneId
            Value: ${param:hostedZoneId}
        Statistic: Maximum
        Period: 1800
        EvaluationPeriods: 1
        Threshold: 1
        ComparisonOperator: GreaterThanOrEqualToThreshold
        TreatMissingData: notBreaching
Enter fullscreen mode Exit fullscreen mode

Step 7: Test and deploy

// test/protections.test.ts
import { test } from "node:test";
import assert from "node:assert/strict";
import { chunk, diffProtections, normalizeName } from "../src/protections.js";

test("normalizes trailing dot, upper case and \\052", () => {
  assert.equal(normalizeName("WWW.Bikerental.example."), "www.bikerental.example");
  assert.equal(normalizeName("\\052.bikerental.example."), "*.bikerental.example");
});

test("finds missing and unexpected protections", () => {
  const { missing, unexpected } = diffProtections(
    [
      { name: "bikerental.example", type: "A" },
      { name: "bikerental.example", type: "MX" },
    ],
    [
      { name: "bikerental.example.", type: "A" },
      { name: "alt.bikerental.example.", type: "CNAME" },
    ],
  );
  assert.deepEqual(missing.map((m) => m.type), ["MX"]);
  assert.deepEqual(unexpected.map((u) => u.name), ["alt.bikerental.example."]);
});

test("splits into batches of at most 100", () => {
  const sizes = chunk(Array.from({ length: 230 }, (_, i) => i), 100).map((c) => c.length);
  assert.deepEqual(sizes, [100, 100, 30]);
});
Enter fullscreen mode Exit fullscreen mode
npm run typecheck
npm test
serverless deploy --param="hostedZoneId=Z0123456789EXAMPLE"
serverless invoke -f check
Enter fullscreen mode Exit fullscreen mode

Expected result: the three tests pass. The first invocation of the function reports something like {"missing":3,"unexpected":0,"repaired":true} if you only protected some records via the CLI beforehand, and every further invocation "missing":0. The log contains the EMF line, and the MissingProtections metric appears under the DnsGuard namespace. Add an SNS action to the alarm so the notification actually reaches you.

Cost and security

On weekdays the function runs about 30 times a day for a few hundred milliseconds, which stays in the range of a few cents per month and often within the free tier. On top of that come one CloudWatch alarm and the custom metric, billed at the usual CloudWatch prices. For the protection itself, neither the announcement nor the Route 53 pricing page mentions any extra cost. Security-wise: the function gets no permission to delete, and you can set AUTO_REPAIR to "false" if you only want to report and not repair.

Common mistakes and how to avoid them

  • The pipeline role may delete protections: then the next script simply bypasses them. Only allow deleting for a dedicated role.
  • Protecting too much: protecting test subdomains trains the team to click past the warning. Stick to a few truly critical records.
  • Batches with mixed changes: a single protected record makes the whole batch fail. Run planned changes to protected records separately.
  • Comparing names incorrectly: without normalizing the trailing dot and upper case, a script keeps reporting “missing” although everything is there.
  • The zone cannot be deleted: first remove all protections, including reservations, then the records, then the zone.
  • Ignoring throttling: retry with backoff on Throttling or PriorRequestNotComplete; the SDK already handles standard retries.

My take

I think record set protection is one of those features you briefly underestimate after reading the announcement and want immediately after your first DNS incident. It is unspectacular, and that is exactly what I like about it: a clear mechanism right where the mistake happens, with an error message that actually helps people.

Two things I see critically. First, native CloudFormation support is still missing, so anyone who wants to manage everything as infrastructure as code needs an extra step. Second, the protection is only as good as the permissions behind it. Without an SCP or a tightly limited role, it is more of a warning sign than a barrier. Still, even the warning sign with a good comment probably prevents most accidents, because the vast majority of DNS mistakes are just that: mistakes.

FAQ

Does Route 53 record set protection cost extra?

Neither the announcement nor the Route 53 pricing page lists a separate price for protections. Still, check the current pricing page before using it at scale.

Does the protection affect DNS resolution?

No. The protection only controls changes via the API, the console and tools. Answers to DNS queries stay the same.

Can I protect only one of several weighted records?

No. One protection always applies to every record sharing that name and type, whatever the set identifier. Weighted or latency-based records are always protected together.

Does it work with private hosted zones?

Yes, according to AWS the feature is available for public and private hosted zones in all commercial Regions.

Your next step

Open your most important hosted zone today and write down which three records would cause the most damage if changed by accident. Protect exactly those three with a meaningful comment, then check which roles are allowed to run DeleteResourceRecordSetProtections. I am curious: which DNS record has already caused an outage for you, and would the protection have prevented it?

All code from this article, ready to run: smirowstanitzok/sascha-ms-examples

Sources

This post was created with AI assistance.


👉 Next step: Working with AWS CDK? Grab my printable AWS CDK cheat sheet with commands, concepts and a stack skeleton.

📬 Stay updated: New articles on serverless, AI and leading tech teams via RSS, browser push or the weekly newsletter (in German).

Originally published on sascha-ms.de. More articles on serverless, AI in everyday development and leading tech teams: sascha-ms.de/en

Top comments (0)