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

Terraform updates on Discovery Engine data store ids causes an unexpected delete and recreated #20603

Open
khuong507 opened this issue Dec 5, 2024 · 0 comments

Comments

@khuong507
Copy link

khuong507 commented Dec 5, 2024

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to a user, that user is claiming responsibility for the issue.
  • Customers working with a Google Technical Account Manager or Customer Engineer can ask them to reach out internally to expedite investigation and resolution of this issue.

The discovery engine api supports the ability to patch an engine. By patching it should allow terraform to be able to update the
google_discovery_engine_chat_engine resource rather than deleting and replacing. Today when adding a new datastore to the data_store_ids collection it forces a delete an recreate. This is unappealing. Especially if the engine has been heavily tuned with custom tuned models. Deleting and recreating causes a lot of unnecessary work. The GCP UI supports adding/removing data stores without having to delete the app. The Terraform resource should do the same.

https://cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1/projects.locations.collections.engines/patch

Terraform Version & Provider Version(s)

Terraform v1.5.7
on darwin_arm64

  • provider registry.terraform.io/hashicorp/archive v2.6.0
  • provider registry.terraform.io/hashicorp/google v6.12.0
  • provider registry.terraform.io/hashicorp/google-beta v5.7.0

Affected Resource(s)

google_discovery_engine_chat_engine

Terraform Configuration

resource "google_discovery_engine_chat_engine" "primary" {
  engine_id = "chat-engine-id"
  collection_id = "default_collection"
  location = google_discovery_engine_data_store.test_data_store.location
  display_name = "Chat engine"
  industry_vertical = "GENERIC"
  data_store_ids = [google_discovery_engine_data_store.test_data_store.data_store_id, google_discovery_engine_data_store.test_data_store_2.data_store_id]
  common_config {
    company_name = "test-company"
  }
  chat_engine_config {
    agent_creation_config {
    business = "test business name"
    default_language_code = "en"
    time_zone = "America/Los_Angeles"
    }
  }
}

Debug Output

-/+ resource "google_discovery_engine_search_engine" "hidden" {
      + create_time       = (known after apply)
      ~ data_store_ids    = [ # forces replacement
          - "store1",
          + "store1",
            "store2",
            # (3 unchanged elements hidden)
        ]
      ~ id                = "hidden" -> (known after apply)
      ~ name              = "hidden" -> (known after apply)
      + update_time       = (known after apply)
        # (6 unchanged attributes hidden)

        # (2 unchanged blocks hidden)
    }

Expected Behavior

The google_discovery_engine_search_engine should be modified/updated and not deleted and recreated.

Actual Behavior

The google_discovery_engine_search_engine resource is deleted and recreated.

Steps to reproduce

  1. With the following configs create an engine:
resource "google_discovery_engine_chat_engine" "primary" {
  engine_id = "chat-engine-id"
  collection_id = "default_collection"
  location = google_discovery_engine_data_store.test_data_store.location
  display_name = "Chat engine"
  industry_vertical = "GENERIC"
  data_store_ids = [google_discovery_engine_data_store.test_data_store.data_store_id, google_discovery_engine_data_store.test_data_store_2.data_store_id]
  common_config {
    company_name = "test-company"
  }
  chat_engine_config {
    agent_creation_config {
    business = "test business name"
    default_language_code = "en"
    time_zone = "America/Los_Angeles"
    }
  }
}
  1. terraform apply
  2. Modify the data store ids by removing one:
resource "google_discovery_engine_chat_engine" "primary" {
  engine_id = "chat-engine-id"
  collection_id = "default_collection"
  location = google_discovery_engine_data_store.test_data_store.location
  display_name = "Chat engine"
  industry_vertical = "GENERIC"
  data_store_ids = [google_discovery_engine_data_store.test_data_store.data_store_id]
  common_config {
    company_name = "test-company"
  }
  chat_engine_config {
    agent_creation_config {
    business = "test business name"
    default_language_code = "en"
    time_zone = "America/Los_Angeles"
    }
  }
}
  1. terraform apply

Important Factoids

No response

References

No response

b/382548791

@khuong507 khuong507 added the bug label Dec 5, 2024
@github-actions github-actions bot added forward/review In review; remove label to forward service/discoveryengine labels Dec 5, 2024
@NickElliot NickElliot self-assigned this Dec 5, 2024
@NickElliot NickElliot added enhancement and removed bug forward/review In review; remove label to forward labels Dec 5, 2024
@NickElliot NickElliot removed their assignment Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants