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_virtual_network - support for private_endpoint_vnet_policies #27830

Merged
15 changes: 14 additions & 1 deletion internal/services/network/virtual_network_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,13 @@ func resourceVirtualNetworkSchema() map[string]*pluginsdk.Schema {
},
},

"private_endpoint_vnet_policies": {
Type: pluginsdk.TypeString,
Optional: true,
Default: string(virtualnetworks.PrivateEndpointVNetPoliciesDisabled),
ValidateFunc: validation.StringInSlice(virtualnetworks.PossibleValuesForPrivateEndpointVNetPolicies(), false),
},

"tags": commonschema.Tags(),
}
}
Expand Down Expand Up @@ -380,6 +387,7 @@ func resourceVirtualNetworkRead(d *pluginsdk.ResourceData, meta interface{}) err
if props := model.Properties; props != nil {
d.Set("guid", props.ResourceGuid)
d.Set("flow_timeout_in_minutes", props.FlowTimeoutInMinutes)
d.Set("private_endpoint_vnet_policies", string(pointer.From(props.PrivateEndpointVNetPolicies)))

if space := props.AddressSpace; space != nil {
if err = d.Set("address_space", space.AddressPrefixes); err != nil {
Expand Down Expand Up @@ -499,6 +507,10 @@ func resourceVirtualNetworkUpdate(d *pluginsdk.ResourceData, meta interface{}) e
defer locks.UnlockMultipleByName(routeTables, routeTableResourceName)
}

if d.HasChange("private_endpoint_vnet_policies") {
payload.Properties.PrivateEndpointVNetPolicies = pointer.To(virtualnetworks.PrivateEndpointVNetPolicies(d.Get("private_endpoint_vnet_policies").(string)))
}

if d.HasChange("tags") {
payload.Tags = tags.Expand(d.Get("tags").(map[string]interface{}))
}
Expand Down Expand Up @@ -768,7 +780,8 @@ func expandVirtualNetworkProperties(ctx context.Context, client virtualnetworks.
DhcpOptions: &virtualnetworks.DhcpOptions{
DnsServers: utils.ExpandStringSlice(d.Get("dns_servers").([]interface{})),
},
Subnets: &subnets,
PrivateEndpointVNetPolicies: pointer.To(virtualnetworks.PrivateEndpointVNetPolicies(d.Get("private_endpoint_vnet_policies").(string))),
Subnets: &subnets,
}

properties.AddressSpace.AddressPrefixes = utils.ExpandStringSlice(d.Get("address_space").(*pluginsdk.Set).List())
Expand Down
11 changes: 6 additions & 5 deletions internal/services/network/virtual_network_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,11 +435,12 @@ resource "azurerm_resource_group" "test" {
}

resource "azurerm_virtual_network" "test" {
name = "acctestvirtnet%d"
address_space = ["10.0.0.0/16", "10.10.0.0/16"]
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
dns_servers = ["10.7.7.2", "10.7.7.7", "10.7.7.1", ]
name = "acctestvirtnet%d"
address_space = ["10.0.0.0/16", "10.10.0.0/16"]
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
dns_servers = ["10.7.7.2", "10.7.7.7", "10.7.7.1", ]
private_endpoint_vnet_policies = "Basic"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been set in the configuration for 3.x. Can you please set this in the configuration that will run in 4.x and also clean up the complete config by removing the 3.x config that isn't valid anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated


encryption {
enforcement = "AllowUnencrypted"
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/virtual_network.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ The following arguments are supported:

-> **NOTE** Since `subnet` can be configured both inline and via the separate `azurerm_subnet` resource, we have to explicitly set it to empty slice (`[]`) to remove it.

* `private_endpoint_vnet_policies` - (Optional) The Private Endpoint VNet Policies for the Virtual Network. Possible values are `Disabled` and `Basic`. Defaults to `Disabled`.

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

---
Expand Down
Loading