r/awslambda • • Oct 30 '17

Learn to create AWS Lambda function using NodeJS

Thumbnail
youtube.com
2 Upvotes

r/awslambda • • Oct 27 '17

Going Serverless | AWS Lambda and Kinesis streams at busuu

Thumbnail
reddit.com
2 Upvotes

r/awslambda • • Oct 11 '17

AWS Lambda meets Racket (or any compiled language)

Thumbnail
lambrospetrou.com
2 Upvotes

r/awslambda • • Sep 28 '17

New dev environment for AWS Lambda

2 Upvotes

It's a new open-source project focusing on development involving AWS Lambda. It enables development of Lambda functions in a dev-friendly environment (local development experience), yet running in full context of a real life AWS Lambda environment. More details can be found in GitHub https://github.com/minutelab/mless. We hope you find it handy and valuable, as always - any feedback (let alone contributors) are more than welcome!


r/awslambda • • Jul 05 '17

Building Lambda Test Configurations the Easy W

2 Upvotes

Quick blog post on creating Lambda test configurations

“Testing AWS Lambda Functions the Easy Way” @reginald3 https://medium.com/@reginald.johnson/testing-aws-lambda-functions-the-easy-way-41cf1ed8c090


r/awslambda • • May 17 '17

AWS X-Ray Makes AWS Lambda Request Tracing Generally Available

Thumbnail
aws.amazon.com
2 Upvotes

r/awslambda • • Feb 07 '17

CODE WITH ME | SERVERLESS SLACK APP | PART 1 | FooBar

Thumbnail
youtube.com
2 Upvotes

r/awslambda • • Nov 10 '16

AWS Lambda: Features, Limitations and A Few Practical Examples

Thumbnail stratoscale.com
2 Upvotes

r/awslambda • • May 10 '26

Unable to load .pkl ML model for AWS Lambda (dependency/version issues) – tried EC2 also

1 Upvotes

Hi, I’m trying to deploy a machine learning model on AWS Lambda.

I have:

  • a .pkl file (saved using joblib)

  • a lambda_function.py file to load and run predictions

My goal is to deploy this on Lambda, but I was getting dependency issues, so I tried setting it up on an EC2 instance first to debug.

However, I’m facing multiple errors while loading the model, and I don’t have access to the original environment or requirements.txt (my friend trained the model and hasn’t shared it yet).

Errors I’ve encountered:

  • ModuleNotFoundError: No module named '_loss'

  • ModuleNotFoundError: No module named 'numpy._core'

  • ValueError: MT19937 is not a known BitGenerator module

What I’ve tried:

  • Creating virtual environment on EC2 (Ubuntu)

  • Installing different versions of numpy, scipy, scikit-learn, joblib, xgboost

  • Matching sklearn version (1.7.2 from warning)

  • Re-downloading the .pkl file

  • Trying Docker build for Lambda image

Still not working.

Current setup:

  • AWS Lambda (target)

  • EC2 Ubuntu instance (for testing)

  • Python 3.10

  • joblib for loading model

Code:

import joblib

data = joblib.load("clinical_trial_pipeline_v1.pkl")

model1 = data['model1'] scaler1 = data['scaler1']

X = [[1,2,3,4]] X_scaled = scaler1.transform(X) prediction = model1.predict(X_scaled)

print(prediction)

My questions:

  1. Is it possible to recover or infer the correct environment from a .pkl file?

  2. Is this likely due to version mismatch between numpy/sklearn?

  3. What’s the best way to make this work for AWS Lambda without original requirements.txt?

Any help would be really appreciated I’ve been stuck for 2 days trying to fix this.


r/awslambda • • May 16 '24

text to speech and speech to text response time

1 Upvotes

dealing with aws lex bot, I figure out that each time I call the bot through amazon connect / genesys cloud or simply by testing the bot through aws console voice input, the response time for the transition between slots take some time (2-3) seconds witch is a little bit annoying when dealing with many slots....

my direct question is there a way to minimize the time for the TTS and STT ?


r/awslambda • • May 07 '24

Migrating AWS Lambda functions from the Go1.x runtime

1 Upvotes

I have been working on Migrating AWS Lambda functions from the Go1.x runtime to the custom runtime on Amazon Linux 2, Created the sprint script to list lambda func in all region

https://github.com/muhammedabdelkader/Micro-Sprint/blob/main/reports/list_lambda.sh

Don't forgot the filter command


r/awslambda • • Apr 29 '24

In a lambda triggered by an sqs queue, what is the default behavior for message deletion?

1 Upvotes

In a lambda triggered by a traditional sqs queue, what is the default behavior for message deletion?

If no explicit action is taken, and the lambda execution succeeds, will the lambda delete the sqs incoming sqs messages?

By default, ReportBatchItemFailures is disabled.

Does the behavior change if the lambda deletes any of the incoming messages explicitly?

IMO this page isn't the clearest https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html

