I am new to AWS and Elasticsearch/Opensearch, and I am having some issues.
I have a Lambda based on python (v3.12) that previously worked with Elasticsearch. My client wants to use Opensearch instead, so i downloaded the library “opensearch-py 2.6.0” and replaced my former library folder ‘elasticsearch’ with the folder ‘opensearchpy’.
In my code, I replaced the 2 references to ELasticsearch :
from opensearchpy import OpenSearch
from dicoDefault import dico as dicoDefault
from dicoDefault import defaultRegex
from dicoDefault import getRegex
from dicoDefault import indices
from dicoDefault import types
from ngram import NGram
from opensearchpy import OpenSearch
from ssl import create_default_context
import certifi
import json
import re
import os
import urllib.parse
import datetime
es = OpenSearch([os.environ['ESURL']])
def lambda_handler(event, context):
inputs = event['queryStringParameters']
However, when I run tests, I have the following error message :
{
"errorMessage": "Unable to import module 'lambda_function': No module named 'events'",
"errorType": "Runtime.ImportModuleError",
"requestId": "e03d61d5-fa1f-424f-a917-1c60e562b3a4",
"stackTrace": []
}
I tried to make some prints, but it seems the function ‘lambda_function’ is not even run.
I did not have this problem with Elasticsearch. So I do not think it has to do with a missing file.
From what I’ve seen, it seems to be a problem related to file versions.
I thought maybe there is some file that is not up to date somewhere in the opensearchpy library ?
Does anyone have some insight into this ?