Introduction
The Amazon Route 53 record resource in Terraform represents a direct mapping to the aws_route53_record managed resource that governs DNS record sets within a hosted zone. The reference material establishes that the resource manages an Route53 Record resource and a minimal configuration to get started requires a name argument. The same material shows a minimal configuration snippet where the resource is declared as resource "aws_route53_record" "example" with a required argument name = "my-route53-record". This minimal declaration illustrates the entry point for creating DNS records declaratively.
The ecosystem around the core resource includes community modules that wrap the resource with opinionated defaults and additional routing policy support. One module creates a Route53 record in AWS and provides a flexible way to configure various types of routing policies for DNS records. The module creates a Route53 record with the specified zone ID, name, type, TTL, and records. It supports optional attributes. It supports different routing policies including geolocation, failover, latency, weighted, and CIDR-based routing. It provides the option for alias records that can point to AWS resources using their AWS resource name. It allows only one routing policy block to be supplied. It adheres to security best practices by leveraging automated scanning with Checkov.
A second community implementation provides a Route53 record resource with a different interface. It supports creating an A record for foo.com in zone foo.com using arguments domain, type, records. It also supports creating an A record for www.foo.com in zone foo.com using hostname and domain. It supports creating a CNAME record for www.foo.com pointing to www.bar.com.
The reference material also describes creating records by using the Amazon Route 53 console. The procedure explains how to create records using the Amazon Route 53 console. For information about how to create records using the Route 53 API, see ChangeResourceRecordSets in the Amazon Route 53 API Reference. The material notes that to create records for complex routing configurations, you can also use the Traffic Flow visual editor and save the configuration as a traffic policy. You can then associate the traffic policy with one or more domain names or subdomain names, in the same hosted zone or in multiple hosted zones. In addition, you can roll back the updates if the new configuration isn't performing as you expected it to. For more information, see Using Traffic Flow to route DNS traffic.
The console workflow includes signing in to the AWS Management Console and opening the Route 53 console at https://console.aws.amazon.com/route53/. In the navigation pane, choose Hosted zones. If you already have a hosted zone for your domain, skip to step 5. If you don't, perform the applicable procedure to create a hosted zone. On the Hosted zones page, choose the name of the hosted zone that you want to create records in. Choose Create record. Choose and define the applicable routing policy and values. Choose Create records.
Your new records take time to propagate to the Route 53 DNS servers. Currently, the only way to verify that changes have propagated is to use the GetChange API action. Changes generally propagate to all Route 53 name servers within 60 seconds.
Core Resource Definition
Resource Identity and Minimal Configuration
The aws_route53_record resource manages an Route53 Record resource. A minimal configuration to get started refers to the Terraform Registry docs for all available arguments. The example shows:
```
resource "awsroute53record" "example" {
Required arguments
name = "my-route53-record"
}
```
The name argument is presented as required in the minimal example. The impact of specifying only name is that the resource can be instantiated but will require additional arguments to be valid in a production deployment. The user must consult the registry docs for the full argument set. The contextual layer connects this minimal declaration to module patterns that abstract name, zone_id, type, ttl, and records into higher level inputs.
Module Example for Flexible Routing
A module creates a Route53 record in AWS. It provides a flexible way to configure various types of routing policies for your DNS records.
The capabilities listed include:
- Creates a Route53 record with the specified zone ID, name, type, TTL, and records.
- Supports optional attributes
- Supports different routing policies including geolocation, failover, latency, weighted, and CIDR-based routing.
- Provides the option for alias records that can point to AWS resources using their AWS resource name.
- Allows only one routing policy block to be supplied.
- Adheres to security best practices by leveraging automated scanning with Checkov.
Examples available here. NOTE: These examples use the latest version of this module.
The minimum example module call is:
module "minimum_example" {
source = "boldlink/route53-records/aws"
version = "insert_latest_version"
zone_id = local.zone_id
name = var.name
type = var.type
ttl = var.ttl
records = var.records
}
Provider requirements are specified in a table.
| Name | Version |
|---|---|
| terraform | >= 0.14.11 |
| aws | >= 4.65.0 |
| Name | Version |
|---|---|
| aws | 5.23.1 |
No modules.
| Name | Type |
|---|---|
| awsroute53record.main | resource |
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| alias | (Optional) An alias block. Conflicts with ttl & records | any | {} | no |
| allow_overwrite | Allow creation of this record in Terraform to overwrite an existing record, if any. This does not affect the ability to update the record in Terraform and does not prevent other resources within Terraform or manual Route 53 changes outside Terraform from overwriting this record. false by default. This configuration is not recommended for most environments. | bool | false | no |
| cidrroutingpolicy | (Optional) A block indicating a routing policy based on the IP network ranges of requestors. Conflicts with any other routing policy. | map(string) | {} | no |
| failoverroutingpolicy | (Optional) A block indicating the routing behavior when associated health check fails. Conflicts with any other routing policy. | any | {} | no |
| geolocationroutingpolicy | (Optional) A block indicating a routing policy based on the geolocation of the requestor. Conflicts with any other routing policy. | any | {} | no |
| healthcheckid | (Optional) The health check the record should be associated with. | string | null | no |
| latencyroutingpolicy | (Optional) A block indicating a routing policy based on the latency between the requestor and an AWS region. Conflicts with any other routing policy |
The table shows that alias conflicts with ttl & records. The allow_overwrite flag defaults to false and is not recommended for most environments. CIDR routing policy, failover routing policy, geolocation routing policy, and latency routing policy are optional blocks that conflict with any other routing policy.
The impact of these constraints is that a user can only select one routing policy per record. The real world consequence is a design decision where failover, geolocation, latency, or CIDR routing must be chosen exclusively.
Community Module Interface Variations
Techservicesillinois Module Arguments
Provides a Route53 record resource.
Create an A record for foo.com in zone foo.com
module "service_name" {
source = "[email protected]:techservicesillinois/terraform-aws-route53-record"
domain = "foo.com"
type = "A"
records = [
"192.168.0.1",
]
}
Create an A record for www.foo.com in zone foo.com
module "service_name" {
source = "[email protected]:techservicesillinois/terraform-aws-route53-record"
hostname = "www"
domain = "foo.com"
type = "A"
records = [
"192.168.0.1",
]
}
Create a CNAME record for www.foo.com pointing to www.bar.com
module "service_name" {
source = "[email protected]:techservicesillinois/terraform-aws-route53-record"
hostname = "www"
domain = "foo.com"
type = "CNAME"
records = [
"www.bar.com",
]
}
The following arguments are supported:
- domain
- (Required) Hosted zone in which to create Route53 record.
- hostname
- (Optional) Hostname for Route53 record.
- type
- (Required) The record type. Valid values are A, AAAA, CAA, CNAME, MX, NAPTR, NS, PTR, SOA, SPF, SRV and TXT.
- records
- (Required) A string list of records.
- ttl
- (Optional) The TTL of the record (default 60)
The impact of the hostname argument is that it allows subdomain creation without repeating domain. The contextual layer connects this to the earlier minimal resource where name is required. The module translates domain plus optional hostname into the full record name.
The valid record types listed are A, AAAA, CAA, CNAME, MX, NAPTR, NS, PTR, SOA, SPF, SRV and TXT. The default TTL is 60 seconds.
Console Creation Workflow and Propagation
Procedure Overview
Creating records by using the Amazon Route 53 console.
The following procedure explains how to create records using the Amazon Route 53 console. For information about how to create records using the Route 53 API, see ChangeResourceRecordSets in the Amazon Route 53 API Reference.
Note
To create records for complex routing configurations, you can also use the Traffic Flow visual editor and save the configuration as a traffic policy. You can then associate the traffic policy with one or more domain names (such as example.com) or subdomain names (such as www.example.com), in the same hosted zone or in multiple hosted zones. In addition, you can roll back the updates if the new configuration isn't performing as you expected it to. For more information, see Using Traffic Flow to route DNS traffic.
To create a record using the Route 53 console
If you're not creating an alias record, go to step 2.
Also go to step 2 if you're creating an alias record that routes DNS traffic to an AWS resource other than an Elastic Load Balancing load balancer or another Route 53 record.
If you're creating an alias record that routes traffic to an Elastic Load Balancing load balancer, and if you created your hosted zone and your load balancer using different accounts, perform the procedure Getting the DNS name for an Elastic Load Balancing load balancer to get the DNS name for the load balancer.
Sign in to the AWS Management Console and open the Route 53 console at https://console.aws.amazon.com/route53/
. In the navigation pane, choose Hosted zones.
If you already have a hosted zone for your domain, skip to step 5. If you don't, perform the applicable procedure to create a hosted zone:
On the Hosted zones page, choose the name of the hosted zone that you want to create records in.
Choose Create record.
Choose and define the applicable routing policy and values
The console steps reflect the same routing policy concepts exposed in the Terraform module. The impact for operators is that console changes are immediate in the UI but require propagation time.
Propagation note:
Choose Create records.
Note
Your new records take time to propagate to the Route 53 DNS servers. Currently, the only way to verify that changes have propagated is to use the GetChange API action. Changes generally propagate to all Route 53 name servers within 60 seconds.
If you're creating multiple records, repeat steps 7 through 8.
Getting the DNS name for an Elastic Load Balancing load balancer
Sign in to the AWS Management Console using the AWS account that was used to create the Classic, Application, or Network Load Balancer that you want to create an alias record for.
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/
The propagation window of up to 60 seconds informs Terraform apply expectations and health check association timing.
Routing Policy Options and Conflicts
The module supports different routing policies including geolocation, failover, latency, weighted, and CIDR-based routing.
The reference material shows optional blocks:
- cidrroutingpolicy | (Optional) A block indicating a routing policy based on the IP network ranges of requestors. Conflicts with any other routing policy.
- failoverroutingpolicy | (Optional) A block indicating the routing behavior when associated health check fails. Conflicts with any other routing policy.
- geolocationroutingpolicy | (Optional) A block indicating a routing policy based on the geolocation of the requestor. Conflicts with any other routing policy.
- latencyroutingpolicy | (Optional) A block indicating a routing policy based on the latency between the requestor and an AWS region. Conflicts with any other routing policy
The impact layer shows that selecting one routing policy prevents mixing policies. The contextual layer connects this to the console Traffic Flow editor which allows complex routing configurations via traffic policy.
Alias Records and Overwrite Behavior
Alias records can point to AWS resources using their AWS resource name.
The alias block is optional. Conflicts with ttl & records.
allow_overwrite | Allow creation of this record in Terraform to overwrite an existing record, if any. This does not affect the ability to update the record in Terraform and does not prevent other resources within Terraform or manual Route 53 changes outside Terraform from overwriting this record. false by default. This configuration is not recommended for most environments.
The real world consequence of allow_overwrite is risk of unintended destruction of manually managed records. The default false protects against accidental overwrite.
Conclusion
The resource aws_route53_record is the foundational Terraform construct for managing Route 53 DNS entries. The reference material demonstrates a minimal resource declaration with name, and a rich module interface that adds zoneid, name, type, ttl, records, optional alias, routing policy blocks for geolocation, failover, latency, CIDR, healthcheckid, and allowoverwrite control. Community modules expose alternative ergonomics using domain, hostname, type, records, and ttl with a default TTL of 60 and a defined set of valid record types.
The console workflow mirrors Terraform capabilities, offering Create record steps, routing policy definition, and propagation notes of approximately 60 seconds verified via GetChange API. Traffic Flow visual editor provides an alternative for complex routing configurations with rollback capability.
The design constraints of one routing policy per record, alias conflict with ttl and records, and the default safety of allow_overwrite false shape operational best practices when authoring infrastructure as code for Route 53.