Skip to content
Draft
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
18 changes: 18 additions & 0 deletions internal/services/network/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2025-01-01/networksecurityperimeterassociations"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2025-01-01/networksecurityperimeterprofiles"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2025-01-01/networksecurityperimeters"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2025-05-01/privatednszonegroups"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2025-05-01/privateendpoints"
"github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager"
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
)
Expand All @@ -24,6 +26,8 @@ type Client struct {
BastionHostsClient *bastionhosts.BastionHostsClient
// VMSS Data Source requires the Network Interfaces and VMSSPublicIpAddresses client from `2023-09-01` for the `ListVirtualMachineScaleSetVMNetworkInterfacesComplete` method
NetworkInterfacesClient *networkinterfaces.NetworkInterfacesClient
PrivateDnsZoneGroups *privatednszonegroups.PrivateDnsZoneGroupsClient
PrivateEndpoints *privateendpoints.PrivateEndpointsClient
NetworkSecurityPerimeterAccessRulesClient *networksecurityperimeteraccessrules.NetworkSecurityPerimeterAccessRulesClient
NetworkSecurityPerimeterAssociationsClient *networksecurityperimeterassociations.NetworkSecurityPerimeterAssociationsClient
NetworkSecurityPerimeterProfilesClient *networksecurityperimeterprofiles.NetworkSecurityPerimeterProfilesClient
Expand Down Expand Up @@ -74,6 +78,18 @@ func NewClient(o *common.ClientOptions) (*Client, error) {
}
o.Configure(VMSSPublicIPAddressesClient.Client, o.Authorizers.ResourceManager)

PrivateDnsZoneGroupsClient, err := privatednszonegroups.NewPrivateDnsZoneGroupsClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building Private DNS Zone Groups Client: %+v", err)
}
o.Configure(PrivateDnsZoneGroupsClient.Client, o.Authorizers.ResourceManager)

PrivateEndpointsClient, err := privateendpoints.NewPrivateEndpointsClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building Private Endpoints Client: %+v", err)
}
o.Configure(PrivateEndpointsClient.Client, o.Authorizers.ResourceManager)

client, err := network_2025_01_01.NewClientWithBaseURI(o.Environment.ResourceManager, func(c *resourcemanager.Client) {
o.Configure(c, o.Authorizers.ResourceManager)
})
Expand All @@ -84,6 +100,8 @@ func NewClient(o *common.ClientOptions) (*Client, error) {
return &Client{
BastionHostsClient: BastionHostsClient,
NetworkInterfacesClient: NetworkInterfacesClient,
PrivateDnsZoneGroups: PrivateDnsZoneGroupsClient,
PrivateEndpoints: PrivateEndpointsClient,
NetworkSecurityPerimeterAccessRulesClient: NetworkSecurityPerimeterAccessRulesClient,
NetworkSecurityPerimeterAssociationsClient: NetworkSecurityPerimeterAssociationsClient,
NetworkSecurityPerimeterProfilesClient: NetworkSecurityPerimeterProfilesClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2025-01-01/applicationsecuritygroups"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2025-01-01/privateendpoints"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2025-05-01/privateendpoints"
)

var _ resourceids.Id = PrivateEndpointApplicationSecurityGroupAssociationId{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"testing"

"github.com/hashicorp/go-azure-sdk/resource-manager/network/2025-01-01/applicationsecuritygroups"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2025-01-01/privateendpoints"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2025-05-01/privateendpoints"
)

func TestPrivateEndpointApplicationSecurityGroupAssociationID(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2025-01-01/applicationsecuritygroups"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2025-01-01/privateendpoints"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2025-05-01/privateendpoints"
"github.com/hashicorp/terraform-provider-azurerm/internal/locks"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/network/parse"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-09-01/applicationsecuritygroups"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2025-01-01/privateendpoints"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2025-05-01/privateendpoints"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2025-01-01/networkinterfaces"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2025-01-01/privateendpoints"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2025-05-01/privateendpoints"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
Expand Down
20 changes: 18 additions & 2 deletions internal/services/network/private_endpoint_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"github.com/hashicorp/go-azure-helpers/resourcemanager/tags"
mariadbServers "github.com/hashicorp/go-azure-sdk/resource-manager/mariadb/2018-06-01/servers"
"github.com/hashicorp/go-azure-sdk/resource-manager/mysql/2017-12-01/servers"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2025-01-01/privatednszonegroups"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2025-01-01/privateendpoints"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2025-05-01/privatednszonegroups"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2025-05-01/privateendpoints"
postgresqlServers "github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2017-12-01/servers"
"github.com/hashicorp/go-azure-sdk/resource-manager/privatedns/2024-06-01/privatezones"
"github.com/hashicorp/go-azure-sdk/resource-manager/redis/2024-03-01/redis"
Expand Down Expand Up @@ -105,6 +105,14 @@ func resourcePrivateEndpoint() *pluginsdk.Resource {
ForceNew: true,
},

"ip_version_type": {
Type: pluginsdk.TypeString,
Optional: true,
ForceNew: true,
Default: string(privateendpoints.PrivateEndpointIPVersionTypeIPvFour),
ValidateFunc: validation.StringInSlice(privateendpoints.PossibleValuesForPrivateEndpointIPVersionType(), false),
},

"private_dns_zone_group": {
Type: pluginsdk.TypeList,
Optional: true,
Expand Down Expand Up @@ -347,6 +355,7 @@ func resourcePrivateEndpointCreate(d *pluginsdk.ResourceData, meta interface{})
Id: pointer.To(d.Get("subnet_id").(string)),
},
IPConfigurations: expandPrivateEndpointIPConfigurations(d.Get("ip_configuration").([]interface{})),
IPVersionType: pointer.ToEnum[privateendpoints.PrivateEndpointIPVersionType](d.Get("ip_version_type").(string)),
CustomNetworkInterfaceName: pointer.To(d.Get("custom_network_interface_name").(string)),
},
Tags: tags.Expand(d.Get("tags").(map[string]interface{})),
Expand Down Expand Up @@ -516,6 +525,7 @@ func resourcePrivateEndpointUpdate(d *pluginsdk.ResourceData, meta interface{})
ipConfigurations := d.Get("ip_configuration").([]interface{})
subnetId := d.Get("subnet_id").(string)
customNicName := d.Get("custom_network_interface_name").(string)
ipVersionType := d.Get("ip_version_type").(string)

// TODO: in future it'd be nice to support conditional updates here, but one problem at a time
parameters := privateendpoints.PrivateEndpoint{
Expand All @@ -528,6 +538,7 @@ func resourcePrivateEndpointUpdate(d *pluginsdk.ResourceData, meta interface{})
Id: pointer.To(subnetId),
},
IPConfigurations: expandPrivateEndpointIPConfigurations(ipConfigurations),
IPVersionType: pointer.ToEnum[privateendpoints.PrivateEndpointIPVersionType](ipVersionType),
CustomNetworkInterfaceName: pointer.To(customNicName),
},
Tags: tags.Expand(d.Get("tags").(map[string]interface{})),
Expand Down Expand Up @@ -703,6 +714,11 @@ func resourcePrivateEndpointFlatten(ctx context.Context, metaClient *clients.Cli
customNicName = *props.CustomNetworkInterfaceName
}
d.Set("custom_network_interface_name", customNicName)
ipVersionType := string(privateendpoints.PrivateEndpointIPVersionTypeIPvFour)
if props.IPVersionType != nil {
ipVersionType = string(*props.IPVersionType)
}
d.Set("ip_version_type", ipVersionType)

