1. Answers
  2. How to create an AWS Route53 record using Pulumi

How do I create an AWS Route53 record using Pulumi?

To create an AWS Route53 record using Pulumi, you need to define a Route53 hosted zone and then create a record within that zone. Below is a Pulumi program written in TypeScript that demonstrates how to achieve this.

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

// Create a new Route53 hosted zone
const zone = new aws.route53.Zone("exampleZone", {
    name: "example.com",
});

// Create a new A record in the hosted zone
const record = new aws.route53.Record("exampleRecord", {
    zoneId: zone.id,
    name: "www.example.com",
    type: "A",
    ttl: 300,
    records: ["192.0.2.1"],
});

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

In this program:

  1. We import the necessary Pulumi and AWS modules.
  2. We create a new Route53 hosted zone named exampleZone with the domain example.com.
  3. We create an A record named exampleRecord within the hosted zone, pointing to the IP address 192.0.2.1 with a TTL of 300 seconds.
  4. We export the name servers of the hosted zone for further use.

This program sets up a basic DNS configuration in AWS Route53, which can be expanded with additional records and configurations as needed.

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