File size: 741 Bytes
d164867
 
 
0150b9a
 
 
d164867
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import boto3
import json
import os
import streamlit as st
# Initialize the Lambda client with AWS credentials and region
# Ensure that the AWS credentials are set in Streamlit secrets

lambda_client = boto3.client(
    'lambda',
    aws_access_key_id=st.secrets['user_access_key_us_west_2'],
    aws_secret_access_key=st.secrets['user_secret_key_us_west_2'], region_name = 'us-west-2'
)

def send_to_lambda(index, document):
    payload = {
        "target_index": index,
        "document": document
    }

    response = lambda_client.invoke(
        FunctionName='proxy-observability-opensearch-ubi',
        InvocationType='Event',  # async!
        Payload=json.dumps(payload)
    )

    return response['StatusCode']  # 202 if accepted