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 Resposta
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
respondido há 4 meses

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas