I need to create aws Lambda (python) from cloudformation. The lambda function was created, but when I tried to execute the lambda, I keep getting the following error. I tried many ways and I just couldn't get it to work.
{
"errorMessage": "Bad handler 'lambda_handler'"
}
This is how I created the lambda from the clouds.
- Create a simple python welcome program containing a print statement (as simple as possible)
the code:
def lambda_handler():
print('lambda_handler is called...');
print('Lambda is printing...');
Replace the python and place it in S3. (I tried both the folder and the folder)
Create a cloud information template with the following resource.
JSON:
"Resources": {
"LF1ZOLJ": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Handler": "lambda_handler",
"Code": {
"S3Bucket": "mybuckname",
"S3Key": "simplepython.zip"
},
"Description": "cfn-create-lambda",
"Role": "arn:aws:iam::305760000000:role/lambda_basic_execution",
"Runtime": "python2.7",
"Timeout": 60
},
"Metadata": {
"AWS::CloudFormation::Designer": {
"id": "xxxxxxxxxxxxxxxxxxxxxxxx"
}
}
}
}
Go to Cloudformation and create a stack using the template. The stack was created successfully.
When I test lambda using Hello World event template. I get an error message.
"errorMessage": "Bad lambda_handler 'handler"
CloudWatch,
lambda_handler: 1 .
. "Hello World" Python. - Lambda, - . Cloudformation.
. .