Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
20 changes: 20 additions & 0 deletions infrastructure/gcp/cloud-dns/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion infrastructure/gcp/cloud-dns/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ resource "example_resource" "this" {

| Name | Version |
|------|---------|
| <a name="provider_google"></a> [google](#provider\_google) | >= 5.0, < 7.0 |
| <a name="provider_google"></a> [google](#provider\_google) | 6.50.0 |

## Resources

Expand All @@ -61,6 +61,7 @@ resource "example_resource" "this" {

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_dnssec_enabled"></a> [dnssec\_enabled](#input\_dnssec\_enabled) | Enable DNSSEC for the zone. Only applies to public zones; signing is inert until the DS record is published at the domain registrar. | `bool` | `true` | no |
| <a name="input_domain_name"></a> [domain\_name](#input\_domain\_name) | The domain name for the DNS zone (without trailing dot, e.g. example.com) | `string` | n/a | yes |
| <a name="input_private_zone_networks"></a> [private\_zone\_networks](#input\_private\_zone\_networks) | VPC network self-links for private zones | `list(string)` | `[]` | no |
| <a name="input_project_id"></a> [project\_id](#input\_project\_id) | The GCP project ID | `string` | n/a | yes |
Expand Down
7 changes: 7 additions & 0 deletions infrastructure/gcp/cloud-dns/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ resource "google_dns_managed_zone" "zone" {
dns_name = "${var.domain_name}."
visibility = var.visibility

dynamic "dnssec_config" {
for_each = var.visibility == "public" && var.dnssec_enabled ? [1] : []
content {
state = "on"
}
}

dynamic "private_visibility_config" {
for_each = var.visibility == "private" ? [1] : []
content {
Expand Down
36 changes: 36 additions & 0 deletions infrastructure/gcp/cloud-dns/tests/cloud_dns.tftest.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,39 @@ run "labels_applied_from_tags" {
error_message = "Labels should be applied from tags variable"
}
}

run "dnssec_enabled_by_default_on_public_zone" {
command = plan

assert {
condition = google_dns_managed_zone.zone.dnssec_config[0].state == "on"
error_message = "DNSSEC should be on by default for public zones"
}
}

run "dnssec_can_be_disabled" {
command = plan

variables {
dnssec_enabled = false
}

assert {
condition = length(google_dns_managed_zone.zone.dnssec_config) == 0
error_message = "DNSSEC should not be configured when dnssec_enabled is false"
}
}

run "dnssec_ignored_on_private_zone" {
command = plan

variables {
visibility = "private"
dnssec_enabled = true
}

assert {
condition = length(google_dns_managed_zone.zone.dnssec_config) == 0
error_message = "DNSSEC should not be configured on private zones even when dnssec_enabled is true"
}
}
6 changes: 6 additions & 0 deletions infrastructure/gcp/cloud-dns/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ variable "private_zone_networks" {
default = []
}

variable "dnssec_enabled" {
type = bool
description = "Enable DNSSEC for the zone. Only applies to public zones; signing is inert until the DS record is published at the domain registrar."
default = true
}

variable "tags" {
type = map(string)
description = "A mapping of labels to assign to the DNS managed zone"
Expand Down