-
Notifications
You must be signed in to change notification settings - Fork 116
/
search-conversation.tf
130 lines (118 loc) · 4.57 KB
/
search-conversation.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
*
* Note: Terraform Provider Limitations, while some GCP GenAI features are not yet fully supported by Terraform, this deployment offers a Python Google Cloud SDK-based deployment to enable those capabilities.
*
*/
resource "random_string" "random" {
length = 4
special = false
lower = true
upper = false
}
locals {
data_store_id = "${var.search_app_name}_datastore_${random_string.random.result}"
search_engine_id = "${var.search_app_name}_search_engine_${random_string.random.result}"
chat_engine_id = "${var.search_app_name}_chat_engine_${random_string.random.result}"
website_data_store_id = "${var.search_app_name}_web_datastore_${random_string.random.result}"
storage_data_store_id = "${var.search_app_name}_storage_datastore_${random_string.random.result}"
}
resource "google_discovery_engine_data_store" "search_datastore" {
project = var.project_id
location = var.genai_location
data_store_id = local.data_store_id
display_name = "tf-test-structured-datastore"
industry_vertical = "GENERIC"
content_config = "PUBLIC_WEBSITE"
solution_types = ["SOLUTION_TYPE_SEARCH"]
create_advanced_site_search = false
depends_on = [module.project_services]
document_processing_config {}
lifecycle {
ignore_changes = [
document_processing_config
]
}
}
resource "google_discovery_engine_search_engine" "search_app" {
project = var.project_id
engine_id = local.search_engine_id
collection_id = "default_collection"
location = var.genai_location
display_name = local.search_engine_id
data_store_ids = [google_discovery_engine_data_store.search_datastore.data_store_id]
search_engine_config {
}
}
// Creating target site
resource "null_resource" "genai_marketing_search_target_site" {
triggers = {
search_app = google_discovery_engine_search_engine.search_app.id
}
provisioner "local-exec" {
working_dir = "scripts/"
command = "venv/bin/python3 -c 'import search_app_creation; search_app_creation.create_target_site(\"${var.project_id}\",\"${var.genai_location}\",\"${google_discovery_engine_data_store.search_datastore.data_store_id}\",\"${join(",", var.datastore_uris)}\")'"
}
depends_on = [null_resource.py_venv, google_discovery_engine_search_engine.search_app]
}
resource "google_discovery_engine_data_store" "website_datastore" {
project = var.project_id
location = var.genai_location
data_store_id = local.website_data_store_id
display_name = local.website_data_store_id
industry_vertical = "GENERIC"
content_config = "PUBLIC_WEBSITE"
solution_types = ["SOLUTION_TYPE_CHAT"]
depends_on = [module.project_services]
}
resource "google_discovery_engine_data_store" "storage_datastore" {
project = var.project_id
location = var.genai_location
data_store_id = local.storage_data_store_id
display_name = local.storage_data_store_id
industry_vertical = "GENERIC"
content_config = "CONTENT_REQUIRED"
solution_types = ["SOLUTION_TYPE_CHAT"]
depends_on = [module.project_services]
document_processing_config {}
lifecycle {
ignore_changes = [
document_processing_config
]
}
}
resource "google_discovery_engine_chat_engine" "chat_app" {
project = var.project_id
engine_id = local.chat_engine_id
collection_id = "default_collection"
location = var.genai_location
display_name = "Chat engine"
industry_vertical = "GENERIC"
data_store_ids = [
google_discovery_engine_data_store.website_datastore.data_store_id,
google_discovery_engine_data_store.storage_datastore.data_store_id]
common_config {
company_name = var.company_name
}
chat_engine_config {
agent_creation_config {
business = var.company_name
default_language_code = "en"
time_zone = "America/Los_Angeles"
}
}
}