Skip to content

Commit 844d545

Browse files
committed
README instructions for terraform deployment
Signed-off-by: majolr <[email protected]>
1 parent 7ffd4ea commit 844d545

24 files changed

+216
-8
lines changed

askme/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ AskME is a suite of features designed to empower users to maximize the potential
1313

1414
5. Knowledge Base Management: Users can create and delete the vector tables.
1515

16+
## Getting Started
17+
18+
You must have an OCI account. [Click here](https://docs.oracle.com/en/cloud/paas/content-cloud/administer/create-and-activate-oracle-cloud-account.html) for more information about Oracle Cloud account creation and activation. Free-tier accounts are currently not supported for the deployment of AskME resources.
19+
20+
There are required OCI resources (see the [Terraform documentation](./terraform/README.md) for more information) that are needed for this tutorial.
1621

1722
## Contributing
1823

askme/terraform/README.md

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
[![License: UPL](https://img.shields.io/badge/license-UPL-green)](https://img.shields.io/badge/license-UPL-green) [![Quality gate](https://sonarcloud.io/api/project_badges/quality_gate?project=oracle-devrel_tech-content-heatwave)](https://sonarcloud.io/dashboard?id=oracle-devrel_tech-content-heatwave)
2+
3+
# Deploy AskME resources with terraform
4+
5+
This section explains how to deploy AskME in your tenancy, using the OCI Cloud Shell and terraform. The following resources are created during the process:
6+
- A dynamic group and a policy in the root compartment
7+
- A Compartment for the AskME resources
8+
- An Object Storage bucket containing two documents
9+
- A Compute Instance to run the AskME app
10+
- A MySQL DBSystem with a HeatWave cluster
11+
- A Vault, a Vault key and three Vault secrets
12+
- A VCN with an Internet Gateway, two Security Lists and two Subnets
13+
14+
The application can then be accessed from your local machine, using local port forwarding, as detailed in [step 8](#step-8-use-askme).
15+
16+
## Step 1: Open OCI Cloud Shell
17+
Sign In to [your OCI tenancy](http://cloud.oracle.com/), switch to a [region supporting OCI Generative AI](https://docs.oracle.com/en-us/iaas/Content/generative-ai/overview.htm#regions) (e.g: US Midwest), and open the Cloud Shell.
18+
You need to have the [Administrator role](https://docs.oracle.com/en-us/iaas/Content/Identity/roles/understand-administrator-roles.htm) to deploy the AskME resources in your tenancy.
19+
20+
![OCI starting page](assets/oci_home_page.png)
21+
22+
![OCI starting page, developer tools](assets/oci_home_page_dev_tools.png)
23+
24+
## Step 2: Get the repository archive
25+
In the Cloud Shell interface, fetch the tech-content-heatwave repository archive.
26+
27+
Command:
28+
```
29+
wget -O tech-content-heatwave.zip -nv https://github.com/oracle-devrel/tech-content-heatwave/archive/refs/heads/tech-content-heatwave_askme.zip
30+
```
31+
32+
![Cloud Shell: get repository archive](assets/cloud_shell_fetch.png)
33+
34+
## Step 3: Unzip the archive
35+
Command:
36+
```
37+
unzip tech-content-heatwave.zip '*/askme/*' -d tech-content-heatwave
38+
```
39+
40+
![Cloud Shell: unzip repository archive](assets/cloud_shell_unzip.png)
41+
42+
## Step 4: Change directory to the terraform folder
43+
Command:
44+
```
45+
cd tech-content-heatwave/*/askme/terraform
46+
```
47+
48+
## Step 5 (optional): Create a screen session to run terraform
49+
Command:
50+
```
51+
screen -S askme_session
52+
```
53+
54+
## Step 6: Run the setup script
55+
Run the script `askme_setup.sh`, and follow the instructions. Additional information will be asked by the script to setup the DBSystem and the compute instance.
56+
57+
Command:
58+
```
59+
sh askme_setup.sh
60+
```
61+
62+
![Cloud Shell: Run deployment script](assets/cloud_shell_script.png)
63+
64+
### Step 6.a: Compartment name
65+
66+
Name of the AskME demo compartment to create (default: `heatwave-genai-askme`).
67+
68+
If your tenancy already contains a compartment with the default name `heatwave-genai-askme`, please provide another compartment name and press Enter. Otherwise, no need to provide a value, press Enter and the default value will be used.
69+
70+
![Deployment script: compartment input parameter](assets/cloud_shell_script_compartment.png)
71+
72+
73+
### Step 6.b: Allowed IPv4 CIDR block
74+
75+
Set of IPv4 addresses (CIDR notation) allowed to connect to the compute instance.
76+
77+
The CIDR notation follows the format: `a.b.c.d/e` where `a`, `b`, `c` and `d` are numbers between 0 and 255, and `e` is a number between 0 and 32. More information about the CIDR block notation in the [Network Overview](https://docs.oracle.com/en-us/iaas/Content/Network/Concepts/overview.htm#:~:text=CIDR%20NOTATION) page.
78+
79+
![Deployment script: IPv4 CIDR block input parameter](assets/cloud_shell_script_ip_cidr.png)
80+
81+
### Step 6.c: SSH authorized key
82+
83+
Content of the SSH public key file (OpenSSH format) located in your local machine. More information about SSH keys in the [Key Pair management and generation](https://docs.oracle.com/en-us/iaas/Content/Compute/Tasks/managingkeypairs.htm) page.
84+
85+
![Deployment script: SSH authorized key input parameter](assets/cloud_shell_script_ssh.png)
86+
87+
## Step 7: Resource deployment
88+
Wait until the terraform deployment finishes. Expected deployment time: 30-40 minutes.
89+
90+
## Step 8: Use AskME
91+
Connect to the AskME compute instance and access the streamlit page.
92+
Follow the instructions provided in the Cloud Shell output. The instructions should look similar to this:
93+
```
94+
================================================
95+
Open a terminal in your local computer, and run:
96+
ssh -L 8501:localhost:8501 [email protected]
97+
Then in your web browser, open the URL:
98+
127.0.0.1:8501
99+
================================================
100+
```
101+
102+
This information can be displayed again with the command `sh askme_output.sh` from the location described in [step 4](#step-4-change-directory-to-the-terraform-folder).
103+
104+
105+
# Cleanup AskME resources with terraform
106+
107+
This section explains how to remove AskME resources from your tenancy, using the OCI Cloud Shell and terraform.
108+
109+
#### Warning: Cleanup setup requirement
110+
Please make sure that the AskME resources have been created following the [deployment instructions](#deploy-askme-resources-with-terraform), and that the setup folders/files located in [deployment step 4](#step-4-change-directory-to-the-terraform-folder) have not been modified or removed since the last deployment.
111+
112+
More specifically, please make sure that the file `terraform.tfstate` still exists there. If not, all resources described in the [deployment instructions](#deploy-askme-resources-with-terraform) need to be removed manually.
113+
114+
#### Warning: Cleanup retention period
115+
There is a retention period of 30 days before the OCI Vault can be removed, blocking the compartment deletion. Please rerun the [cleanup step 2](#step-2-run-the-cleanup-script) again after 30 days to complete the cleanup process.
116+
117+
## Step 1: Remove Vector Tables in the AskME app (if any)
118+
Follow the instructions in [step 8](#step-8-use-askme) to access the streamlit page.
119+
In the `Knowledge Base Management` tab, go to the section `Reset Knowledge Base` and follow the page instructions to remove all vector store tables.
120+
121+
![Remove Vector Tables from AskME](assets/askme_reset_kb.png)
122+
123+
## Step 2: Run the cleanup script
124+
Follow the instructions in [deployment step 1](#step-1-open-oci-cloud-shell) and [deployment step 4](#step-4-change-directory-to-the-terraform-folder) to use the Cloud Shell from the right location.
125+
126+
Run the script `sh askme_cleanup.sh`, and follow the instructions. Additional information will be asked by the script to choose the right compartment name.
127+
128+
Command:
129+
```
130+
sh askme_cleanup.sh
131+
```
132+
133+
![Cloud Shell: Run deployment script](assets/cloud_shell_script_cleanup.png)
134+
135+
### Step 2.a: Compartment name
136+
137+
Name of the AskME demo compartment to delete (default: `heatwave-genai-askme`).
138+
139+
If you used a custom compartment name in [deployment step 6.a](#step-6a-compartment-name), please provide the same compartment name here and press Enter. Otherwise, no need to provide a value, press Enter and the default value will be used.
140+
141+
![Cleanup script: compartment input parameter](assets/cloud_shell_script_compartment.png)
142+
143+
144+
# Troubleshooting
145+
146+
## Compartment already exists
147+
148+
![Troubleshooting: compartment already exists](assets/troubleshooting_compartment_exists.png)
149+
150+
If the compartment already exists in your tenancy, please rerun the [step 6](#step-6-run-the-setup-script) and specify another compartment name in [step 6.a](#step-6a-compartment-name).
151+
152+
## Current OCI region does not support Generative AI
153+
154+
![Troubleshooting: region does not support GenAI](assets/troubleshooting_region_genai_support.png)
155+
156+
Please close the current Cloud Shell session:
157+
158+
![Exit Cloud Shell](assets/cloud_shell_exit.png)
159+
160+
![Exit Cloud Shell Confirm](assets/cloud_shell_exit_confirm.png)
161+
162+
Then change the OCI Console region to a [region supporting OCI Generative AI](https://docs.oracle.com/en-us/iaas/Content/generative-ai/overview.htm#regions) (e.g: US Midwest):
163+
164+
![Change OCI Region](assets/oci_home_page_change_region.png)
165+
166+
Then reopen the Cloud Shell ([step 1](#step-1-open-oci-cloud-shell)) and in the same folder as in [step 4](#step-4-change-directory-to-the-terraform-folder), please rerun [step 6](#step-6-run-the-setup-script).
167+
168+
## Compartment name length must be between 4 and 20
169+
170+
![Troubleshooting: bad compartment name format](assets/troubleshooting_compartment_name_format.png)
171+
172+
Please rerun [step 6](#step-6-run-the-setup-script) and use a smaller/longer compartment name in [step 6.a](#step-6a-compartment-name).
173+
174+
## Invalid IPv4 CIDR block notation
175+
176+
![Troubleshooting: bad IPv4 CIDR format](assets/troubleshooting_cidr_format.png)
177+
178+
Please rerun [step 6](#step-6-run-the-setup-script) and provide a valid IPv4 block range in [step 6.b](#step-6b-allowed-ipv4-cidr-block), following the CIDR block notation.
179+
180+
More information about the CIDR block notation in the [Network Overview](https://docs.oracle.com/en-us/iaas/Content/Network/Concepts/overview.htm#:~:text=CIDR%20NOTATION) page.
181+
182+
## The SSH public key value must follow the OpenSSH format
183+
184+
![Troubleshooting: bad SSH public key format](assets/troubleshooting_ssh_key_format.png)
185+
186+
Please rerun [step 6](#step-6-run-the-setup-script) and provide a valid SSH public key in [step 6.c](#step-6c-ssh-authorized-key), following the OpenSSH format.
187+
188+
More information about SSH keys in the [Key Pair management and generation](https://docs.oracle.com/en-us/iaas/Content/Compute/Tasks/managingkeypairs.htm) page.

askme/terraform/askme_output.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
# Copyright (c) 2025 Oracle and/or its affiliates.
3+
# Licensed under the Universal Permissive License (UPL), Version 1.0.
4+
5+
set -e # Exit script if any command fails
6+
7+
terraform init >/dev/null
8+
public_ip=`terraform output -json askme_instance_public_ip 2>/dev/null || echo ""`
9+
public_ip=`echo $public_ip | tr -d '"'`
10+
if [ -z "$public_ip" ]
11+
then
12+
echo "No terraform resource detected.."
13+
echo "Please run the deployment instructions to create the resources."
14+
else
15+
echo "================================================"
16+
echo "Open a terminal in your local computer, and run:"
17+
echo " ssh -L 8501:localhost:8501 opc@$public_ip"
18+
echo "Then in your web browser, open the URL:"
19+
echo " 127.0.0.1:8501"
20+
echo "================================================"
21+
fi

askme/terraform/askme_setup.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,4 @@ set -e # Exit script if any command fails
66

77
terraform init
88
TF_VAR_TENANCY=$OCI_TENANCY TF_VAR_REGION=$OCI_REGION terraform apply -auto-approve
9-
public_ip=`terraform output -raw askme_instance_public_ip`
10-
echo "================================================"
11-
echo "Open a terminal in your local computer, and run:"
12-
echo " ssh -L 8501:localhost:8501 opc@$public_ip"
13-
echo "Then in your web browser, open the URL:"
14-
echo " 127.0.0.1:8501"
15-
echo "================================================"
9+
sh askme_output.sh
113 KB
Loading
29.2 KB
Loading
61.5 KB
Loading
101 KB
Loading
93 KB
Loading
86.5 KB
Loading

0 commit comments

Comments
 (0)