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" 

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"} ]' 

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" 

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" }] } } ] } 
aws route53 change-resource-record-sets \ --hosted-zone-id "$ZONE_ID" \ --change-batch file://mx-change.json 

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."}]' 

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."); } } 

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" } } } ] } 

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 

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 

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" } } 
{ "compilerOptions": { "target": "ES2022", "module": "NodeNext", "moduleResolution": "NodeNext", "strict": true, "skipLibCheck": true, "noEmit": true, "types": ["node"] }, "include": ["src", "test"] } 

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." }, ]; 

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; } 

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 ?? []Source:https://dev.to/sascha-ms/route-53-record-set-protection-lock-critical-dns-records-iio

Related posts