Skip to content

Have two integrations for the single API Gateway call - S3 put object or lambda

0

Hi we have created AWS API Gateway which integrates to S3 put object using Integration type as AWS Service S3 Put using VTL in integration mapping to create the unique S3 Path

Now we want to dynamically decide the Integration Type either as AWS Service S3 Put or Lambda Function depending upon the request size. For example, if request body size is more than 5 MB do AWS Service S3 Put and if size is less than 5 MB do AWS Lambda Invocation

Is it possible to have dynamic integration ?

2 Answers
0

No. It is not possible. Once you decide on an integration, it will be used until you change it. You can use Stage variables, so different stages will go to different versions or aliases, but not what you are asking for.

Why would you invoke a Lambda function if it is smaller than 5 MB? Why not go to S3 for all sizes?

AWS
EXPERT
answered 2 years ago
  • For smaller sizes we can process the api within gateway time limits, so we were thinking of returning the response directly to user for better user experience.

    Currently we return the link to check the status of job, so users have to do two calls.

0

Hello @Sumeet

Good day.

Can you please share details how you have achieve below. I am struggling with the same problem.

Hi we have created AWS API Gateway which integrates to S3 put object using Integration type as AWS Service S3 Put using VTL in integration mapping to create the unique S3 Path

answered 2 years ago
  • We skipped the S3 integration and VTL stuff and we gzipped the request to get more data. Depending upon size of gzip request we are processing the data directly in lambda or putting it in S3 for background processing

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.