When you specify the code inline, then the first part of the handler should always be index.
Check out this documentation for more information: AWS::Lambda::Function
Use this:
LambdaFunction:
Type: "AWS::Lambda::Function"
Properties:
Code:
ZipFile: !Sub |
import json
def lambda_handler(event,context):
#Creating delete request
...
Description: Lambda function.
FunctionName: lambda_function
Handler: index.lambda_handler
Role : !GetAtt LambdaExecutionRole.Arn
Runtime: python2.7
Timeout: 5
It should be index.lambda_handler instead of lambda_function.lambda_handler.