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

azurerm_private_dns_zone_virtual_network_link - Add support for Resolution Policy #28615

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"time"

"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/tags"
Expand Down Expand Up @@ -48,6 +49,11 @@ func dataSourcePrivateDnsZoneVirtualNetworkLink() *pluginsdk.Resource {
Computed: true,
},

"resolution_policy": {
Type: pluginsdk.TypeString,
Computed: true,
},

"tags": commonschema.TagsDataSource(),
},
}
Expand Down Expand Up @@ -79,6 +85,7 @@ func dataSourcePrivateDnsZoneVirtualNetworkLinkRead(d *pluginsdk.ResourceData, m
if props := model.Properties; props != nil {
d.Set("registration_enabled", props.RegistrationEnabled)

d.Set("resolution_policy", pointer.From(props.ResolutionPolicy))
if network := props.VirtualNetwork; network != nil {
d.Set("virtual_network_id", network.Id)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"log"
"time"

"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonids"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
Expand Down Expand Up @@ -75,6 +76,13 @@ func resourcePrivateDnsZoneVirtualNetworkLink() *pluginsdk.Resource {
Default: false,
},

"resolution_policy": {
Type: pluginsdk.TypeString,
Optional: true,
Default: string(virtualnetworklinks.ResolutionPolicyDefault),
ValidateFunc: validation.StringInSlice(virtualnetworklinks.PossibleValuesForResolutionPolicy(), false),
},

"tags": commonschema.Tags(),
},
}
Expand Down Expand Up @@ -108,6 +116,7 @@ func resourcePrivateDnsZoneVirtualNetworkLinkCreateUpdate(d *pluginsdk.ResourceD
Id: utils.String(d.Get("virtual_network_id").(string)),
},
RegistrationEnabled: utils.Bool(d.Get("registration_enabled").(bool)),
ResolutionPolicy: pointer.To(virtualnetworklinks.ResolutionPolicy(d.Get("resolution_policy").(string))),
},
}

Expand Down Expand Up @@ -151,6 +160,7 @@ func resourcePrivateDnsZoneVirtualNetworkLinkRead(d *pluginsdk.ResourceData, met
if props := model.Properties; props != nil {
d.Set("registration_enabled", props.RegistrationEnabled)

d.Set("resolution_policy", pointer.From(props.ResolutionPolicy))
if network := props.VirtualNetwork; network != nil {
d.Set("virtual_network_id", network.Id)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ resource "azurerm_private_dns_zone_virtual_network_link" "test" {
virtual_network_id = azurerm_virtual_network.test.id
resource_group_name = azurerm_resource_group.test.name
registration_enabled = true
resolution_policy = "NxDomainRedirect"
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ output "private_dns_a_record_id" {

* `registration_enabled` - Whether the auto-registration of virtual machine records in the virtual network in the Private DNS zone is enabled or not.

* `resolution_policy` - Specifies the policy for handling DNS resolution. If set to `NxDomainRedirect`, the DNS resolution will fall back to internet recursion when an authoritative NXDOMAIN response is received for a Private Link zone.

* `tags` - A mapping of tags to assign to the resource.

## Timeouts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ The following arguments are supported:

* `registration_enabled` - (Optional) Is auto-registration of virtual machine records in the virtual network in the Private DNS zone enabled? Defaults to `false`.

* `resolution_policy` - (Optional) Specifies the policy for handling DNS resolution. If set to `NxDomainRedirect`, the DNS resolution will fall back to internet recursion when an authoritative NXDOMAIN response is received for a Private Link zone. Defaults to `Default` (no recursion).

* `tags` - (Optional) A mapping of tags to assign to the resource.

## Attributes Reference
Expand Down
Loading