API Gateway has same integration parameters for all routes

0

Hello,

I build an API Gateway with a Lambda Integration. I need that the gateway to add HTTP parameters, transparent for the users (on the server side), for each route. I see that this can be done using Request parameter mapping from Manage Integration screen. But these parameters are the same for all routes in one API, and unique for the API Lambda Integration, as you can see below.

/route1 POST - Lambda1 Request parameter mapping: querystring.tableName->table1
/route2 POST - Lambda1 Request parameter mapping: querystring.tableName->table1

Is there a workaround to add different parameters for different routes (like below: table2), or the only way is to add the parameters from the client side (URL query parameters) ?

/route1 POST - Lambda1 Request parameter mapping: querystring.tableName->table1
/route2 POST - Lambda1 Request parameter mapping: querystring.tableName->table2

Thank you,
Mihai

1 Answer
0

You're correct. API Gateway's request parameter mapping at the integration level is indeed limited to a global scope for all routes within an API. While there's no direct way to achieve route-specific parameter mapping at the API Gateway level, here are some potential workarounds:

1/ Lambda Function Logic -- > Leverage Path Parameters: If you have control over the route paths, you can use path parameters to differentiate requests.

Example: /route1/{tableName} and /route2/{tableName} .In your Lambda function, extract the tableName from the path parameters and use it accordingly.

2/ Use API Gateway Method Request: While not ideal for large-scale scenarios, you can manually add query string parameters to the method request for each route. This approach can be tedious for multiple routes.

Hope it helps.

profile pictureAWS
cloudyy
answered 2 months ago

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.

Guidelines for Answering Questions