Reputation: 4623
I have created a lambda function to convert a file on S3 and put the new converted file back to S3, the lambda function is triggered by rest api on api gateway. What I want to do is to reply the client by that same converted file when accessing the same endpoint. The option that I have in my mind is to return the file from lambda, which may not be a time optimized solution. My question is there another possible solution ? like calling the lambda function and forward the request to the created object in S3 ? I thought of forwarding one api resource to another one which will read from S3 directly, is it possible somehow ?
Upvotes: 1
Views: 458
Reputation: 10101
You probably want to return a pre-signed S3 url for the file you've just created, which the client can then follow (at most once, and for a limited time), to download that file directly from S3. The general documentation is here, but there will probably be a helper for it in an SDK for whatever language you're using.
Remember that API Gateway has a maximum timeout of 29 seconds. This is probably fine if you're just moving small amounts of data around in S3, but it's worth being aware of!
Upvotes: 2