Main¶
CLI entry point and main execution logic for the Lambda handler.
handle ¶
handle(event, context)
Route and execute a Lambda handler function invocation.
This function acts as a router that deserializes the incoming event, loads the appropriate handler, and invokes it with the event payload.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event
|
LambdaEvent
|
The Lambda event containing the handler reference and payload. Must be a dictionary with handler and event fields. |
required |
context
|
LambdaContext
|
The AWS Lambda context object providing runtime information. |
required |
Returns:
| Type | Description |
|---|---|
Optional[JSON]
|
The response from the invoked handler, or None if no response. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the event is not a dictionary type. |
Source code in src/aibs_informatics_aws_lambda/main.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
handle_cli ¶
handle_cli(args=None)
Execute a Lambda handler from the command line interface.
Parses command line arguments to determine the handler to invoke, the event payload, and optionally where to store the response. Supports loading payloads from JSON strings, local files, or S3.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
Optional[Sequence[str]]
|
Optional sequence of command line arguments. If None, uses sys.argv. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If handler or payload cannot be resolved from arguments or environment variables. |
ValueError
|
If response location is specified but invalid. |
Example
handle_cli([
'--handler', 'my_module.MyHandler',
'--payload', '{"key": "value"}',
'--response-location', '/tmp/response.json'
])
Source code in src/aibs_informatics_aws_lambda/main.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |