|
4 | 4 |
|
5 | 5 | The "Document Explorer" sample generative AI application demonstrates how to build end-to-end solutions leveraging AWS services and [AWS Generative AI CDK Constructs](https://github.com/awslabs/generative-ai-cdk-constructs). |
6 | 6 |
|
| 7 | +> Note: This sample can also be deployed through Terraform ! Please refer to the [Terraform sample code](https://github.com/aws-samples/aws-generative-ai-terraform-samples/tree/main/samples/document-explorer) for more details. |
| 8 | +
|
7 | 9 | It includes examples of key components needed in generative AI applications: |
8 | 10 |
|
9 | 11 | - [Data Ingestion Pipeline](https://github.com/awslabs/generative-ai-cdk-constructs/tree/main/src/patterns/gen-ai/aws-rag-appsync-stepfn-opensearch): Ingests documents, converts them to text, and stores them in a knowledge base for retrieval. This enables long context window approaches. |
@@ -45,17 +47,6 @@ samples/document_explorer |
45 | 47 | ├── cdk-config-frontend |
46 | 48 | │ └── frontend_stack.py # Frontend - CDK app |
47 | 49 | │ |
48 | | -├── terraform-config-frontend # Frontend – Terraform |
49 | | -│ │ |
50 | | -│ ├── main.tf # Terraform resources |
51 | | -│ ├── outputs.tf # Outputs definition |
52 | | -│ ├── variables.tf # Variables defintion |
53 | | -│ └── terraform.tfvars # Variables values |
54 | | -│ |
55 | | -├── terraform-config-backend # Backend – Terraform |
56 | | -│ │ |
57 | | -│ ├── main.tf # Terraform resources |
58 | | -│ └── outputs.tf # Outputs definition |
59 | 50 | │ |
60 | 51 | ├── bin |
61 | 52 | │ └── document_explorer.ts # Backend - CDK app |
@@ -153,7 +144,7 @@ Note: the CDK Front End deployment was adapted from [this blog](https://kawsaur. |
153 | 144 | ```shell |
154 | 145 | cd cdk-config-frontend |
155 | 146 | ``` |
156 | | -2. Configure your environment variables in `client_app/Dockerfile`. Replace the property values with the values retrieved from the stack outputs/console. You will leave `APP_URI` as a placeholder for now because the URI will be the Cloudfront URL output from your Terraform deployment. |
| 147 | +2. Configure your environment variables in `client_app/Dockerfile`. Replace the property values with the values retrieved from the stack outputs/console. You will leave `APP_URI` as a placeholder for now because the URI will be the Cloudfront URL output from your CDK deployment. |
157 | 148 |
|
158 | 149 | ``` |
159 | 150 | ENV COGNITO_DOMAIN = "<ApiStack.CognitoDomain>" |
@@ -186,58 +177,6 @@ Note: the CDK Front End deployment was adapted from [this blog](https://kawsaur. |
186 | 177 |
|
187 | 178 | </details> |
188 | 179 |
|
189 | | - |
190 | | - |
191 | | - ### Deploy with Terraform |
192 | | - <details><summary>Terraform Instructions</summary> |
193 | | - |
194 | | - #### Deploy the Backend |
195 | | - 1. Open the `/terraform-config-backend` folder |
196 | | - ```shell |
197 | | - cd terraform-config-backend |
198 | | - ``` |
199 | | - 2. Run `terraform init` |
200 | | - 3. Make sure you have Docker running and deploy the Terraform by running `terraform apply` |
201 | | - 4. When prompted with `Do you want to perform these actions?` enter `yes` and wait for the backend to be deployed. |
202 | | - |
203 | | - |
204 | | - |
205 | | -#### Deploy the Front End |
206 | | - |
207 | | - |
208 | | - |
209 | | -1. Open the `/terraform-config-frontend` folder |
210 | | - ```shell |
211 | | - cd ../terraform-config-frontend |
212 | | - ``` |
213 | | -2. Configure your environment variables in `client_app/Dockerfile`. Replace the property values with the values the were outputted from the backend Terraform deployment in your terminal. You will leave `APP_URI` as a placeholder for now because the URI will be the Cloudfront URL output from your Front End Terraform deployment. |
214 | | - ``` |
215 | | -ENV COGNITO_DOMAIN = "<Output.CognitoDomain>" |
216 | | -ENV REGION = "<Output.Region>" |
217 | | -ENV USER_POOL_ID = "<Output.UserPoolId>" |
218 | | -ENV CLIENT_ID = "<Output.ClientId>" |
219 | | -ENV CLIENT_SECRET = "<COGNITO_CLIENT_SECRET>" |
220 | | -ENV IDENTITY_POOL_ID = "<Output.IdentityPoolId>" |
221 | | -ENV AUTHENTICATED_ROLE_ARN = "<Output.AuthenticatedRoleArn>" |
222 | | -ENV GRAPHQL_ENDPOINT = "<Output.GraphQLEndpoint>" |
223 | | -ENV S3_INPUT_BUCKET = "<Output.InputsAssetsBucket>" |
224 | | -ENV S3_PROCESSED_BUCKET = "<Output.ProcessedAssetsBucket>" |
225 | | -ENV CLIENT_NAME = "<Output.ClientName>" |
226 | | - ``` |
227 | | - |
228 | | - Note: The ```COGNITO_CLIENT_SECRET``` is a secret value that can be retrieved from the AWS Console. Go to the [Amazon Cognito page](https://console.aws.amazon.com/cognito/home) in the AWS console, then select the created user pool. Under App integration, select the corresponding app client. This will navigate you to a new page where the secret can be unhidden, and you will want to copy the value of the App client secret. |
229 | | - |
230 | | - |
231 | | -3. Run `terraform init` |
232 | | -4. Run `terraform import aws_cognito_user_pool_client.update_client {user-pool-id}/{client-id}` and make sure to update the `user-pool-id` and `client-id` values. In the `terraform.tfvars` folder, add the values for the `user_pool_id`, `client_name`, `client_id`, and `region`. |
233 | | -5. Run `terraform import aws_cognito_identity_pool.update_pool {identity-pool-id}`. |
234 | | -5. Deploy the Terraform by running `terraform apply` |
235 | | -6. Now that you have the CloudFront URL, go back to your `client_app/Dockerfile` and paste in the value of your Cloudfront URL like `https://XXXXXXXXXXXXXX.cloudfront.net/` for your APP_URI. Save the Dockerfile and run `terraform apply` again. |
236 | | -7. Once your changes have been applied, open your browser to the outputted URL. It may take a few moments for the webapp to become available. |
237 | | -</details> |
238 | | - |
239 | | - |
240 | | - |
241 | 180 | ### Deploy the Front End Locally |
242 | 181 |
|
243 | 182 | <details> |
@@ -402,12 +341,6 @@ First make sure to remove all data from the Amazon Simple Storage Service (Amazo |
402 | 341 | $ cdk destroy --all |
403 | 342 | ``` |
404 | 343 |
|
405 | | -Or if you deployed with Terraform: |
406 | | -
|
407 | | -```shell |
408 | | - $ terraform destroy |
409 | | -``` |
410 | | -
|
411 | 344 | Then in the AWS Console delete the S3 buckets. |
412 | 345 |
|
413 | 346 | ## Deployment Options |
|
0 commit comments