Skip to content

Terraform module to create Route53 resource on AWS for zone and record set.

License

Notifications You must be signed in to change notification settings

orangesys/terraform-aws-route53

 
 

Repository files navigation

Terraform AWS Route53

Terraform module to create Route53 resource on AWS for zone and record set.

Terraform Licence


We eat, drink, sleep and most importantly love DevOps. We are working towards strategies for standardizing architecture while ensuring security for the infrastructure. We are strong believer of the philosophy Bigger problems are always solved by breaking them into smaller manageable problems. Resonating with microservices architecture, it is considered best-practice to run database, cluster, storage in smaller connected yet manageable pieces within the infrastructure.

This module is basically combination of Terraform open source and includes automatation tests and examples. It also helps to create and improve your infrastructure with minimalistic code instead of maintaining the whole infrastructure code yourself.

We have fifty plus terraform modules. A few of them are comepleted and are available for open source usage while a few others are in progress.

Prerequisites

This module has a few dependencies:

Examples

IMPORTANT: Since the master branch used in source varies based on new modifications, we suggest that you use the release versions here.

Here are some examples of how you can use this module in your inventory structure:

Public Hostedzone

  module "route53" {
    source        = "clouddrove/route53/aws"
    version       = "0.13.0"
    name           = "route53"
    application    = "clouddrove"
    environment    = "test"
    label_order    = ["environment", "name", "application"]
    public_enabled = true
    record_enabled = true
    domain_name    = "clouddrove.com"
    names          = [
                      "www.",
                      "admin."
                    ]
    types          = [
                      "A",
                      "CNAME"
                    ]
    alias          = {
                      names = [
                        "d130easdflja734js.cloudfront.net"
                      ]
                      zone_ids = [
                        "Z2FDRFHATA1ER4"
                      ]
                      evaluate_target_healths = [
                        false
                      ]
                    }
  }

Private Hostedzone

  module "route53" {
    source        = "clouddrove/route53/aws"
    version       = "0.13.0"
    name            = "route53"
    application     = "clouddrove"
    environment     = "test"
    label_order     = ["environment", "name", "application"]
    private_enabled = true
    record_enabled  = true
    domain_name     = "clouddrove.com"
    vpc_id          = "vpc-xxxxxxxxxxxxx"
    names           = [
                      "www.",
                      "admin."
                     ]
    types           = [
                      "A",
                      "CNAME"
                     ]
    ttls            = [
                      "3600",
                      "3600",
                     ]
    values          = [
                      "10.0.0.27",
                      "mydomain.com",
                     ]
  }

Vpc Association

  module "route53" {
    source        = "clouddrove/route53/aws"
    version       = "0.13.0"
    name                 = "route53"
    application          = "clouddrove"
    environment          = "test"
    label_order          = ["environment", "name", "application"]
    private_enabled      = true
    enabled              = true
    domain_name          = "clouddrove.com"
    vpc_id               = "vpc-xxxxxxxxxxxxx"
    secondary_vpc_id     = "vpc-xxxxxxxxxxxxx"
    secondary_vpc_region = "eu-west-1"
  }

Inputs

Name Description Type Default Required
alias An alias block. Conflicts with ttl & records. Alias record documented below. map
{
"evaluate_target_healths": [],
"names": [],
"zone_ids": []
}
no
allow_overwrites 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. list [] no
application Application (e.g. cd or clouddrove). string "" no
attributes Additional attributes (e.g. 1). list [] no
comment A comment for the hosted zone. Defaults to 'Managed by Terraform'. string "" no
delegation_set_id The ID of the reusable delegation set whose NS records you want to assign to the hosted zone. Conflicts with vpc as delegation sets can only be used for public zones. string "" no
delimiter Delimiter to be used between organization, environment, name and attributes. string "-" no
domain_name This is the name of the resource. string n/a yes
enabled Whether to create Route53 vpc association. bool false no
environment Environment (e.g. prod, dev, staging). string "" no
failover_enabled Whether to create Route53 record set. bool false no
failover_routing_policies A block indicating the routing behavior when associated health check fails. Conflicts with any other routing policy. Documented below. any null no
force_destroy Whether to destroy all records (possibly managed outside of Terraform) in the zone when destroying the zone. bool true no
geolocation_enabled Whether to create Route53 record set. bool false no
geolocation_routing_policies A block indicating a routing policy based on the geolocation of the requestor. Conflicts with any other routing policy. Documented below. any null no
health_check_ids The health check the record should be associated with. list [] no
label_order Label order, e.g. name,application. list [] no
latency_enabled Whether to create Route53 record set. bool false no
latency_routing_policies A block indicating a routing policy based on the latency between the requestor and an AWS region. Conflicts with any other routing policy. Documented below. any null no
managedby ManagedBy, eg 'CloudDrove' or 'AnmolNagpal'. string "[email protected]" no
multivalue_answer_routing_policies Set to true to indicate a multivalue answer routing policy. Conflicts with any other routing policy. list [] no
name Name (e.g. app or cluster). string "" no
names The name of the record. list [] no
private_enabled Whether to create private Route53 zone. bool false no
public_enabled Whether to create public Route53 zone. bool false no
record_enabled Whether to create Route53 record set. bool false no
record_set_enabled Whether to create seperate Route53 record set. bool false no
secondary_vpc_id The VPC to associate with the private hosted zone. string "" no
secondary_vpc_region The VPC's region. Defaults to the region of the AWS provider. string "" no
set_identifiers Unique identifier to differentiate records with routing policies from one another. Required if using failover, geolocation, latency, or weighted routing policies documented below. list [] no
tags Additional tags (e.g. map(BusinessUnit,XYZ). map {} no
ttls (Required for non-alias records) The TTL of the record. list [] no
types The record type. Valid values are A, AAAA, CAA, CNAME, MX, NAPTR, NS, PTR, SOA, SPF, SRV and TXT. list [] no
values (Required for non-alias records) A string list of records. To specify a single record value longer than 255 characters such as a TXT record for DKIM, add "" inside the Terraform configuration string (e.g. "first255characters""morecharacters"). list [] no
vpc_id VPC ID. string "" no
weighted_enabled Whether to create Route53 record set. bool false no
weighted_routing_policies A block indicating a weighted routing policy. Conflicts with any other routing policy. Documented below. any null no
zone_id Zone ID. string "" no

Outputs

Name Description
tags A mapping of tags to assign to the resource.
zone_id The Hosted Zone ID. This can be referenced by zone records.

Testing

In this module testing is performed with terratest and it creates a small piece of infrastructure, matches the output like ARN, ID and Tags name etc and destroy infrastructure in your AWS account. This testing is written in GO, so you need a GO environment in your system.

You need to run the following command in the testing folder:

  go test -run Test

Feedback

If you come accross a bug or have any feedback, please log it in our issue tracker, or feel free to drop us an email at [email protected].

If you have found it worth your time, go ahead and give us a ★ on our GitHub!

About us

At CloudDrove, we offer expert guidance, implementation support and services to help organisations accelerate their journey to the cloud. Our services include docker and container orchestration, cloud migration and adoption, infrastructure automation, application modernisation and remediation, and performance engineering.

We are The Cloud Experts!


We ❤️ Open Source and you can check out our other modules to get help with your new Cloud ideas.

About

Terraform module to create Route53 resource on AWS for zone and record set.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • HCL 79.8%
  • Go 19.7%
  • Makefile 0.5%