is there a way to cache values in a lambda by setting global variables with magic functions in Pulumi? Or do I need to resort to packaging lambdas manually?
That should work fine in Pulumi. Pulumi just packages the lambda functions / layers and deploys them. You can do everything in that article via Pulumi.