This was working before! Perhaps AWS changed something in the Lambda runtime, or I didn't test things well enough. Regardless, I moved the initialization of the IO into static areas, following these best practices:
Limit the re-initialization of variables/objects on every invocation. Instead use static initialization/constructor, global/static variables and singletons. Keep alive and reuse connections (HTTP, database, etc.) that were established during a previous invocation.
Additionally, I'm no longer switching the original stdout/stderr back. These stay re-assigned for the duration of the lambda lifetime. However, I am still printing to the original stderr/stdout so that data appears in cloudwatch logs.
This was working before! Perhaps AWS changed something in the Lambda runtime, or I didn't test things well enough. Regardless, I moved the initialization of the IO into static areas, following these best practices:
Additionally, I'm no longer switching the original stdout/stderr back. These stay re-assigned for the duration of the lambda lifetime. However, I am still printing to the original stderr/stdout so that data appears in cloudwatch logs.