Skip to content

Commit

Permalink
Merge pull request #4 from schubergphilis/bug/variablefixes
Browse files Browse the repository at this point in the history
fix loop in forwarding rules. Add variable for ruleset name
  • Loading branch information
gillianstravers authored Nov 29, 2024
2 parents 7420c9c + ff211e6 commit feb9650
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ No modules.
|------|-------------|------|---------|:--------:|
| <a name="input_private_dns_resolver"></a> [private\_dns\_resolver](#input\_private\_dns\_resolver) | Private DNS resolver configuration | <pre>object({<br> name = string<br> virtual_network_id = string<br> virtual_network_name = string<br> })</pre> | n/a | yes |
| <a name="input_private_dns_resolver_forwarding_rule"></a> [private\_dns\_resolver\_forwarding\_rule](#input\_private\_dns\_resolver\_forwarding\_rule) | Private DNS resolver forwarding rule configuration | <pre>map(object({<br> name = string<br> domain_name = string<br> enabled = optional(bool, true)<br> target_dns_servers = list(object({<br> ip_address = string<br> port = optional(number, 53)<br> }))<br> }))</pre> | n/a | yes |
| <a name="input_private_dns_resolver_forwarding_ruleset"></a> [private\_dns\_resolver\_forwarding\_ruleset](#input\_private\_dns\_resolver\_forwarding\_ruleset) | Private DNS resolver forwarding ruleset configuration | <pre>object({<br> name = string<br> })</pre> | n/a | yes |
| <a name="input_private_dns_resolver_inbound_endpoint"></a> [private\_dns\_resolver\_inbound\_endpoint](#input\_private\_dns\_resolver\_inbound\_endpoint) | Private DNS resolver inbound endpoint configuration | <pre>object({<br> name = string<br> private_ip_allocation_method = optional(string, "static")<br> subnet_id = string<br> })</pre> | n/a | yes |
| <a name="input_private_dns_resolver_outbound_endpoint"></a> [private\_dns\_resolver\_outbound\_endpoint](#input\_private\_dns\_resolver\_outbound\_endpoint) | Private DNS resolver outbound endpoint configuration | <pre>object({<br> enabled = optional(bool, true)<br> name = string<br> subnet_id = string<br> })</pre> | n/a | yes |
| <a name="input_resource_group"></a> [resource\_group](#input\_resource\_group) | Resource group configuration | <pre>object({<br> name = string<br> location = string<br> })</pre> | n/a | yes |
Expand Down
4 changes: 4 additions & 0 deletions examples/basic/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ module "pdns_resolver" {
subnet_id = "subnet-id"
}

private_dns_resolver_forwarding_ruleset = {
name = "ruleset"
}

private_dns_resolver_forwarding_rule = {
rule1 = {
name = "rule1"
Expand Down
14 changes: 7 additions & 7 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ resource "azurerm_private_dns_resolver_outbound_endpoint" "this" {
resource "azurerm_private_dns_resolver_dns_forwarding_ruleset" "this" {
count = var.private_dns_resolver_outbound_endpoint.enabled ? 1 : 0

name = var.private_dns_resolver_forwarding_rule.each.name
name = var.private_dns_resolver_forwarding_ruleset.name
resource_group_name = azurerm_resource_group.this.name
location = azurerm_resource_group.this.location
private_dns_resolver_outbound_endpoint_ids = [azurerm_private_dns_resolver_outbound_endpoint.this[count.index].id]
Expand All @@ -74,15 +74,15 @@ resource "azurerm_private_dns_resolver_dns_forwarding_ruleset" "this" {
}

resource "azurerm_private_dns_resolver_forwarding_rule" "this" {
count = var.private_dns_resolver_outbound_endpoint.enabled ? 1 : 0
for_each = var.private_dns_resolver_forwarding_rule

name = var.private_dns_resolver_forwarding_rule.each.name
dns_forwarding_ruleset_id = azurerm_private_dns_resolver_outbound_endpoint.this[count.index].id
domain_name = var.private_dns_resolver_forwarding_rule.each.domain_name
enabled = var.private_dns_resolver_forwarding_rule.each.enabled
name = var.private_dns_resolver_forwarding_rule[each.key].name
dns_forwarding_ruleset_id = azurerm_private_dns_resolver_outbound_endpoint.this[0].id
domain_name = var.private_dns_resolver_forwarding_rule[each.key].domain_name
enabled = var.private_dns_resolver_forwarding_rule[each.key].enabled

dynamic "target_dns_servers" {
for_each = var.private_dns_resolver_forwarding_rule.each.target_dns_servers
for_each = var.private_dns_resolver_forwarding_rule[each.key].target_dns_servers
content {
ip_address = target_dns_servers.value.ip_address
port = target_dns_servers.value.port
Expand Down
8 changes: 8 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ variable "private_dns_resolver_outbound_endpoint" {
subnet_id = string
})
}

variable "private_dns_resolver_forwarding_ruleset" {
description = "Private DNS resolver forwarding ruleset configuration"
type = object({
name = string
})
}

variable "private_dns_resolver_forwarding_rule" {
description = "Private DNS resolver forwarding rule configuration"
type = map(object({
Expand Down

0 comments on commit feb9650

Please sign in to comment.