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_subnet: Remove ForceNew from default_outbound_access_enabled property. #27858

Merged
merged 1 commit into from
Nov 4, 2024
Merged
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
5 changes: 4 additions & 1 deletion internal/services/network/subnet_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ func resourceSubnet() *pluginsdk.Resource {
Type: pluginsdk.TypeBool,
Default: true,
Optional: true,
ForceNew: true,
},

"private_endpoint_network_policies": {
Expand Down Expand Up @@ -514,6 +513,10 @@ func resourceSubnetUpdate(d *pluginsdk.ResourceData, meta interface{}) error {
}
}

if d.HasChange("default_outbound_access_enabled") {
props.DefaultOutboundAccess = pointer.To(d.Get("default_outbound_access_enabled").(bool))
}

if d.HasChange("delegation") {
delegationsRaw := d.Get("delegation").([]interface{})
props.Delegations = expandSubnetDelegation(delegationsRaw)
Expand Down
34 changes: 16 additions & 18 deletions internal/services/network/subnet_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,25 @@ func TestAccSubnet_disappears(t *testing.T) {
}

func TestAccSubnet_defaultOutbound(t *testing.T) {
dataInternal := acceptance.BuildTestData(t, "azurerm_subnet", "internal")
dataPublic := acceptance.BuildTestData(t, "azurerm_subnet", "public")
data := acceptance.BuildTestData(t, "azurerm_subnet", "internal")
r := SubnetResource{}

dataInternal.ResourceTest(t, r, []acceptance.TestStep{
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.defaultOutbound(data, true),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("default_outbound_access_enabled").HasValue("true"),
),
},
data.ImportStep(),
{
Config: r.defaultOutbound(dataInternal),
Config: r.defaultOutbound(data, false),
Check: acceptance.ComposeTestCheckFunc(
check.That(dataInternal.ResourceName).ExistsInAzure(r),
check.That(dataInternal.ResourceName).Key("default_outbound_access_enabled").HasValue("false"),
check.That(dataPublic.ResourceName).ExistsInAzure(r),
check.That(dataPublic.ResourceName).Key("default_outbound_access_enabled").HasValue("true"),
check.That(data.ResourceName).Key("default_outbound_access_enabled").HasValue("false"),
),
},
data.ImportStep(),
})
}

Expand Down Expand Up @@ -839,24 +844,17 @@ resource "azurerm_subnet" "test" {
`, r.template(data))
}

func (r SubnetResource) defaultOutbound(data acceptance.TestData) string {
func (r SubnetResource) defaultOutbound(data acceptance.TestData, enabled bool) string {
return fmt.Sprintf(`
%s
resource "azurerm_subnet" "internal" {
name = "internal"
resource_group_name = azurerm_resource_group.test.name
virtual_network_name = azurerm_virtual_network.test.name
address_prefixes = ["10.0.2.0/24"]
default_outbound_access_enabled = false
}
resource "azurerm_subnet" "public" {
name = "public"
resource_group_name = azurerm_resource_group.test.name
virtual_network_name = azurerm_virtual_network.test.name
address_prefixes = ["10.0.3.0/24"]
default_outbound_access_enabled = true
default_outbound_access_enabled = %t
}
`, r.template(data))
`, r.template(data), enabled)
}

func (r SubnetResource) delegationUpdated(data acceptance.TestData) string {
Expand Down
Loading