Two issues:
the python function was wrongly defined
the main handler for Lambda requires 2 arguments
Answer:
def hello_world(event_data, lambda_config):
print "hello world"
For more information on the arguments for the main handler, read http://docs.aws.amazon.com/lambda/latest/dg/python-programming-model-handler-types.html
Excerpt:
Use the following general syntax structure when creating a handler function in Python.
def handler_name(event, context):
...
return some_value
In the syntax, note the following:
- event – AWS Lambda uses this parameter to pass in event data to the handler. This parameter is usually of the Python dict type. It can also be list, str, int, float, or NoneType type.
- context – AWS Lambda uses this parameter to provide runtime information to your handler. This parameter is of the LambdaContext type.
- Optionally, the handler can return a value. What happens to the returned value depends on the invocation type you use when invoking the Lambda function: If you use the RequestResponse invocation type (synchronous execution), AWS Lambda returns the result of the Python function call to the client invoking the Lambda function (in the HTTP response to the invocation request, serialized into JSON). For example, AWS Lambda console uses the RequestResponse invocation type, so when you test invoke the function using the console, the console will display the returned value. If the handler does not return anything, AWS Lambda returns null. If you use the Event invocation type (asynchronous execution), the value is discarded.
Testing a Python Lambda function returns Hello World when I expect an error?
AWS Lambda + Serverless Framework + Python – A Step by Step “Hello World”
I recommend this framework. I’ve used it in prod and had good results
More on reddit.comSo what does a well-made AWS Lambda in Python actually look like?
AWS Lambda + Serverless Framework + Python – A Step by Step “Hello World”
Looks great! I'm going to give it a crack later today.
More on reddit.comTwo issues:
the python function was wrongly defined
the main handler for Lambda requires 2 arguments
Answer:
def hello_world(event_data, lambda_config):
print "hello world"
For more information on the arguments for the main handler, read http://docs.aws.amazon.com/lambda/latest/dg/python-programming-model-handler-types.html
Excerpt:
Use the following general syntax structure when creating a handler function in Python.
def handler_name(event, context):
...
return some_value
In the syntax, note the following:
- event – AWS Lambda uses this parameter to pass in event data to the handler. This parameter is usually of the Python dict type. It can also be list, str, int, float, or NoneType type.
- context – AWS Lambda uses this parameter to provide runtime information to your handler. This parameter is of the LambdaContext type.
- Optionally, the handler can return a value. What happens to the returned value depends on the invocation type you use when invoking the Lambda function: If you use the RequestResponse invocation type (synchronous execution), AWS Lambda returns the result of the Python function call to the client invoking the Lambda function (in the HTTP response to the invocation request, serialized into JSON). For example, AWS Lambda console uses the RequestResponse invocation type, so when you test invoke the function using the console, the console will display the returned value. If the handler does not return anything, AWS Lambda returns null. If you use the Event invocation type (asynchronous execution), the value is discarded.
change your python syntax into
def event_handler(event,context):
message = "hello{0}".format(event['world'])
return mesaage
here event always like dictionary type object and Context is lambda context