Skip to content

Commit

Permalink
feat: Added support for delegation sets (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
flora-five authored Jan 6, 2022
1 parent 563c8b7 commit 43f587d
Show file tree
Hide file tree
Showing 10 changed files with 147 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ There are independent submodules:

- [zones](https://github.com/terraform-aws-modules/terraform-aws-route53/tree/master/modules/zones) - to manage Route53 zones
- [records](https://github.com/terraform-aws-modules/terraform-aws-route53/tree/master/modules/records) - to manage Route53 records
- [delegation-sets](https://github.com/terraform-aws-modules/terraform-aws-route53/tree/master/modules/delegation-sets) - to manage Route53 delegation sets

## Usage

Expand Down
3 changes: 3 additions & 0 deletions examples/complete/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Note that this example may create resources which cost money. Run `terraform des
| Name | Source | Version |
|------|--------|---------|
| <a name="module_cloudfront"></a> [cloudfront](#module\_cloudfront) | terraform-aws-modules/cloudfront/aws | n/a |
| <a name="module_delegation_sets"></a> [delegation\_sets](#module\_delegation\_sets) | ../../modules/delegation-sets | n/a |
| <a name="module_disabled_records"></a> [disabled\_records](#module\_disabled\_records) | ../../modules/records | n/a |
| <a name="module_records"></a> [records](#module\_records) | ../../modules/records | n/a |
| <a name="module_records_with_lists"></a> [records\_with\_lists](#module\_records\_with\_lists) | ../../modules/records | n/a |
Expand All @@ -59,6 +60,8 @@ No inputs.

| Name | Description |
|------|-------------|
| <a name="output_route53_delegation_set_id"></a> [route53\_delegation\_set\_id](#output\_route53\_delegation\_set\_id) | ID of Route53 delegation set |
| <a name="output_route53_delegation_set_name_servers"></a> [route53\_delegation\_set\_name\_servers](#output\_route53\_delegation\_set\_name\_servers) | Name servers in the Route53 delegation set |
| <a name="output_route53_record_fqdn"></a> [route53\_record\_fqdn](#output\_route53\_record\_fqdn) | FQDN built using the zone domain and name |
| <a name="output_route53_record_name"></a> [route53\_record\_name](#output\_route53\_record\_name) | The name of the record |
| <a name="output_route53_zone_name"></a> [route53\_zone\_name](#output\_route53\_zone\_name) | Name of Route53 zone |
Expand Down
11 changes: 10 additions & 1 deletion examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,21 @@ locals {
# zone_id = module.zones.route53_zone_zone_id["app.terraform-aws-modules-example.com"]
}

module "delegation_sets" {
source = "../../modules/delegation-sets"

delegation_sets = {
main = {}
}
}

module "zones" {
source = "../../modules/zones"

zones = {
"terraform-aws-modules-example.com" = {
comment = "terraform-aws-modules-example.com (production)"
comment = "terraform-aws-modules-example.com (production)"
delegation_set_id = module.delegation_sets.route53_delegation_set_id.main
tags = {
Name = "terraform-aws-modules-example.com"
}
Expand Down
11 changes: 11 additions & 0 deletions examples/complete/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# delegation sets
output "route53_delegation_set_id" {
description = "ID of Route53 delegation set"
value = module.delegation_sets.route53_delegation_set_id
}

output "route53_delegation_set_name_servers" {
description = "Name servers in the Route53 delegation set"
value = module.delegation_sets.route53_delegation_set_name_servers
}

# zones
output "route53_zone_zone_id" {
description = "Zone ID of Route53 zone"
Expand Down
83 changes: 83 additions & 0 deletions modules/delegation-sets/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Route53 Delegation Sets

This module creates Route53 delegation sets.

## Usage

### Create Route53 delegation sets and public zones using a delegation set

```hcl
module "delegation_sets" {
source = "terraform-aws-modules/route53/aws//modules/delegation-sets"
version = "~> 2.0"
delegation_sets = {
"myset" = {
reference_name = "myset"
}
}
}
module "zones" {
source = "terraform-aws-modules/route53/aws//modules/zones"
version = "~> 2.0"
zones = {
"myapp1.com" = {
comment = "myapp1.com"
delegation_set_id = module.delegation_sets.route53_delegation_set_id["myset"]
}
"myapp2.com" = {
comment = "myapp2.com"
delegation_set_id = module.delegation_sets.route53_delegation_set_id["myset"]
}
}
tags = {
ManagedBy = "Terraform"
}
depends_on = [module.delegation_sets]
}
```

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.56 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.56 |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [aws_route53_delegation_set.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_delegation_set) | resource |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_create"></a> [create](#input\_create) | Whether to create Route53 delegation sets | `bool` | `true` | no |
| <a name="input_delegation_sets"></a> [delegation\_sets](#input\_delegation\_sets) | Map of Route53 delegation set parameters | `any` | `{}` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_route53_delegation_set_id"></a> [route53\_delegation\_set\_id](#output\_route53\_delegation\_set\_id) | ID of Route53 delegation set |
| <a name="output_route53_delegation_set_name_servers"></a> [route53\_delegation\_set\_name\_servers](#output\_route53\_delegation\_set\_name\_servers) | Name servers in the Route53 delegation set |
| <a name="output_route53_delegation_set_reference_name"></a> [route53\_delegation\_set\_reference\_name](#output\_route53\_delegation\_set\_reference\_name) | Reference name used when the Route53 delegation set has been created |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
5 changes: 5 additions & 0 deletions modules/delegation-sets/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resource "aws_route53_delegation_set" "this" {
for_each = var.create ? var.delegation_sets : tomap({})

reference_name = lookup(each.value, "reference_name", null)
}
14 changes: 14 additions & 0 deletions modules/delegation-sets/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
output "route53_delegation_set_id" {
description = "ID of Route53 delegation set"
value = { for k, v in aws_route53_delegation_set.this : k => v.id }
}

output "route53_delegation_set_name_servers" {
description = "Name servers in the Route53 delegation set"
value = { for k, v in aws_route53_delegation_set.this : k => v.name_servers }
}

output "route53_delegation_set_reference_name" {
description = "Reference name used when the Route53 delegation set has been created"
value = { for k, v in aws_route53_delegation_set.this : k => v.reference_name }
}
11 changes: 11 additions & 0 deletions modules/delegation-sets/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
variable "create" {
description = "Whether to create Route53 delegation sets"
type = bool
default = true
}

variable "delegation_sets" {
description = "Map of Route53 delegation set parameters"
type = any
default = {}
}
7 changes: 7 additions & 0 deletions modules/delegation-sets/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
terraform {
required_version = ">= 0.13.1"

required_providers {
aws = ">= 3.56"
}
}
2 changes: 2 additions & 0 deletions modules/zones/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ resource "aws_route53_zone" "this" {
comment = lookup(each.value, "comment", null)
force_destroy = lookup(each.value, "force_destroy", false)

delegation_set_id = lookup(each.value, "delegation_set_id", null)

dynamic "vpc" {
for_each = try(tolist(lookup(each.value, "vpc", [])), [lookup(each.value, "vpc", {})])

Expand Down

0 comments on commit 43f587d

Please sign in to comment.