使用 AWS re:Post 即表示您同意 AWS re:Post 使用條款

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 個回答
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
已回答 4 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南