A Terraform module to create a Route53 Domain Name System (DNS) on Amazon Web Services (AWS). https://aws.amazon.com/route53/
terraform-aws-route53
A Terraform module to create a scalable and highly available Amazon Route53 Domain Name System (DNS) on Amazon Web Services (AWS).
*This module supports Terraform v1.x, v0.15, v0.14, v0.13 as well as v0.12.20 and above and is compatible with the terraform AWS provider v3 as well as v2.45 and above.*
- Top-level Arguments - Module Configuration - Route53 Zone - Route53 Delegation Set - AWS Documentation Route53 - Terraform AWS Provider Documentation - Backwards compatibility in0.0.z and 0.y.z version
Module Features
This module offers a convenient way to create Route53 zones and records.
- Zones:
"mineiros.com")
or multiple zones by passing a list of strings (e.G. ["mineiros.io", "mineiros.com])
as the name parameter. name = "mineiros.io". You can also share the same
records among multiple zones. Please see the [example][same-records-example] for details.
- Records:
- Default TTL for Records
ttl parameter. To adjust the default value for
TTL, please use the default_ttl parameter.
Please see the [examples] for details.
- Delegation Set:
skipdelegationsetcreation to true. If skipdelegationsetcreation isn't set to true and multiple zones
are being created, all created zones will share the same delegation set.
Getting Started
Most basic usage creating a Route53 zone and delegation set and a record for www pointing to localhost.
module "route53" {
source = "mineiros-io/route53/aws"
version = "~> 0.6.0"
name = "mineiros.io"
records = [ { name = "www" type = "A" records = ["127.0.0.1"] }, ] }
Examples
We offer a broad set of examples that can be used to quickly start using this module.
- Basic routing
- Private hosted zone
- Multiple domains with different records
- Multiple domains that share the same record set
- Delegation set
- Failover routing
- Weighted routing
Module Argument Reference
See [variables.tf] and [examples/] for details and use-cases.
Top-level Arguments
Module Configuration
moduleenabled: (Optionalbool)
Default is true.
moduledependson: (Optionallist(dependency))
Default is [].
Route53 Zone
name: (Requiredstring)
["zone1", "zone2"]. Forces new resource.
Example:
Single: name = "example.com"
Multiple: name = ["example.com", "example.io"]
records: (Optionallist(record))
Default is [].
Each record object in the list accepts the following attributes:
- name: (Required string)
The name of the record.
- type: (Required string)
The record type. Valid values are A, AAAA, CAA, CNAME, MX, NAPTR, NS, PTR, SOA, SPF, SRV and TXT.
- ttl: (Optional number)
The TTL of the record.
Default is 3600.
- alias: (Optional object(alias))
An alias block. Expects name, zoneid and evaluatetarget_health to be defined. Conflicts with ttl & records.
The alias object accepts the following attributes:
- name: (Required string)
DNS domain name for a CloudFront distribution, S3 bucket, ELB, or another resource record set in this hosted zone.
- zoneid: (Required string)
Hosted zone ID for a CloudFront distribution, S3 bucket, ELB, or Route 53 hosted zone.
- evaluatetargethealth: (Optional bool)
Set to true if you want Route 53 to determine whether to respond to DNS queries using this resource record set by checking the health of the resource record set.
- allowoverwrite: (Optional bool)
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. This configuration is not recommended for most environments.
Default is false.
- healthcheckid: (Optional string)
The health check the record should be associated with.
- setidentifier: (Optional string)
Unique identifier to differentiate records with routing policies from one another. Required if using failover, geolocation, latency, or weighted routing policies documented below.
- weight: (Optional number)
A numeric value indicating the relative weight of the record. Will turn the record into a weighted record. For details see http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-policy.html#routing-policy-weighted
- failover: (Optional number)
The failover type of the record. Will turn the record into a failover record. Possible values are PRIMARY and SECONDARY. A PRIMARY record will be served if its healthcheck is passing, otherwise the SECONDARY will be served. For details see http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/dns-failover-configuring-options.html#dns-failover-failover-rrsets
tags: (Optionalmap(string))
Default is {}.
allowoverwrite: (Optionalbool)
Default is false.
defaultttl: (Optionalnumber)
Default is 3600.
vpcids: (Optionallist(string))
Default is [].
delegationsetid: (Optionalstring)
zoneid: (Optionalstring)
comment: (Optionalstring)
Default is "Managed by Terraform".
forcedestroy: (Optionalbool)
Default is false.
Route53 Delegation Set
referencename: (Optionalstring)
skipdelegationsetcreation: (Optionalbool)
Default is false.
Module Outputs
The following attributes are exported by the module:
zone: (list(zone))
awsroute53zone objects.
records: (list(record))
awsroute53record objects.
delegationset: (object(delegationset))
awsroute53delegation_set object.
moduleenabled: (bool)
External Documentation
AWS Documentation Route53
- Zones: https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/hosted-zones-working-with.html
- Records: https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/rrsets-working-with.html
Terraform AWS Provider Documentation
- https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_zone
- https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record
- https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53delegationset
- https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53zoneassociation
- https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53healthcheck
Module Versioning
This Module follows the principles of [Semantic Versioning (SemVer)].
Given a version number MAJOR.MINOR.PATCH, we increment the:
MAJORversion when we make incompatible changes,MINORversion when we add functionality in a backwards compatible manner, andPATCHversion when we make backwards compatible bug fixes.
Backwards compatibility in 0.0.z and 0.y.z version
- Backwards compatibility in versions
0.0.zis not guaranteed whenzis increased. (Initial development) - Backwards compatibility in versions
0.y.zis not guaranteed whenyis increased. (Pre-release)
About Mineiros
Mineiros is a [DevOps as a Service][homepage] company based in Berlin, Germany. We offer commercial support for all of our projects and encourage you to reach out if you have any questions or need help. Feel free to send us an email at [hello@mineiros.io] or join our [Community Slack channel][slack].
We can also help you with:
- Terraform modules for all types of infrastructure such as VPCs, Docker clusters, databases, logging and monitoring, CI, etc.
- Consulting & training on AWS, Terraform and DevOps
Reporting Issues
We use GitHub [Issues] to track community reported issues and missing features.
Contributing
Contributions are always encouraged and welcome! For the process of accepting changes, we use [Pull Requests]. If you'd like more information, please see our [Contribution Guidelines].
Makefile Targets
This repository comes with a handy [Makefile]. Run make help to see details on each available target.
License
[![license][badge-license]][apache20]
This module is licensed under the Apache License Version 2.0, January 2004. Please see [LICENSE] for full details.
Copyright © 2020-2022 [Mineiros GmbH][homepage]
[homepage]: https://mineiros.io/?ref=terraform-aws-route53 [hello@mineiros.io]: mailto:hello@mineiros.io [badge-build]: https://github.com/mineiros-io/terraform-aws-route53/actions/workflows/main.yml/badge.svg [badge-semver]: https://img.shields.io/github/v/tag/mineiros-io/terraform-aws-route53.svg?label=latest&sort=semver [badge-license]: https://img.shields.io/badge/license-Apache%202.0-brightgreen.svg [badge-terraform]: https://img.shields.io/badge/terraform-1.x%20|%200.15%200.14%20|%200.13%20|%200.12.20+-623CE4.svg?logo=terraform [badge-slack]: https://img.shields.io/badge/slack-@mineiros--community-f32752.svg?logo=slack [badge-tf-aws]: https://img.shields.io/badge/AWS-3%20and%202.45+-F8991D.svg?logo=terraform [releases-aws-provider]: https://github.com/terraform-providers/terraform-provider-aws/releases [build-status]: https://github.com/mineiros-io/terraform-aws-route53/actions [releases-github]: https://github.com/mineiros-io/terraform-aws-route53/releases [releases-terraform]: https://github.com/hashicorp/terraform/releases [apache20]: https://opensource.org/licenses/Apache-2.0 [slack]: https://join.slack.com/t/mineiros-community/shared_invite/zt-ehidestg-aLGoIENLVs6tvwJ11w9WGg [Terraform]: https://www.terraform.io [AWS]: https://aws.amazon.com/ [Semantic Versioning (SemVer)]: https://semver.org/ [alias]: https://aws.amazon.com/premiumsupport/knowledge-center/route-53-create-alias-records/ [weighted]: https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-policy.html#routing-policy-weighted [failover]: https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/dns-failover-configuring.html [examples/example/main.tf]: https://github.com/mineiros-io/terraform-aws-route53/blob/master/examples/example/main.tf [variables.tf]: https://github.com/mineiros-io/terraform-aws-route53/blob/master/variables.tf [examples/]: https://github.com/mineiros-io/terraform-aws-route53/tree/master/examples [same-records-example]: https://github.com/mineiros-io/terraform-aws-route53/tree/master/examples/multiple-domains-same-records [Issues]: https://github.com/mineiros-io/terraform-aws-route53/issues [LICENSE]: https://github.com/mineiros-io/terraform-aws-route53/blob/master/LICENSE [Makefile]: https://github.com/mineiros-io/terraform-aws-route53/blob/master/Makefile [Pull Requests]: https://github.com/mineiros-io/terraform-aws-route53/pulls [Contribution Guidelines]: https://github.com/mineiros-io/terraform-aws-route53/blob/master/CONTRIBUTING.md