Skip to content

Commit

Permalink
feat: added more outputs (#23)
Browse files Browse the repository at this point in the history
* feat: added more outputs

* feat: added more outputs

* feat: added more outputs
  • Loading branch information
rajatagarwal-ibm authored Apr 17, 2024
1 parent 0978b4d commit f637364
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
11 changes: 11 additions & 0 deletions solutions/banking/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
34 changes: 34 additions & 0 deletions solutions/banking/outputs.tf
Original file line number Diff line number Diff line change
@@ -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
}
13 changes: 13 additions & 0 deletions solutions/banking/watson-scripts/discovery-get-project.sh
Original file line number Diff line number Diff line change
@@ -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}'

0 comments on commit f637364

Please sign in to comment.