How do I set up an AWS Route 53 record using Pulumi?
Overview
In this example, you will learn how to set up an AWS Route 53 record using Pulumi. We’ll create a DNS record within a hosted zone.
Detailed Explanation
To manage your DNS settings, AWS Route 53 makes it easy with hosted zones and various types of records. In this example, you’ll see how to create a simple A
record that points to a specific IP address.
Key Components:
- AWS Provider Configuration: Set up the provider to interact with AWS.
- Hosted Zone: An existing hosted zone in Route 53 where the record will be created.
- Route 53 Record: The DNS record we wish to add.
Program
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const config = new pulumi.Config();
// The ID of the hosted zone
const zoneId = config.get("zoneId") || "Z3P5QSUBK4POTI";
// Define the Route 53 Record
const example = new aws.route53.Record("example", {
zoneId: zoneId,
name: "example.mydomain.com",
type: aws.route53.RecordType.A,
ttl: 300,
records: ["192.0.2.44"],
});
export const recordName = example.name;
export const recordType = example.type;
export const recordValue = example.records;
Key Points
- Provider Configuration: Crucial to specify the AWS region.
- Hosted Zone: Import or refer to an existing hosted zone.
- Route 53 Record: Define the type, name, TTL, and values.
- Outputs: Provide useful output to know what DNS records are set.
Summary
You have successfully created an AWS Route 53 record using Pulumi. This included setting up an AWS provider, referencing a hosted zone, and finally creating and outputting a DNS A
record.
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.