diff --git a/azurerm/internal/services/network/local_network_gateway_resource.go b/azurerm/internal/services/network/local_network_gateway_resource.go index 5a9e3bd0446d..a538bc1d6f39 100644 --- a/azurerm/internal/services/network/local_network_gateway_resource.go +++ b/azurerm/internal/services/network/local_network_gateway_resource.go @@ -57,7 +57,7 @@ func resourceLocalNetworkGateway() *schema.Resource { "address_space": { Type: schema.TypeList, - Required: true, + Optional: true, Elem: &schema.Schema{ Type: schema.TypeString, }, diff --git a/azurerm/internal/services/network/local_network_gateway_resource_test.go b/azurerm/internal/services/network/local_network_gateway_resource_test.go index 0aa2faa8a593..7a0f0c905d7f 100644 --- a/azurerm/internal/services/network/local_network_gateway_resource_test.go +++ b/azurerm/internal/services/network/local_network_gateway_resource_test.go @@ -181,6 +181,13 @@ func TestAccLocalNetworkGateway_updateAddressSpace(t *testing.T) { r := LocalNetworkGatewayResource{} data.ResourceTest(t, r, []resource.TestStep{ + { + Config: r.noneAddressSpace(data), + Check: resource.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), { Config: r.multipleAddressSpace(data), Check: resource.ComposeTestCheckFunc( @@ -369,6 +376,26 @@ resource "azurerm_local_network_gateway" "test" { `, data.RandomInteger, data.Locations.Primary, data.RandomInteger) } +func (LocalNetworkGatewayResource) noneAddressSpace(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctest-%d" + location = "%s" +} + +resource "azurerm_local_network_gateway" "test" { + name = "acctestlng-%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + gateway_address = "127.0.0.1" +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger) +} + func (LocalNetworkGatewayResource) multipleAddressSpace(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { diff --git a/website/docs/r/local_network_gateway.html.markdown b/website/docs/r/local_network_gateway.html.markdown index c3a520821c05..0dc1f29b2207 100644 --- a/website/docs/r/local_network_gateway.html.markdown +++ b/website/docs/r/local_network_gateway.html.markdown @@ -40,7 +40,7 @@ The following arguments are supported: * `location` - (Required) The location/region where the local network gateway is created. Changing this forces a new resource to be created. -* `address_space` - (Required) The list of string CIDRs representing the +* `address_space` - (Optional) The list of string CIDRs representing the address spaces the gateway exposes. * `bgp_settings` - (Optional) A `bgp_settings` block as defined below containing the