Skip to content

Commit a708633

Browse files
Fix issue#20603 (#13295) (#9506)
[upstream:184ff95c3ca98aa0cbae943cc9dadd4eb3b6b89e] Signed-off-by: Modular Magician <[email protected]>
1 parent a0a8702 commit a708633

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

.changelog/13295.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
discoveryengine: changed field `dataStoreIds` to mutable in `google_discovery_engine_search_engine`
3+
```

google-beta/services/discoveryengine/resource_discovery_engine_search_engine.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ func ResourceDiscoveryEngineSearchEngine() *schema.Resource {
6666
"data_store_ids": {
6767
Type: schema.TypeList,
6868
Required: true,
69-
ForceNew: true,
7069
Description: `The data stores associated with this engine. For SOLUTION_TYPE_SEARCH type of engines, they can only associate with at most one data store.`,
7170
Elem: &schema.Schema{
7271
Type: schema.TypeString,
@@ -375,6 +374,12 @@ func resourceDiscoveryEngineSearchEngineUpdate(d *schema.ResourceData, meta inte
375374
} else if v, ok := d.GetOkExists("display_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, displayNameProp)) {
376375
obj["displayName"] = displayNameProp
377376
}
377+
dataStoreIdsProp, err := expandDiscoveryEngineSearchEngineDataStoreIds(d.Get("data_store_ids"), d, config)
378+
if err != nil {
379+
return err
380+
} else if v, ok := d.GetOkExists("data_store_ids"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, dataStoreIdsProp)) {
381+
obj["dataStoreIds"] = dataStoreIdsProp
382+
}
378383
searchEngineConfigProp, err := expandDiscoveryEngineSearchEngineSearchEngineConfig(d.Get("search_engine_config"), d, config)
379384
if err != nil {
380385
return err
@@ -400,6 +405,10 @@ func resourceDiscoveryEngineSearchEngineUpdate(d *schema.ResourceData, meta inte
400405
updateMask = append(updateMask, "displayName")
401406
}
402407

408+
if d.HasChange("data_store_ids") {
409+
updateMask = append(updateMask, "dataStoreIds")
410+
}
411+
403412
if d.HasChange("search_engine_config") {
404413
updateMask = append(updateMask, "searchEngineConfig")
405414
}

google-beta/services/discoveryengine/resource_discovery_engine_search_engine_test.go

+21-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
package discoveryengine_test
44

55
import (
6+
"testing"
7+
68
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
79
"github.com/hashicorp/terraform-provider-google-beta/google-beta/acctest"
8-
"testing"
910
)
1011

1112
func TestAccDiscoveryEngineSearchEngine_discoveryengineSearchengineBasicExample_update(t *testing.T) {
@@ -55,12 +56,21 @@ resource "google_discovery_engine_data_store" "basic" {
5556
solution_types = ["SOLUTION_TYPE_SEARCH"]
5657
create_advanced_site_search = false
5758
}
59+
resource "google_discovery_engine_data_store" "second" {
60+
location = "global"
61+
data_store_id = "tf-test-example2-datastore%{random_suffix}"
62+
display_name = "tf-test-structured-datastore2"
63+
industry_vertical = "GENERIC"
64+
content_config = "NO_CONTENT"
65+
solution_types = ["SOLUTION_TYPE_SEARCH"]
66+
create_advanced_site_search = false
67+
}
5868
resource "google_discovery_engine_search_engine" "basic" {
5969
engine_id = "tf-test-example-engine-id%{random_suffix}"
6070
collection_id = "default_collection"
6171
location = google_discovery_engine_data_store.basic.location
6272
display_name = "Example Display Name"
63-
data_store_ids = [google_discovery_engine_data_store.basic.data_store_id]
73+
data_store_ids = [google_discovery_engine_data_store.basic.data_store_id, google_discovery_engine_data_store.second.data_store_id]
6474
industry_vertical = google_discovery_engine_data_store.basic.industry_vertical
6575
common_config {
6676
company_name = "Example Company Name"
@@ -84,6 +94,15 @@ resource "google_discovery_engine_data_store" "basic" {
8494
solution_types = ["SOLUTION_TYPE_SEARCH"]
8595
create_advanced_site_search = false
8696
}
97+
resource "google_discovery_engine_data_store" "second" {
98+
location = "global"
99+
data_store_id = "tf-test-example2-datastore%{random_suffix}"
100+
display_name = "tf-test-structured-datastore2"
101+
industry_vertical = "GENERIC"
102+
content_config = "NO_CONTENT"
103+
solution_types = ["SOLUTION_TYPE_SEARCH"]
104+
create_advanced_site_search = false
105+
}
87106
resource "google_discovery_engine_search_engine" "basic" {
88107
engine_id = "tf-test-example-engine-id%{random_suffix}"
89108
collection_id = "default_collection"

0 commit comments

Comments
 (0)