r/awslambda • • Apr 15 '22

Please help me regarding the node JS incompatibility issue

Thumbnail
reddit.com
2 Upvotes

r/awslambda • • Apr 10 '22

Lambda function to split pdf file in s3 bucket and store in s3 bucket

2 Upvotes

I want to write an AWS Lambda function that:

Takes pdf file from s3 bucket -> splits the pdf file -> Stores split files to S3 bucket.
I am using PyPDF module, so need to know how I can use it in aws lambda function as well.

The code to split pdf files:

import os from PyPDF2 import PdfFileReader, PdfFileWriter  
pdf_file_path = 'filename.pdf' 
file_base_name = pdf_file_path.replace('.pdf','') 
output_folder_path = os.path.join(os.getcwd(), 'output')  
pdf = PdfFileReader(pdf_file_path)  
for page_num in range(pdf.numPages):     
    pdfWriter = PdfFileWriter()     
    pdfWriter.addPage(pdf.getPage(page_num))      

    with       open(os.path.join(output_folder_path,'{0}_Page{1}.pdf'.format(file_base_name,page_    num+1)), 'wb') as f:         
    pdfWriter.write(f)         
    f.close() 

What should be my lambda function for this?(The code)


r/awslambda • • Apr 01 '22

Lambda to write to Timestram

2 Upvotes

Hi everyone I'm trying to set up a lambda to write the content of a sample data set file from like a S3 bucket to Timestream at reguralbintervals just for testing and do some experimentation with quicksight too . Can anyone point me in the right direction the Aws material on Timestream ingestion methods is giving me a headache , a simple tutorial somewhere would be amazing if there are any.

Thank you !


r/awslambda • • Mar 25 '22

Any good sources to learn how to do data transformation using aws lambda?

2 Upvotes

I want to transform data in a dynamodb (dynamodb json) to a csv file using lambda. Where can i find how to do that or what should i do to learn transforming such data?


r/awslambda • • Mar 14 '22

Analyzing AWS Lambda and GraalVM

Thumbnail self.aws
2 Upvotes

r/awslambda • • Mar 07 '22

What problem are you trying to solve with Lambdas?

2 Upvotes

And has it been a success?


r/awslambda • • Feb 15 '22

Need help with chromedriver error in lambda

2 Upvotes

I am getting error

"Message: Service /opt/chromedriver unexpectedly exited. Status code was: 127

Looks like this error comes up when there is a mismatch between chromedriver and chromium versions. But my versions are the same. I even tried a different version and still got the same error. what am i missing?

chromium version (used stable version)

chromedriver version

They are both version 86 so how come I am still getting this error? Ive been stuck here for so long.

Edit: using python 3.8 and latest version of selenium(tried it with selenium 3.8 because thats what one stackoverflow post was suggesting)


r/awslambda • • Feb 09 '22

Serverless on AWS Lambda with Micronaut + Kotlin + Graal VM

Thumbnail
medium.com
2 Upvotes

r/awslambda • • Jan 06 '22

One handler per function or handler routing?

2 Upvotes

Hi all, currently working with lambdas in my company and are having a discussion about implementation, hoping for some more inputs.

I was under the impression it should be one handler per function, so createPost has a handler, editPost a handler (coming from sqs). To me, having a single handler and then a switch case is leaning into a monolithic approach vs microservice. The argument against is that it reduces code duplication (my counter is we can use layers for this)

Any thoughts/opinions would be massively welcome, thanks.


r/awslambda • • Jan 02 '22

How to create a chrome profile programmatically in aws lambda?

2 Upvotes

My objectives:

  1. Scrape a website using Python,Selenium,Chrome

  2. Capture the scraped information into excel file using pandas

  3. Store the excel file in AWS EC2

  4. Periodically(Daily once) run the scraper script using AWS Event Bridge

I have developed the code for my objective 1&2 ,it's working fine in my local

When i tried to add the code to AWS lambda ,it's not working

I have provided detail description in the below post

https://stackoverflow.com/questions/70553894/how-to-create-a-chrome-profile-programmatically-in-aws-lambda


r/awslambda • • Dec 28 '21

Upload to S3 with AWS lambda.

2 Upvotes

hey,

I am very new to AWS. I am working on a DE project. in this project, I am getting data from an online static link that spits out JSON.

I want to get that data, convert it to CSV, and upload it to the AWS S3 bucket. I also want to run this lambda function every 15 days.

I am trying to do this by following https://www.youtube.com/watch?v=vXiZO1c5Sk0 for some reason had no luck

here is my code;-https://github.com/Mandeepsingh666/lambda_aws/blob/main/lambda.py

I have attached the IAM role that has AmazonS3FullAccess, AWSLambdaBasicExecutionRole policies

I have attached some screenshots of the output.

can some help me ?


r/awslambda • • Dec 20 '21

Executing SSM Document from boto3 with input

2 Upvotes

So I am trying to execute a lambda function from a python Lambda. The Lambda function takes some input, does some validation, gathers some additional information, and then the intent is, given that certain criteria are met, it executes a SSM document with ssm.send_command, passing in some data that will be used inside the ssm document.

Essentially what I want to do is shim some data into the execution of the existing SSM document, so that as it executes, it has access to data that has been sorted out in Lambda.

How I had been trying to launch the SSM is as follows:

    response = ssm.send_command(
        InstanceIds=targetInstances,
        DocumentName=ssmDocument,
        DocumentVersion='$DEFAULT',
        Parameters={"instance" : [instance]}
        )

instance as it exists in the execution of the lambda is just a dictionary

Really having some issues trying to figure out how to properly pass this in. I have tried various iterations on this, including

