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달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