Skip to content

Secret not generating

0

Hi All,

I am trying to replicate the generative AI chatbot found in the code in this repository: https://github.com/aws-samples/rag-using-langchain-amazon-bedrock-and-opensearch/tree/main

I have been able to complete all of the steps under "Prerequisites" on the "README" page. However, I am unable to complete step 2 (and therefore can't move onto step 3) on the "Steps for using this sample code" section.

When I run step 2 in the terminal "python3 load-data-to-opensearch.py --recreate 1 --early-stop 1", I receive the following error: " 2024-07-16 13:34:17.631 | INFO | main:main:47 - Starting

2024-07-16 13:34:17.632 | INFO | main:main:57 - recreating opensearch index: True, using early stop: True to insert only 100 records

2024-07-16 13:34:17.632 | INFO | main:main:58 - Preparing OpenSearch Index Traceback (most recent call last):

File "/Users/myname/Desktop/AWS_RAG/rag-using-langchain-amazon-bedrock-and-opensearch/load-data-to-opensearch.py", line 121, in <module>

main()

File "/Users/myname/Desktop/AWS_RAG/rag-using-langchain-amazon-bedrock-and-opensearch/load-data-to-opensearch.py", line 59, in main

opensearch_password = secret.get_secret(name, region)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/Users/myname/Desktop/AWS_RAG/rag-using-langchain-amazon-bedrock-and-opensearch/utils/secret.py", line 6, in get_secret

secret_arn = locate_secret_arn(secret_prefix, client)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "/Users/myname/Desktop/AWS_RAG/rag-using-langchain-amazon-bedrock-and-opensearch/utils/secret.py", line 24, in locate_secret_arn

return response['SecretList'][0]['ARN']

       ~~~~~~~~~~~~~~~~~~~~~~^^^

IndexError: list index out of range"

I believe this error is due to there being no Secret stored in the AWS SecretsManager. For some reason, the code isn't generating a Secret password. I believe that the file "Secrets.tf" in the "Terraform" folder in the repository has the code to generate and store the OpenSearch password as a Secret in the AWS SecretsManager.

I am not sure how to get Secret.tf to generate and store my OpenSearch password in AWS SecretsManager. I believe once I am able to generate and access the password, that the code should then work.

Thank you for your help, Em

1 Answer
3

Hello.

I tried running Terraform in my environment, but SecretsManager was created in us-east-1.
So please try running the code in us-east-1 as well.

Looking at the Terraform code, the region is us-east-1.
https://github.com/aws-samples/rag-using-langchain-amazon-bedrock-and-opensearch/blob/main/terraform/variables.tf

I also gave a similar answer at the URL below.
https://repost.aws/ja/questions/QU5IiD7O8lToSNeGEsEckRtg/how-to-modify-aws-bedrock-code-so-that-it-runs-without-secrets-manager

EXPERT
answered 2 years ago
EXPERT
reviewed 2 years ago
AWS
EXPERT
reviewed 2 years ago
  • Therefore, try specifying the region as an argument as shown below.

    python load-data-to-opensearch.py --recreate 1 --early-stop 1 --region us-east-1
    
  • Thank you sooooo much Riku! This worked!!!!!! Wish me luck in trying to now use the code with my own dataset!

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.