Parameters=json.dumps({"instance" : instance})

Parameters={"instance" : json.dumps(instance)}

etc.

I know that there are also different parameter types, like String, StringMap, etc.

I have a feeling it something to do with the SSM document itself, judging by examples here: https://docs.aws.amazon.com/systems-manager/latest/userguide/document-schemas-features.html

I see there is an "InputPayload" that references the pre-defined parameters. I'm just having trouble passing parameter validation when executing send_command. From there, the document, even if I run it manually, is currently just supposed to take the input parameters and write them to a file - thats not happening either and I'll need to tackle that as well, but really at the moment trying to figure out what I need to do to trigger this ssm document with some parameters in json / dictionary format.

Edit:

This is all worked out now. Had the right idea from the get go, but the final solution was:

Parameters={"instance" : [json.dumps(instance)]}

r/awslambda • • Nov 16 '21

Trying to do a prefix matching in s3 BOTO3

2 Upvotes

I'm trying to do a prefix matching of a file uploaded or a file that exists. so for ex: if there's a file that's called random_123 then go look for a folder with the name 'random' in a different s3 bucket and retrieve all the files based on the count The partition key would be '_' (underscore) so for ex: If i upload a file named Random_dataset inside one bucket, Look for a subsequent folder in a different s3 bucket named 'Random' which already has a few files inside (based on the count of the files). Below is the code i've written so far. Need assistance on how I could proceed further.

import boto3
s3 = boto3.resource('s3')
def lambda_handler(event, context):
empty_list=[""]
i=0
bucket = s3.Bucket('bucket-name')
count_obj=0
for obj in bucket.objects.filter(Prefix='folder-name/'):
    print(obj.key)
    empty_list.append(str(obj.key))
    i=i+1
    count_obj = count_obj + 1
print(count_obj)
print(empt_list)

r/awslambda • • Nov 09 '21

Deploying Lambda Layers using AWS CDK.

2 Upvotes

r/awslambda • • Oct 20 '21

Tokens expiring in AWS lambda function

2 Upvotes

I was reading the best practices and this part seemed important:

Initialize SDK clients and database connections outside of the function handler (...)

(https://docs.aws.amazon.com/lambda/latest/dg/best-practices.html)

I wrote some code that initializes SDK clients outside the handler, as that doc told me. Part of the SDK initialization includes fetching a token, which has an expiration, so the first few invocations of my lambda work as expected, but then after the expiration I'm not re-fetching the token.

A few things come to mind:

A) I could simply disregard the best practices and get the token inside the handler.

B) Find a way to "cold start" the whole function at an interval that's shorter than the expiration time.

Any thoughts on this? I'm not seeing an obvious way to cold start at a set interval. There are probably other ways to deal with this, but I'm not very experienced in lambda, so I thought I would ask.

Thanks!


r/awslambda • • Jul 20 '21

Can't deploy functions anymore, from management console

2 Upvotes

I've never had this problem since I started using Lambda earlier this year.

Now for some reason every time I try to Deploy I get this error:

It doesn't give any explanation, and I can't update my functions... It's not related to the kind of changes I made to the code, even just adding a comment won't work. It just doesn't let me...

I tried logging off and in again, I tried reloading the whole browser.

This looks like a bug on AWS part, is it? Can I report it someway?

(the problem persists even changing region)


r/awslambda • • Jul 17 '21

how to ddeploy pupeteer lambda function on aws

2 Upvotes

i have a function which uses pupetter. pupteer unzipped is more than 260mb. how to get this done?


r/awslambda • • Jun 29 '21

Put a Stop to Data Swamps with Event-Driven Data Testing!

2 Upvotes

Without proper testing and governance, your data lake can easily turn into a data swamp.

This article looks at how to build automated data tests that will be executed any time new data is loaded to a data lake.

Learn more: https://dashbird.io/blog/data-swamps-event-driven-data-testing/


r/awslambda • • Jun 24 '21

I want my lambda code to directly upload files into an s3 bucket of a different account

2 Upvotes

So I have a lambda function that triggers a sagemaker processing job and this job currently writes a few files to my s3 bucket. I have mentioned my output_uri ='s3://outputbucket-in-my-acc/' Now I want the same files to be directly uploaded to a different AWS account and not in my account. How do i achieve this? I want no traces of the file to be stored in my account.

I found a similar solution here but this copies the file into the different account while the original files are still present in the source account: AWS Lambda put data to cross account s3 bucket


r/awslambda • • Jun 18 '21

Machine learning model deployment

2 Upvotes

I am using AWS to store data from different sensors. I want to apply a machine learning model on every object of the data after being stored. I will train the model locally and export only the model.

Is it possible to make a lambda function to get the object, apply the model on it and store the prediction results?


r/awslambda • • May 28 '21

Serverless Stonks checker app for Wall Street Bets: week 3 activity report

2 Upvotes

A few weeks ago we set up an #API to monitor hot stocks via the Wall Street Bets subreddit. Since then we've seen quite a lot of activity in the app.

In this article, we're showing you some interesting findings: https://dashbird.io/blog/serverless-stonks-checker-activity-report/


r/awslambda • • May 22 '21

RDS stop and start for cost saving

2 Upvotes

Hi All..

I had set a lambda function to stop and start rds. But the problem is in aws there is a limitation to stop a db instance that has a read replica. Anybody have an idea for this??


r/awslambda • • May 18 '21

Lambda Edge dev tools

2 Upvotes

I’m new to developing web with Lambda Edge and I was wondering what tooling you guys recommend, what’s your routine for dev and how you locally develop your functions?


r/awslambda • • Apr 20 '21

Curious about data lakes to data science?

2 Upvotes