|
| 1 | +[](https://img.shields.io/badge/license-UPL-green) [](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 | + |
| 21 | + |
| 22 | + |
| 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 | + |
| 33 | + |
| 34 | +## Step 3: Unzip the archive |
| 35 | +Command: |
| 36 | +``` |
| 37 | +unzip tech-content-heatwave.zip '*/askme/*' -d tech-content-heatwave |
| 38 | +``` |
| 39 | + |
| 40 | + |
| 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 | + |
| 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 | + |
| 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 | + |
| 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 | + |
| 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 opc@x.x.x.x |
| 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 | + |
| 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 | + |
| 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 | + |
| 142 | + |
| 143 | + |
| 144 | +# Troubleshooting |
| 145 | + |
| 146 | +## Compartment already exists |
| 147 | + |
| 148 | + |
| 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 | + |
| 155 | + |
| 156 | +Please close the current Cloud Shell session: |
| 157 | + |
| 158 | + |
| 159 | + |
| 160 | + |
| 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 | + |
| 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 | + |
| 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 | + |
| 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 | + |
| 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. |
0 commit comments