1
1
locals {
2
- watsonx_assistant_url = " https://api.${ var . watson_assistant_region } .assistant.watson.cloud.ibm.com/instances/${ var . watson_assistant_instance_id } "
3
- watsonx_discovery_url = " //api.${ var . watson_discovery_region } .discovery.watson.cloud.ibm.com/instances/${ var . watson_discovery_instance_id } "
4
- sensitive_tokendata = sensitive (data. ibm_iam_auth_token . tokendata . iam_access_token )
2
+ watsonx_assistant_url = " https://api.${ var . watson_assistant_region } .assistant.watson.cloud.ibm.com/instances/${ var . watson_assistant_instance_id } "
3
+ watson_discovery_url = " //api.${ var . watson_discovery_region } .discovery.watson.cloud.ibm.com/instances/${ var . watson_discovery_instance_id } "
4
+ watson_discovery_project_name = var. prefix != null ? " ${ var . prefix } -gen-ai-rag-sample-app-project" : " gen-ai-rag-sample-app-project"
5
+ watson_discovery_collection_name = var. prefix != null ? " ${ var . prefix } -gen-ai-rag-sample-app-data" : " gen-ai-rag-sample-app-data"
6
+ sensitive_tokendata = sensitive (data. ibm_iam_auth_token . tokendata . iam_access_token )
5
7
}
6
8
7
9
data "ibm_iam_auth_token" "tokendata" {}
@@ -114,25 +116,25 @@ module "configure_project" {
114
116
# Discovery project creation
115
117
resource "restapi_object" "configure_discovery_project" {
116
118
depends_on = [data . ibm_iam_auth_token . tokendata ]
117
- path = local. watsonx_discovery_url
118
- read_path = " ${ local . watsonx_discovery_url } /v2/projects/{id}?version=2023-03-31"
119
+ path = local. watson_discovery_url
120
+ read_path = " ${ local . watson_discovery_url } /v2/projects/{id}?version=2023-03-31"
119
121
read_method = " GET"
120
- create_path = " ${ local . watsonx_discovery_url } /v2/projects?version=2023-03-31"
122
+ create_path = " ${ local . watson_discovery_url } /v2/projects?version=2023-03-31"
121
123
create_method = " POST"
122
124
id_attribute = " project_id"
123
125
destroy_method = " DELETE"
124
- destroy_path = " ${ local . watsonx_discovery_url } /v2/projects/{id}?version=2023-03-31"
126
+ destroy_path = " ${ local . watson_discovery_url } /v2/projects/{id}?version=2023-03-31"
125
127
data = <<- EOT
126
128
{
127
- "name": "gen-ai-rag-sample-app-project ",
129
+ "name": "${ local . watson_discovery_project_name } ",
128
130
"type": "document_retrieval"
129
131
}
130
132
EOT
131
133
update_method = " POST"
132
- update_path = " ${ local . watsonx_discovery_url } /v2/projects/{id}?version=2023-03-31"
134
+ update_path = " ${ local . watson_discovery_url } /v2/projects/{id}?version=2023-03-31"
133
135
update_data = <<- EOT
134
136
{
135
- "name": "gen-ai-rag-sample-app-project ",
137
+ "name": "${ local . watson_discovery_project_name } ",
136
138
"type": "document_retrieval"
137
139
}
138
140
EOT
@@ -141,25 +143,25 @@ resource "restapi_object" "configure_discovery_project" {
141
143
# Discovery collection creation
142
144
resource "restapi_object" "configure_discovery_collection" {
143
145
depends_on = [data . ibm_iam_auth_token . tokendata , restapi_object . configure_discovery_project ]
144
- path = local. watsonx_discovery_url
145
- read_path = " ${ local . watsonx_discovery_url } /v2/projects/${ restapi_object . configure_discovery_project . id } /collections/{id}?version=2023-03-31"
146
+ path = local. watson_discovery_url
147
+ read_path = " ${ local . watson_discovery_url } /v2/projects/${ restapi_object . configure_discovery_project . id } /collections/{id}?version=2023-03-31"
146
148
read_method = " GET"
147
- create_path = " ${ local . watsonx_discovery_url } /v2/projects/${ restapi_object . configure_discovery_project . id } /collections?version=2023-03-31"
149
+ create_path = " ${ local . watson_discovery_url } /v2/projects/${ restapi_object . configure_discovery_project . id } /collections?version=2023-03-31"
148
150
create_method = " POST"
149
151
id_attribute = " collection_id"
150
152
destroy_method = " DELETE"
151
- destroy_path = " ${ local . watsonx_discovery_url } /v2/projects/${ restapi_object . configure_discovery_project . id } /collections/{id}?version=2023-03-31"
153
+ destroy_path = " ${ local . watson_discovery_url } /v2/projects/${ restapi_object . configure_discovery_project . id } /collections/{id}?version=2023-03-31"
152
154
data = <<- EOT
153
155
{
154
- "name": "gen-ai-rag-sample-app-data ",
156
+ "name": "${ local . watson_discovery_collection_name } ",
155
157
"description": "Sample data"
156
158
}
157
159
EOT
158
160
update_method = " POST"
159
- update_path = " ${ local . watsonx_discovery_url } /v2/projects/${ restapi_object . configure_discovery_project . id } /collections/{id}?version=2023-03-31"
161
+ update_path = " ${ local . watson_discovery_url } /v2/projects/${ restapi_object . configure_discovery_project . id } /collections/{id}?version=2023-03-31"
160
162
update_data = <<- EOT
161
163
{
162
- "name": "gen-ai-rag-sample-app-data ",
164
+ "name": "${ local . watson_discovery_collection_name } ",
163
165
"description": "Sample data"
164
166
}
165
167
EOT
@@ -173,7 +175,7 @@ resource "null_resource" "discovery_file_upload" {
173
175
}
174
176
175
177
provisioner "local-exec" {
176
- command = " ${ path . module } /watson-scripts/discovery-file-upload.sh \" https:${ local . watsonx_discovery_url } \" \" ${ restapi_object . configure_discovery_project . id } \" \" ${ restapi_object . configure_discovery_collection . id } \" \" ${ path . module } /artifacts/WatsonDiscovery\" "
178
+ command = " ${ path . module } /watson-scripts/discovery-file-upload.sh \" https:${ local . watson_discovery_url } \" \" ${ restapi_object . configure_discovery_project . id } \" \" ${ restapi_object . configure_discovery_collection . id } \" \" ${ path . module } /artifacts/WatsonDiscovery\" "
177
179
interpreter = [" /bin/bash" , " -c" ]
178
180
quiet = true
179
181
environment = {
0 commit comments