1. Answers
  2. Adding a TXT record in AWS Route 53

How do I add a TXT record in Route 53?

In this guide, we will demonstrate how to add a TXT record to an AWS Route 53 hosted zone using Pulumi. This is useful for various purposes, such as domain verification or setting up email services.

Key Points:

  • We will create a new Route 53 hosted zone.
  • We will add a TXT record to the created hosted zone.
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

// Create a new Route 53 Hosted Zone
const hostedZone = new aws.route53.Zone("exampleZone", {
    name: "example.com",
});

// Add a TXT record to the Hosted Zone
const txtRecord = new aws.route53.Record("exampleTxtRecord", {
    zoneId: hostedZone.zoneId,
    name: "example.com",
    type: "TXT",
    ttl: 300,
    records: ["\"v=spf1 include:example.com ~all\""], // Example TXT record value
});

// Export the name servers for the created hosted zone
export const nameServers = hostedZone.nameServers;

Concluding Summary:

In this example, we created a new Route 53 hosted zone named example.com and added a TXT record to it. The TXT record can be used for domain verification or other DNS-related configurations. We also exported the name servers for the hosted zone, which can be used to update your domain registrar settings.

Deploy this code

Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.

Sign up

New to Pulumi?

Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.

Sign up