Thank you in advance!


r/awslambda • • Apr 26 '24

Deploying pretrained model on a server for Realtime image processing [D] [R] [P]

1 Upvotes

I have a flask application, which uses a pretrained ml model ,whose main task is to find embeddings of an image, at a time there may be 100s of images for processing, lets suppose that the 100 image processing takes 80sec to complete, how should i deploy the application on AWS or any other cloud service, such that it takes only 4-5 seconds to process 100 images.


r/awslambda • • Apr 23 '24

[Java Lambda - Help] Running a Simulation Model

1 Upvotes

My client has requested the execution of a simulation model (model.jar) exported from AnyLogic. The export provides everything needed to run the model, including a "lib" folder containing all required files.

Considering the model execution takes less than 15 minutes and utilizes 5GB of RAM, running it on an AWS Lambda function is a good solution for me. I was thinking that the solution could have these steps:

  1. Store all exported AnyLogic files in an Amazon S3 bucket.

  2. Download the necessary files within the Lambda function.

  3. Execute the simulation model using Process Builder.

  4. Save the execution results back to the S3 bucket.

Would that be a good solution? Here is an SS of the files that I have.


r/awslambda • • Apr 22 '24

How to set the LLM temperature, model ARN and AWS Knowledge Base for an AI chatbot built using AWS Bedrock + invoke_agent function + AWS Lambda

1 Upvotes

Hey guys, so I am referring to this documentation below on AWS Bedrock's "invoke_agent" function:

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/bedrock-agent-runtime/client/invoke_agent.html

In the "responses" variable, how do I specify the LLM temperature, model ARN and AWS Knowledge Base?

Would really appreciate any help on this. Many thanks!


r/awslambda • • Apr 14 '24

struggling with structuring my lambda python 3 application

1 Upvotes

Hey AWS lambda experts

I am a Lambda Python newbie and I am struggling with structuring my application to run correctly on AWS Lambda. So, I am reaching out to the experts as my last resort.

  1. My application is structured (as below) and packaged into a zip file.


app.py

folder_name

├── configs

│   └── mysql_db_configs.py

├── db

│   └── query_executor.py

├── enums

│   └── mysql_config_prop.py

My questions are:

  1. How should I import my dependencies into my app.py file?

  2. If I have an external 3rd-party dependency, how should I include them?

  3. If my handler is located in app.py, what handler value be?


r/awslambda • • Apr 14 '24

Trying to read and write file from S3 in node.js on Lambda

1 Upvotes

Hello,

my simple test code reading from and writing to S3 is:

import * as AWS from 'aws-sdk';

const s3 = new AWS.S3();

exports.handler = async (event) => {
    const bucket = process.env.BUCKET_NAME || 'seriestestbucket';
    const key = process.env.FILE_KEY || 'timeseries.csv';

    const numbers = [1, 2, 3, 4, 5]; // Example data for manual testing

    const mean = numbers.length ? numbers.reduce((a, b) => a + b) / numbers.length : 0;

    const meanKey = key.replace('.csv', '_mean.txt');

    await s3.putObject({
        Bucket: bucket,
        Key: meanKey,
        Body: mean.toString(),
    }).promise();
};

Unfortunately I get the following error even though I have seen on several sites that this should work

