简体   繁体   中英

How do I import Opensearch from opensearchpy?

new to the community here. I didn't find this problem discussed, so I'm probably missing something super obvious. Thanks!

Python Code snippet:

import botocore
import time
import os
import os.path
import sys
import io
import urllib.parse
import json
import base64

from io import BytesIO
from opensearchpy import OpenSearch, RequestsHttpConnection
from requests_aws4auth import AWS4Auth

from s3transfer.manager import TransferManager
from trp import Document

error code from lambda while using s3 put test scenario

commented above, but to answer.

  1. create a layer directory with a 'python' folder

  2. install library into that python folder

    $ py -m pip install opensearch-py --target lambda-layer/python/

  3. zip the python folder and re-name to something relevant (opensearch-py.1.0.0.zip)

  4. create layer in lambda, upload zip file

  5. add layer to lambda function

  6. victory

there's a bunch of info out there with differing file directory structures for layers, but the fine folks at amazon wrote it down . I just missed the need to have all the dependent collateral libraries included in the zip for it to work correctly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM