'Python in AWS Lambda giving indent error on line that doesn't even exist
I'm trying to setup a simple aws lambda function and no matter what python I put in the function it's returning an error on a line that's not even in the function.
What I started with:
def hello(event, context):
print("hi i")
return "hello-world"
What I"m at now:
def hello(event, context):
pass
No matter what the body of the function is, when I test it I get this error:
Response:
{
"errorMessage": "Syntax error in module 'handler'"
}
Request ID:
"6071965c-b7ad-4a9f-aa10-7a81980388f0"
Function logs:
START RequestId: 6071965c-b7ad-4a9f-aa10-7a81980388f0 Version: $LATEST
Syntax error in module 'handler': unindent does not match any outer indentation level (handler.py, line 4)
END RequestId: 6071965c-b7ad-4a9f-aa10-7a81980388f0
REPORT RequestId: 6071965c-b7ad-4a9f-aa10-7a81980388f0 Duration: 0.36 ms Billed Duration: 1 ms Memory Size: 1024 MB Max Memory Used: 36 MB
The function I have now, just "pass" doesn't even have 4 lines, how could it be throwing this error? I'm using Python 2.7 Runtime.
Thank you!
Solution 1:[1]
Try changing
def hello(event, context):
to
def lambda_handler(event, context):
and rename your file from handler.py to lambda_function.py
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | alexdabest |