Skip to content
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: 3 additions & 2 deletions internal/services/search/search_service_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,10 @@ func resourceSearchServiceUpdate(d *pluginsdk.ResourceData, meta interface{}) er
if d.HasChange("allowed_ips") {
ipRulesRaw := d.Get("allowed_ips").(*pluginsdk.Set).List()

model.Properties.NetworkRuleSet = &services.NetworkRuleSet{
IPRules: expandSearchServiceIPRules(ipRulesRaw),
if model.Properties.NetworkRuleSet == nil {
model.Properties.NetworkRuleSet = &services.NetworkRuleSet{}
}
model.Properties.NetworkRuleSet.IPRules = expandSearchServiceIPRules(ipRulesRaw)
}

if d.HasChange("network_rule_bypass_option") {
Expand Down
40 changes: 33 additions & 7 deletions internal/services/search/search_service_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,13 @@ func TestAccSearchService_ipRules(t *testing.T) {
),
},
data.ImportStep(),
{
Config: r.ipRulesUpdate(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
{
Config: r.basic(data, "standard"),
Check: acceptance.ComposeTestCheckFunc(
Expand Down Expand Up @@ -710,7 +717,6 @@ resource "azurerm_search_service" "test" {
}

func (r SearchServiceResource) ipRules(data acceptance.TestData) string {
template := r.template(data)
return fmt.Sprintf(`
provider "azurerm" {
features {}
Expand All @@ -719,13 +725,33 @@ provider "azurerm" {
%s

resource "azurerm_search_service" "test" {
name = "acctestsearchservice%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
sku = "standard"
allowed_ips = ["168.1.5.65", "1.2.3.0/24"]
name = "acctestsearchservice%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
sku = "standard"
allowed_ips = ["168.1.5.65", "1.2.3.0/24"]
network_rule_bypass_option = "AzureServices"
}
`, template, data.RandomInteger)
`, r.template(data), data.RandomInteger)
}

func (r SearchServiceResource) ipRulesUpdate(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}

%s

resource "azurerm_search_service" "test" {
name = "acctestsearchservice%d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
sku = "standard"
allowed_ips = ["168.1.5.65", "168.1.5.66", "1.2.3.0/24"]
network_rule_bypass_option = "AzureServices"
}
`, r.template(data), data.RandomInteger)
}

func (r SearchServiceResource) bypassServices(data acceptance.TestData) string {
Expand Down
Loading