This diagram may look like there is a lot going on but there really isn’t much to it.
Here’s the gist of it:
There is currently a hard 10-second limit on all requests triggered via API Gateway. The problem that this poses is that establishing an IRC connection (joining the channel, etc) unfortunately takes longer than 10 seconds, which results in API Gateway returning a 504 back to the (webhook) caller.
This is not ideal because from the caller’s point-of-view, the webhook failed, which might warrant a retry even though the (triggered) Lambda function happily continued executing.
The asynchronous IRC connection is a nice compromise between returning back to the caller in a timely manner (under a second), and attending to a long running task.
One nice side-effect of using this design is that AWS will retry any failed (asynchronous) Lambda invocations, which means this system could potentially survive brief network outages (if tweaked to do so).