You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A deployed _proxy-lambda_ should return _OK_ or time out waiting for a response if you run it with a test event from the AWS console. Check CloudWatch logs for a detailed execution report.
121
+
A deployed _proxy-lambda_ should return _OK_ or time out waiting for a response if you run it with a test event from the AWS console.
122
+
Check CloudWatch logs for a detailed execution report.
119
123
120
124
### Debugging
121
125
@@ -127,8 +131,8 @@ __Pre-requisites:__
127
131
128
132
__Launching the local lambda:__
129
133
- start the _runtime-emulator_ in the terminal as a binary or with `cargo run`
130
-
-run [env-lambda.sh](env-lambda.sh) in a terminal window on your local machine
131
-
- start your lambda in the same terminal window with `cargo run`
134
+
-add environmental variables from the prompt printed by the _runtime-emulator_ to the lambda terminal
135
+
- start your lambda with `cargo run`
132
136
133
137

134
138
@@ -139,13 +143,13 @@ __Debugging:__
139
143
140
144
__Success, failure and replay:__
141
145
142
-
- successful responses are sent back to the caller if the response queue is configured
146
+
- successful responses are sent back to the caller if the response queue is configured (`proxy_lambda_resp`)
143
147
- panics or handler errors are not sent back to AWS
144
148
- the same incoming SQS message is reused until the lambda completes successfully
145
-
-_runtime-emulator_ deletes the incoming message (request) when the local lambda completes successfully
146
-
-_proxy-lambda_ deletes the outgoing message (response) after forwarding it to the caller
147
-
-_proxy-lambda_clears the response queue before forwarding a request
148
-
-purge the request queue manually to delete stale requests
149
+
-_runtime-emulator_ deletes the request message from `proxy_lambda_req` queue when the local lambda completes successfully
150
+
-_proxy-lambda_ deletes the response message from `proxy_lambda_resp` queue after forwarding it to the caller, e.g. to API Gateway
151
+
-_proxy-lambda_purges `proxy_lambda_resp`queue before sending a new request to `proxy_lambda_resp`
152
+
-you have to purge `proxy_lambda_req` queue manually to delete stale requests
149
153
150
154
If the local lambda fails, terminates or panics, you can make changes to its code and run it again to reuse the same incoming payload from the request queue.
151
155
@@ -162,26 +166,36 @@ Provide these env vars to _proxy-lambda_ and _runtime-emulator_ if your queue na
162
166
163
167
### Late responses
164
168
165
-
Debugging the local lambda may take longer than the AWS service is willing to wait. For example, _proxy-lambda_ function can be configured to wait for up to 15 minutes, but the AWS API Gateway wait time is limited to 30 seconds. If a response from the local lambda arrives after 5 minutes, the _proxy-lambda_ can still forward it to the API Gateway, but that service would already time out. You may need to re-run the request for it to complete successfully end-to-end.
169
+
Debugging the local lambda may take longer than the AWS service is willing to wait.
170
+
For example, _proxy-lambda_ function can be configured to wait for up to 15 minutes, but the AWS API Gateway wait time is limited to 30 seconds.
171
+
172
+
Assume that it took you 5 minutes to fix the lambda code and return the correct response.
173
+
If _proxy-lambda_ was configured to wait for that long it would still forward the response to the API Gateway which timed out 4.5 min earlier.
174
+
In that case, you may need to trigger another request for it to complete successfully end-to-end.
166
175
167
176
### Not waiting for responses from local lambda
168
177
169
-
It may be inefficient to have _proxy-lambda_ waiting for a response from the local lambda.
178
+
It may be inefficient to have _proxy-lambda_ waiting for a response from the local lambda because it takes too long or no response is necessary.
179
+
Both _proxy-lambda_ and _runtime-emulator_ would not expect a response if the response queue is inaccessible.
170
180
171
181
Option 1: delete _proxy_lambda_resp_ queue
172
182
173
-
Option 2: add `PROXY_LAMBDA_RESP_QUEUE_URL` env var with no value to instruct _proxy-lambda_ and _runtime-emulator_ to not wait for the local lambda response
183
+
Option 2: add `PROXY_LAMBDA_RESP_QUEUE_URL` env var with no value to _proxy-lambda_ and _runtime-emulator_
174
184
175
-
Option 3: make _proxy_lambda_resp_ queue inaccessible by changing its IAM policy. E.g. change the resource name from the correct queue name `"Resource": "arn:aws:sqs:us-east-1:512295225992:proxy_lambda_resp"` to `"Resource": "arn:aws:sqs:us-east-1:512295225992:proxy_lambda_resp_BLOCKED"`.
176
-
Both, _proxy-lambda_ and _runtime-emulator_ treat the access error as a hint to not expect a response.
185
+
Option 3: make _proxy_lambda_resp_ queue inaccessible by changing its IAM policy.
186
+
E.g. change the resource name from the correct queue name `"Resource": "arn:aws:sqs:us-east-1:512295225992:proxy_lambda_resp"` to a non-existent name like this `"Resource": "arn:aws:sqs:us-east-1:512295225992:proxy_lambda_resp_BLOCKED"`.
187
+
Both _proxy-lambda_ and _runtime-emulator_ treat the access error as a hint to not expect a response.
177
188
178
189
### Canceling long _proxy-lambda_ wait
179
190
180
-
Send a random message to the response queue via the AWS console to make _proxy-lambda_ exit and become available for a new request.
191
+
If your _proxy-lambda_ is configured to expect a long debugging time, e.g. 30 minutes, you may want to cancel the wait for a rerun.
192
+
Since it is impossible to kill a running lambda instance on AWS, the easiest way to cancel the wait is to send a random message to `proxy_lambda_resp` queue via the AWS console.
193
+
The waiting _proxy-lambda_ will forward it to the caller and become available for a new request.
181
194
182
195
### Large payloads and data compression
183
196
184
-
The size of the SQS payload is [limited to 262,144 bytes by SQS](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/quotas-messages.html). To get around this limitation _proxy-lambda_ and _runtime-emulator_ compress oversized payloads using [flate2 crate](https://crates.io/crates/flate2) and send it as an encoded Base58 string. The encoding/decoding happens automatically at both ends.
197
+
The size of the SQS payload is [limited to 262,144 bytes by SQS](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/quotas-messages.html) while [Lambda allows up to 6MB](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html).
198
+
_proxy-lambda_ and _runtime-emulator_ compress oversized payloads using [flate2 crate](https://crates.io/crates/flate2) and send them as an encoded Base58 string to get around that limitation.
185
199
186
200
The data compression can take up to a minute in debug mode. It is significantly faster with release builds.
0 commit comments