Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added reverse lookup feature to module dns #1042 #1043

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions modules/dns/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Google Cloud DNS Module

This module allows simple management of Google Cloud DNS zones and records. It supports creating public, private, forwarding, peering and service directory based zones.
This module allows simple management of Google Cloud DNS zones and records. It supports creating public, private, forwarding, peering, service directory and reverse based zones.

For DNSSEC configuration, refer to the [`dns_managed_zone` documentation](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/dns_managed_zone#dnssec_config).

Expand Down Expand Up @@ -86,6 +86,21 @@ module "private-dns" {
}
# tftest modules=1 resources=4
```

### Reverse Lookup Zone

```hcl
module "private-dns" {
source = "./fabric/modules/dns"
project_id = "myproject"
type = "reverse"
name = "test-example"
domain = "${reverse-ip}.in-addr.arpa."
client_networks = [var.vpc.self_link]
}
# tftest modules=1 resources=1
```

<!-- BEGIN TFDOC -->

## Variables
Expand All @@ -103,7 +118,7 @@ module "private-dns" {
| [peer_network](variables.tf#L77) | Peering network self link, only valid for 'peering' zone types. | <code>string</code> | | <code>null</code> |
| [recordsets](variables.tf#L88) | Map of DNS recordsets in \"type name\" => {ttl, [records]} format. | <code title="map&#40;object&#40;&#123;&#10; ttl &#61; optional&#40;number, 300&#41;&#10; records &#61; optional&#40;list&#40;string&#41;&#41;&#10; geo_routing &#61; optional&#40;list&#40;object&#40;&#123;&#10; location &#61; string&#10; records &#61; list&#40;string&#41;&#10; &#125;&#41;&#41;&#41;&#10; wrr_routing &#61; optional&#40;list&#40;object&#40;&#123;&#10; weight &#61; number&#10; records &#61; list&#40;string&#41;&#10; &#125;&#41;&#41;&#41;&#10;&#125;&#41;&#41;">map&#40;object&#40;&#123;&#8230;&#125;&#41;&#41;</code> | | <code>&#123;&#125;</code> |
| [service_directory_namespace](variables.tf#L123) | Service directory namespace id (URL), only valid for 'service-directory' zone types. | <code>string</code> | | <code>null</code> |
| [type](variables.tf#L129) | Type of zone to create, valid values are 'public', 'private', 'forwarding', 'peering', 'service-directory'. | <code>string</code> | | <code>&#34;private&#34;</code> |
| [type](variables.tf#L129) | Type of zone to create, valid values are 'public', 'private', 'forwarding', 'peering', 'service-directory','reverse'. | <code>string</code> | | <code>&#34;private&#34;</code> |
| [zone_create](variables.tf#L139) | Create zone. When set to false, uses a data source to reference existing zone. | <code>bool</code> | | <code>true</code> |

## Outputs
Expand Down
15 changes: 8 additions & 7 deletions modules/dns/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,14 @@ locals {
}

resource "google_dns_managed_zone" "non-public" {
count = (var.zone_create && var.type != "public") ? 1 : 0
provider = google-beta
project = var.project_id
name = var.name
dns_name = var.domain
description = var.description
visibility = "private"
count = (var.zone_create && var.type != "public") ? 1 : 0
provider = google-beta
project = var.project_id
name = var.name
dns_name = var.domain
description = var.description
visibility = "private"
reverse_lookup = (var.type == "reverse")

dynamic "forwarding_config" {
for_each = (
Expand Down
6 changes: 3 additions & 3 deletions modules/dns/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ variable "service_directory_namespace" {
}

variable "type" {
description = "Type of zone to create, valid values are 'public', 'private', 'forwarding', 'peering', 'service-directory'."
description = "Type of zone to create, valid values are 'public', 'private', 'forwarding', 'peering', 'service-directory','reverse'."
type = string
default = "private"
validation {
condition = contains(["public", "private", "forwarding", "peering", "service-directory"], var.type)
error_message = "Zone must be one of 'public', 'private', 'forwarding', 'peering', 'service-directory'."
condition = contains(["public", "private", "forwarding", "peering", "service-directory", "reverse"], var.type)
error_message = "Zone must be one of 'public', 'private', 'forwarding', 'peering', 'service-directory','reverse'."
}
}

Expand Down