{
  "errorType": "Error",
  "errorMessage": "Cannot find package 'aws-sdk' imported from /var/task/index.mjs",
  "trace": [
    "Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'aws-sdk' imported from /var/task/index.mjs",

Thanks for every help


r/awslambda • • Apr 07 '24

How to deploy a RAG-tuned AI chatbot/LLM using AWS Bedrock

1 Upvotes

Hey guys, so I am building a chatbot which uses a RAG-tuned LLM in AWS Bedrock (and deployed using AWS Lambda endpoints).

How do I avoid my LLM from being having to be RAG-tuned every single time a user asks his/her first question? I am thinking of storing the RAG-tuned LLM in an AWS S3 bucket. If I do this, I believe I will have to store the LLM model parameters and the vector store index in the S3 bucket. Doing this would mean every single time a user asks his/her first question (and subsequent questions), I will just be loading the the RAG-tuned LLM from the S3 bucket (rather than having to run RAG-tuning every single time when a user asks his/her first question, which will save me RAG-tuning costs and latency).

Would this design work? I have a sample of my script below:

import os
import json
import boto3
from langchain.document_loaders import PyPDFLoader
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.embeddings import BedrockEmbeddings
from langchain.vectorstores import FAISS
from langchain.indexes import VectorstoreIndexCreator
from langchain.llms.bedrock import Bedrock

def save_to_s3(model_params, vector_store_index, bucket_name, model_key, index_key):
    s3 = boto3.client('s3')
    
    # Save model parameters to S3
    s3.put_object(Body=model_params, Bucket=bucket_name, Key=model_key)
    
    # Save vector store index to S3
    s3.put_object(Body=vector_store_index, Bucket=bucket_name, Key=index_key)

def load_from_s3(bucket_name, model_key, index_key):
    s3 = boto3.client('s3')
    
    # Load model parameters from S3
    model_params = s3.get_object(Bucket=bucket_name, Key=model_key)['Body'].read()
    
    # Load vector store index from S3
    vector_store_index = s3.get_object(Bucket=bucket_name, Key=index_key)['Body'].read()
    
    return model_params, vector_store_index

def initialize_hr_system(bucket_name, model_key, index_key):
    s3 = boto3.client('s3')
    
    try:
        # Check if model parameters and vector store index exist in S3
        s3.head_object(Bucket=bucket_name, Key=model_key)
        s3.head_object(Bucket=bucket_name, Key=index_key)
        
        # Load model parameters and vector store index from S3
        model_params, vector_store_index = load_from_s3(bucket_name, model_key, index_key)
        
        # Deserialize and reconstruct the RAG-tuned LLM and vector store index
        llm = Bedrock.deserialize(json.loads(model_params))
        index = VectorstoreIndexCreator.deserialize(json.loads(vector_store_index))
    except s3.exceptions.ClientError:
        # Model parameters and vector store index don't exist in S3
        # Create them and save to S3
        data_load = PyPDFLoader('Glossary_of_Terms.pdf')
        data_split = RecursiveCharacterTextSplitter(separators=["\n\n", "\n", " ", ""], chunk_size=100, chunk_overlap=10)
        data_embeddings = BedrockEmbeddings(credentials_profile_name='default', model_id='amazon.titan-embed-text-v1')
        data_index = VectorstoreIndexCreator(text_splitter=data_split, embedding=data_embeddings, vectorstore_cls=FAISS)
        index = data_index.from_loaders([data_load])
        
        llm = Bedrock(
            credentials_profile_name='default',
            model_id='mistral.mixtral-8x7b-instruct-v0:1',
            model_kwargs={
                "max_tokens_to_sample": 3000,
                "temperature": 0.1,
                "top_p": 0.9
            }
        )
        
        # Serialize model parameters and vector store index
        serialized_model_params = json.dumps(llm.serialize())
        serialized_vector_store_index = json.dumps(index.serialize())
        
        # Save model parameters and vector store index to S3
        save_to_s3(serialized_model_params, serialized_vector_store_index, bucket_name, model_key, index_key)
    
    return index, llm

def hr_rag_response(index, llm, question):
    hr_rag_query = index.query(question=question, llm=llm)
    return hr_rag_query

# S3 bucket configuration
bucket_name = 'your-bucket-name'
model_key = 'models/chatbot_model.json'
index_key = 'indexes/chatbot_index.json'

# Initialize the system
index, llm = initialize_hr_system(bucket_name, model_key, index_key)

# Serve user requests
while True:
    user_question = input("User: ")
    response = hr_rag_response(index, llm, user_question)
    print("Chatbot:", response)

r/awslambda • • Mar 26 '24

Using class not able to fetch the data inside the s3 buckt

Post image
1 Upvotes

Hi guys

The below boto3 python code needs to retrieve the files inside the s3 bucket, but it's only giving output for one bucket which is "test-draft-s3".not getting the output for "test-draft2-s3".please tell what I need to do in my code to get the output for both the s3 buckets.


r/awslambda • • Mar 23 '24

How to embed marshalled protobuf message in data field of test kinesis event?

1 Upvotes

I want to test my lambda by triggering some kinesis dummy events. These events containes protobuf message as data. How can I do it? What goes in the data field?
My marshalled data looks like: [10 20 12 11 7 ...]


r/awslambda • • Mar 17 '24

HTML contact form to email

1 Upvotes

Hi, I need help to setup lambda function to send email that trigger by a html contact form,


r/awslambda • • Feb 11 '24

AWS Lambda Tutorial For Beginners | What is AWS Lambda? | AWS Lambda For Beginners

1 Upvotes

r/awslambda • • Feb 10 '24

Request Body missing in Lambda and no idea why

1 Upvotes

Hello,

lambda function code is

"import { DynamoDBClient } from "@aws-sdk/client-dynamodb";

import { PutItemCommand } from "@aws-sdk/client-dynamodb";

const dynamodb = new DynamoDBClient({});

const handler = async (event) => {

try {

// Check if event.body is undefined

if (!event.body) {

throw new Error("Request body is missing");

}

....."

this error is now always thrown. I tried this curl request:

curl -X POST -H "Content-Type: application/json" -d "{\"value\": 123}" APILINK

and also have an app trying a call so I don't think both of the calls are wrong as I also checked them with chatgpt.

ty for any help


r/awslambda • • Feb 09 '24

Trying to access DynamoDB in node.js (fails to download aws-sdk)

1 Upvotes

Pretty much all described in title; I tried "require" and "import" to get the aws-sdk into my node.js code.

Any common pitfalls/tipps?