Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I uniquely ID the AWS Lambda container that my function is running in?

I would like to get the (AWS Lambda container) instance ID that my function is running in.

For now I would just log it - it would help me when debugging issues with my caching algorithm: I could identify which invocations were happening in the same instance.

I looked at the docs for the context object and don't see anything there.

I could do it manually - and I'll put that below as my fallback answer - but I thought I would check whether some sort of real instance ID is available somehow.

like image 310
Tom Avatar asked Apr 04 '17 17:04

Tom


People also ask

Does Lambda run in a container?

Lambda supports only Linux-based container images. Lambda provides multi-architecture base images. However, the image you build for your function must target only one of the architectures. Lambda does not support functions that use multi-architecture container images.

How do you find the output of a Lambda function?

The simplest way to see logs from your AWS lambda function is in the console. Navigate to the monitoring tab of your lambda function and click the “view logs in CloudWatch” button. You should now be inside CloudWatch viewing your log output.

What is a resource that you can invoke to run a code in AWS Lambda?

You can invoke Lambda functions directly using the Lambda console, a function URL HTTP(S) endpoint, the Lambda API, an AWS SDK, the AWS Command Line Interface (AWS CLI), and AWS toolkits.

What is AWS Lambda running on?

AWS Lambda natively supports Java, Go, PowerShell, Node. js, C#, Python, and Ruby code, and provides a Runtime API which allows you to use any additional programming languages to author your functions. Please read our documentation on using Node. js, Python, Java, Ruby, C#, Go, and PowerShell.


1 Answers

Could just generate a random GUID save that in global. (I'm just starting to look at this issue of container re-use and the potential for data caching, but I assume that node's 'global' object remains intact when an instance is re-used.)

like image 61
Tom Avatar answered Oct 04 '22 07:10

Tom