I have tried to look throught the internet, but none of the solutions seem to work for me in python. Basicly I want to transfer some parameters from one lambda function to the next lambda function in a step function. I was a bit surprised how hard it is to find a simple example of how to do this?
So my first lambda function has an output like:
return {"user_name" : user_name, "region" : region, "instance_id" : instance_id}
And my second lambda function tries to import with:
user_name = event["user_name"]
region = event["region"]
instance_id = event["instance_id"]
My stepfunction looks like:
{
"StartAt": "CreateEC2Instance",
"States": {
"CreateEC2Instance": {
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke",
"Parameters": {
"FunctionName": "MY_ARN_1",
"Payload": {
"region": "eu-central-1",
"user_name": "MY_USERNAME"
}},
"Next": "AttachEFStoEC2"
},
"AttachEFStoEC2": {
"Type": "Task",
"Resource":"MY_ARN_2",
"End": true
}
the error is:
{
"error": "KeyError",
"cause": {
"errorMessage": "'user_name'",
"errorType": "KeyError",
"stackTrace": [
" File \"/var/task/lambda_function.py\", line 7, in lambda_handler\n user_name = event[\"user_name\"]\n"
]
}
}