I created the following lambda function and its given me the following error. I am new to Python and I dont think there’s anything missing in the function. can someone please help to make this function work? Thanks
JavaScript
x
30
30
1
import logging
2
import json
3
import boto3
4
5
client = boto3.client('workspaces')
6
7
def handler(event, context):
8
response = create_workspace()
9
return event
10
11
def create_workspace():
12
response = client.create_workspaces(
13
Workspaces=[
14
{
15
'DirectoryId': 'd-9767328a34',
16
'UserName': 'Ken',
17
'BundleId': 'wsb-6cdbk8901',
18
'WorkspaceProperties': {
19
'RunningMode': 'AUTO_STOP'
20
},
21
'Tags': [
22
{
23
'Key': 'Name',
24
'Value': 'CallCentreProvisioned'
25
},
26
]
27
},
28
]
29
)
30
Execution result
JavaScript
1
7
1
{
2
"errorMessage": "Handler 'lambda_handler' missing on module 'lambda_function'",
3
"errorType": "Runtime.HandlerNotFound",
4
"requestId": "a09fd219-b262-4226-a04b-4d26c1b7281f",
5
"stackTrace": []
6
}
7
Advertisement
Answer
Very simple. Rename handler
to lambda_handler
, or change your lambda configuration to use the handler called handler
rather than lambda_handler
. There were comments that mentioned this, but no simple answer given.
There is no good reason to nest the function as the other answer seems to suggest.