Check if AWS Lambda is under execution right now using boto3 - python-3.x

I have a requirement that I need to check if a specific lambda is currently under execution or not using another lambda.
I went through boto3 documentation and found get_function() method returns State of the function, But this doesn't return function state, It gives State that if Lambda creation is Pending/Inactive/Active, etc.
Is there a way I can find out if the function state of lambda using another lambda?
Any help or guidance is appreciated.
Documentation Link
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/lambda.html#Lambda.Client.get_function

You can use CloudWatch metrics of your lambda function to determine whether it's currently being invoked. https://docs.aws.amazon.com/lambda/latest/dg/monitoring-metrics.html#monitoring-metrics-types

Related

sonarqube and aws lambda

I recently enabled sonarqube for my lambda functions.
Now as we all know, for any lambda_handler this is the standard process. However all the logics are stated and based on event not much on context.
def lambda_handler(event, context):
Now after running the sonarqube scan, I'm getting:
Remove the unused function parameter "context".
I'm getting MAJOR issue from the sonarqube for all my lambdas , any suggestion to fix this issue?
My lambdas are Python based.

how to build search functionality with ElasticSearch and lambda function into your existing project

I am having a Node + Express application running on EC2 server and trying to add a new search feature to it. I am thinking about using Lambda function and ElasticSearch. When the client fires a request to update a table in dynamodb, Lambda function will react to this event and update the elastcsearch index.
I know lambda runs serverless whereas my original application runs within a server. Can anybody give me some hints about how to do it or let me know if it's even possible?
The link between a DynamoDB update and a Lambda is "DynamoDB Streams".
The documentation says, in part,
Amazon DynamoDB is integrated with AWS Lambda so that you can create
triggers—pieces of code that automatically respond to events in
DynamoDB Streams. With triggers, you can build applications that react
to data modifications in DynamoDB tables.
If you enable DynamoDB Streams on a table, you can associate the
stream Amazon Resource Name (ARN) with an AWS Lambda function that you
write. Immediately after an item in the table is modified, a new
record appears in the table's stream. AWS Lambda polls the stream and
invokes your Lambda function synchronously when it detects new stream
records.

How to know the status of RDS using Lambda function

I'm using RDS instance and I want to know the status of instance from AWS Lambda function written in Node.js
You can use the describeDBInstances() method of the AWS SDK for Node.js. List of instance statuses can be found here: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.DBInstance.Status.html

lambdas fail to log to CloudWatch

Situation - I have a lambda that:
is built with Node.js v8
has console.log() statements
is triggered by SQS events
works properly (the downstream system receives all messages, AWS X-Ray can see those executions)
Problem:
this lambda does not log anything!
But if the same lambda is called manually (using "Test" button) - all logging statements are visible in CloudWatch.
My lambda is based on this tutorial: https://www.jeremydaly.com/serverless-consumers-with-lambda-and-sqs-triggers/
A very similar situation occurs if the lambda was called from within another lambda (recursion). Only the first lambda logs stuff (started manually), but every next lambda in the recursion chain does not log anything.
an example can be found here:
https://theburningmonk.com/2016/04/aws-lambda-use-recursive-function-to-process-sqs-messages-part-1/
any idea how to tackle this problem will be highly appreciated.

Is there is any way to pass the timeout value for aws lambda function programmatically?

I am working on getting snapshot API using aws lambda. I wan to pass the timeout value for lambda function depends on number of snapshots to be taken. So, Is there is any way to pass the timeout value to aws function runtime?
As far as I'm aware you cannot set the timeout function dynamically for each invocation. Is there a reason you aren't just setting the timeout high, and relying on the function to properly exit when it is finished?

Resources