From f637364e2d3725675f029813ff5cf65972bf8f4f Mon Sep 17 00:00:00 2001 From: Rajat Agrawal <108140212+rajatagarwal-ibm@users.noreply.github.com> Date: Wed, 17 Apr 2024 14:57:40 +0100 Subject: [PATCH] feat: added more outputs (#23) * feat: added more outputs * feat: added more outputs * feat: added more outputs --- solutions/banking/main.tf | 11 ++++++ solutions/banking/outputs.tf | 34 +++++++++++++++++++ .../watson-scripts/discovery-get-project.sh | 13 +++++++ 3 files changed, 58 insertions(+) create mode 100755 solutions/banking/watson-scripts/discovery-get-project.sh diff --git a/solutions/banking/main.tf b/solutions/banking/main.tf index da360d2..bcef2e9 100644 --- a/solutions/banking/main.tf +++ b/solutions/banking/main.tf @@ -151,6 +151,17 @@ data "external" "assistant_get_integration_id" { } } +# get discovery project ID +data "external" "discovery_project_id" { + depends_on = [null_resource.discovery_project_creation] + program = ["bash", "${path.module}/watson-scripts/discovery-get-project.sh"] + query = { + tokendata = local.sensitive_tokendata + watson_discovery_url = local.watsonx_discovery_url + } +} + + # Update CI pipeline with Assistant instance ID resource "ibm_cd_tekton_pipeline_property" "watsonx_assistant_id_pipeline_property_ci" { name = "watsonx_assistant_id" diff --git a/solutions/banking/outputs.tf b/solutions/banking/outputs.tf index e69de29..3bbaf4f 100644 --- a/solutions/banking/outputs.tf +++ b/solutions/banking/outputs.tf @@ -0,0 +1,34 @@ +output "project_id" { + description = "ID of the created WatsonX project." + value = module.configure_project.project_id +} + +output "project_url" { + description = "WatsonX project ID URL." + value = "https://dataplatform.cloud.ibm.com/projects/${module.configure_project.project_id}" +} + +output "watsonx_assistant_url" { + description = "WatsonX Assistant URL." + value = local.watsonx_assistant_url +} + +output "watsonx_discovery_url" { + description = "WatsonX Discovery URL." + value = local.watsonx_discovery_url +} + +output "cos_instance_crn" { + description = "COS instance CRN which is configured with the WatsonX project." + value = module.cos.cos_instance_crn +} + +output "assistant_integration_id" { + description = "WatsonX assistant integration ID." + value = data.external.assistant_get_integration_id.result.assistant_integration_id +} + +output "discovery_project_id" { + description = "WatsonX Discovery Project ID." + value = data.external.discovery_project_id.result.discovery_project_id +} diff --git a/solutions/banking/watson-scripts/discovery-get-project.sh b/solutions/banking/watson-scripts/discovery-get-project.sh new file mode 100755 index 0000000..ef1e0bc --- /dev/null +++ b/solutions/banking/watson-scripts/discovery-get-project.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +set -e + +eval "$(jq -r '@sh "IAM_TOKEN=\(.tokendata) WATSON_DISCOVERY_URL=\(.watson_discovery_url)"')" +token="$(echo "$IAM_TOKEN" | awk '{print $2}')" + +PROJECT_ID=$(curl -X GET --location "$WATSON_DISCOVERY_URL/v2/projects?version=2023-03-31" \ + --header "Authorization: Bearer $token" \ + --header "Content-Type: application/json" \ + | jq -r '.projects[] | select(.name == "gen-ai-rag-sample-app-project") | .project_id ') + +jq -n --arg discovery_project_id "$PROJECT_ID" '{"discovery_project_id": $discovery_project_id}'