if fetchCompleteData {
privateDnsZoneIds, err := retrievePrivateDnsZoneGroupsForPrivateEndpoint(ctx, dnsClient, *id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonids"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2025-01-01/privateendpoints"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2025-05-01/privateendpoints"
"github.com/hashicorp/terraform-plugin-framework/list"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
Expand Down
105 changes: 104 additions & 1 deletion internal/services/network/private_endpoint_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"testing"

"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2025-01-01/privateendpoints"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2025-05-01/privateendpoints"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
Expand Down Expand Up @@ -1121,3 +1121,106 @@ resource "azurerm_private_endpoint" "test" {
}
`, r.template(data, r.serviceAutoApprove(data)), data.RandomInteger)
}

func TestAccPrivateEndpoint_ipVersionType(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_private_endpoint", "test")
r := PrivateEndpointResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.ipVersionType(data, "IPv4"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func TestAccPrivateEndpoint_ipVersionTypeIPv6(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_private_endpoint", "test")
r := PrivateEndpointResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.ipVersionType(data, "IPv6"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func TestAccPrivateEndpoint_ipVersionTypeDualStack(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_private_endpoint", "test")
r := PrivateEndpointResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.ipVersionType(data, "DualStack"),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func (PrivateEndpointResource) ipVersionTypeTemplate(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}

resource "azurerm_resource_group" "test" {
name = "acctestRG-privatelink-%d"
location = "%s"
}

resource "azurerm_storage_account" "test" {
name = "acctestsa%s"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
account_tier = "Standard"
account_replication_type = "LRS"
}

resource "azurerm_virtual_network" "test" {
name = "acctestvnet-%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
address_space = ["10.0.0.0/16", "ace:cab:deca::/48"]
}

resource "azurerm_subnet" "endpoint" {
name = "acctestsnetendpoint-%d"
resource_group_name = azurerm_resource_group.test.name
virtual_network_name = azurerm_virtual_network.test.name
address_prefixes = ["10.0.2.0/24", "ace:cab:deca:2::/64"]

private_endpoint_network_policies = "Disabled"
}
`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomInteger, data.RandomInteger)
}

func (r PrivateEndpointResource) ipVersionType(data acceptance.TestData, ipVersionType string) string {
return fmt.Sprintf(`
%s

resource "azurerm_private_endpoint" "test" {
name = "acctest-privatelink-%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
subnet_id = azurerm_subnet.endpoint.id
ip_version_type = "%s"

private_service_connection {
name = "acctest-privatelink-psc-%d"
is_manual_connection = false
private_connection_resource_id = azurerm_storage_account.test.id
subresource_names = ["blob"]
}
}
`, r.ipVersionTypeTemplate(data), data.RandomInteger, ipVersionType, data.RandomInteger)
}

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

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

Loading
Loading