Skip to content

Commit

Permalink
Merge pull request #5801 from terraform-providers/f/subnet-deprecation
Browse files Browse the repository at this point in the history
r/subnet: switching over the `association` resources
  • Loading branch information
tombuildsstuff authored Feb 18, 2020
2 parents 044cbbc + b7327f0 commit 15f05be
Show file tree
Hide file tree
Showing 20 changed files with 635 additions and 1,180 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -595,11 +595,6 @@ resource "azurerm_subnet" "test" {
resource_group_name = azurerm_resource_group.test.name
virtual_network_name = azurerm_virtual_network.test.name
address_prefix = "10.1.0.0/24"
# TODO: remove in 2.0
lifecycle {
ignore_changes = ["route_table_id"]
}
}
resource "azurerm_kubernetes_cluster" "test" {
Expand Down Expand Up @@ -667,11 +662,6 @@ resource "azurerm_subnet" "test" {
resource_group_name = azurerm_resource_group.test.name
virtual_network_name = azurerm_virtual_network.test.name
address_prefix = "10.1.0.0/24"
# TODO: remove in 2.0
lifecycle {
ignore_changes = ["route_table_id"]
}
}
resource "azurerm_subnet_route_table_association" "test" {
Expand Down Expand Up @@ -802,7 +792,6 @@ resource "azurerm_subnet" "test" {
resource_group_name = azurerm_resource_group.test.name
virtual_network_name = azurerm_virtual_network.test.name
address_prefix = "10.1.0.0/24"
route_table_id = azurerm_route_table.test.id
}
resource "azurerm_subnet_route_table_association" "test" {
Expand Down Expand Up @@ -894,11 +883,6 @@ resource "azurerm_subnet" "test" {
resource_group_name = azurerm_resource_group.test.name
virtual_network_name = azurerm_virtual_network.test.name
address_prefix = "172.0.2.0/24"
# TODO: remove in 2.0
lifecycle {
ignore_changes = ["route_table_id"]
}
}
resource "azurerm_kubernetes_cluster" "test" {
Expand Down Expand Up @@ -1062,7 +1046,6 @@ resource "azurerm_subnet" "test" {
resource_group_name = azurerm_resource_group.test.name
virtual_network_name = azurerm_virtual_network.test.name
address_prefix = "10.1.0.0/24"
route_table_id = azurerm_route_table.test.id
}
resource "azurerm_subnet_route_table_association" "test" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1079,11 +1079,6 @@ resource "azurerm_subnet" "test" {
resource_group_name = azurerm_resource_group.test.name
virtual_network_name = azurerm_virtual_network.test.name
address_prefix = "10.1.0.0/24"
# TODO: remove in 2.0
lifecycle {
ignore_changes = ["route_table_id"]
}
}
resource "azurerm_subnet_route_table_association" "test" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,6 @@ resource "azurerm_subnet" "public" {
]
}
}
lifecycle {
ignore_changes = ["network_security_group_id"]
}
}
resource "azurerm_subnet" "private" {
Expand All @@ -333,10 +329,6 @@ resource "azurerm_subnet" "private" {
]
}
}
lifecycle {
ignore_changes = ["network_security_group_id"]
}
}
resource "azurerm_network_security_group" "nsg" {
Expand Down
39 changes: 11 additions & 28 deletions azurerm/internal/services/network/data_source_subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package network

import (
"fmt"
"strings"
"time"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
Expand Down Expand Up @@ -51,13 +50,6 @@ func dataSourceArmSubnet() *schema.Resource {
Computed: true,
},

"ip_configurations": {
Type: schema.TypeSet,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: schema.HashString,
},

"service_endpoints": {
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -104,32 +96,23 @@ func dataSourceArmSubnetRead(d *schema.ResourceData, meta interface{}) error {
if props := resp.SubnetPropertiesFormat; props != nil {
d.Set("address_prefix", props.AddressPrefix)

if pe := props.PrivateEndpointNetworkPolicies; pe != nil {
d.Set("enforce_private_link_endpoint_network_policies", strings.EqualFold("Disabled", *pe))
}

if ps := props.PrivateLinkServiceNetworkPolicies; ps != nil {
d.Set("enforce_private_link_service_network_policies", strings.EqualFold("Disabled", *ps))
}

if props.NetworkSecurityGroup != nil {
d.Set("network_security_group_id", props.NetworkSecurityGroup.ID)
} else {
d.Set("network_security_group_id", "")
}
d.Set("enforce_private_link_endpoint_network_policies", flattenSubnetPrivateLinkNetworkPolicy(props.PrivateEndpointNetworkPolicies))
d.Set("enforce_private_link_service_network_policies", flattenSubnetPrivateLinkNetworkPolicy(props.PrivateLinkServiceNetworkPolicies))

if props.RouteTable != nil {
d.Set("route_table_id", props.RouteTable.ID)
} else {
d.Set("route_table_id", "")
networkSecurityGroupId := ""
if props.NetworkSecurityGroup != nil && props.NetworkSecurityGroup.ID != nil {
networkSecurityGroupId = *props.NetworkSecurityGroup.ID
}
d.Set("network_security_group_id", networkSecurityGroupId)

if err := d.Set("ip_configurations", flattenSubnetIPConfigurations(props.IPConfigurations)); err != nil {
return err
routeTableId := ""
if props.RouteTable != nil && props.RouteTable.ID != nil {
routeTableId = *props.RouteTable.ID
}
d.Set("route_table_id", routeTableId)

if err := d.Set("service_endpoints", flattenSubnetServiceEndpoints(props.ServiceEndpoints)); err != nil {
return err
return fmt.Errorf("Error setting `service_endpoints`: %+v", err)
}
}

Expand Down
Loading

0 comments on commit 15f05be

Please sign in to comment.