diff --git a/nutanix/resource_nutanix_subnet.go b/nutanix/resource_nutanix_subnet.go index 4a0e78f69..4b97e91e7 100644 --- a/nutanix/resource_nutanix_subnet.go +++ b/nutanix/resource_nutanix_subnet.go @@ -717,10 +717,8 @@ func getSubnetResources(d *schema.ResourceData, subnet *v3.SubnetResources) { dhcpo.DomainSearchList = expandStringList(v.([]interface{})) } - if v, ok := d.GetOk("vlan_id"); ok { - if v.(int) == 0 || ok { - subnet.VlanID = utils.Int64Ptr(int64(v.(int))) - } + if v, ok := d.GetOkExists("vlan_id"); ok { + subnet.VlanID = utils.Int64Ptr(int64(v.(int))) } if v, ok := d.GetOk("network_function_chain_reference"); ok { diff --git a/nutanix/resource_nutanix_subnet_test.go b/nutanix/resource_nutanix_subnet_test.go index 2b1b6afd7..665585816 100644 --- a/nutanix/resource_nutanix_subnet_test.go +++ b/nutanix/resource_nutanix_subnet_test.go @@ -255,6 +255,24 @@ func TestAccNutanixSubnet_nameDuplicated(t *testing.T) { }) } +func TestAccNutanixSubnet_WithVlan0(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckNutanixSubnetDestroy, + Steps: []resource.TestStep{ + { + Config: testAccNutanixSubnetConfig(0), + Check: resource.ComposeTestCheckFunc( + testAccCheckNutanixSubnetExists(resourceNameSubnet), + resource.TestCheckResourceAttr(resourceNameSubnet, "name", "acctest-managed-0"), + resource.TestCheckResourceAttr(resourceNameSubnet, "description", "Description of my unit test VLAN"), + ), + }, + }, + }) +} + func testAccCheckNutanixSubnetExists(n string) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n]