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:
- We import the necessary Pulumi and AWS modules.
- We create a new Route53 hosted zone named
exampleZone
with the domainexample.com
. - We create an A record named
exampleRecord
within the hosted zone, pointing to the IP address192.0.2.1
with a TTL of 300 seconds. - 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 upNew to Pulumi?
Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.
Sign upThank you for your feedback!
If you have a question about how to use Pulumi, reach out in Community Slack.
Open an issue on GitHub to report a problem or suggest an improvement.