Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass parameters to AWS Lambda function

I know that it is possible to pass parameters to a Java program running on AWS Lambda in order to test it. But I do not know how to pass those parameters if this program gets called by a schedule event.

Does anyone know if this is possible? If yes, how? I was not able to find anything about it.

Thanks in advance

like image 326
EllisTheEllice Avatar asked Jan 06 '16 12:01

EllisTheEllice


People also ask

Can Lambda use parameter store?

You can store parameter data as Lambda environment variables as part of the function's version-specific configuration.

How do you pass parameters to step functions?

Step Functions paths use JsonPath syntax. To specify that a parameter use a path to reference a JSON node in the input, end the parameter name with . $ . For example, if you have text in your state input in a node named message , you could pass that to a parameter by referencing the input JSON with a path.

How do you use input in Lambda function?

The lambda function always generates 0, and it doesn't care about the input argument, so the input argument can be represented using _ .


2 Answers

You can create a CloudWatch rule as a schedule and configure target's input as a constant json value:

CloudWatch -> Events -> Rules -> Schedule -> Targers

Set Configure input as Сonstant (JSON text) and pass any valid json-data there.

In Lambda you can access constant input as an input object.

AWS CloudWatch screenshot

like image 88
Sergey Nikitin Avatar answered Sep 22 '22 15:09

Sergey Nikitin


You could leverage the environment variables from the lambda configuration. Then you read them on your Java program with:

System.getenv("VAR_NAME")
like image 28
Diogo Eichert Avatar answered Sep 18 '22 15:09

Diogo Eichert