localstack
localstack copied to clipboard
add context variables and stage variables to API NG context
Motivation
We need a separate context, representing the $context
variables used to render VTL templates, and which is also passed in the payload to AWS_PROXY
integrations.
More informations about $context
here.
https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html#context-variable-reference
It is a bit of duplicated information from the original RestApiInvocationContext
object and the InvocationRequest
, but they serve different purposes.
If we need to update different contexts at the same time, then maybe we could simplify. But we learned that creating those context when needed, collecting informations from different sources, can be pretty hard.
The InvocationRequest
goal is simply to represent the incoming request "as is", with no transformation.
The idea would be to go from InvocationRequest
, get the Resource
. Use the original InvocationRequest
, the Resource
,the ContextVariables
and StageVariables
to construct the IntegrationRequest
and send it down.
The InvocationRequest
will not be mutated. The ContextVariables
will be mutated and populated along the way of the different handlers.
Changes
- add the
ContextVariables
and populate it - add the not yet used
LoggingContextVariables
which can add more data to the logging - add
IntegrationRequest
for future work in integration request handler - add the stage variables and fetch them from the stage
- add small tests to validate we're populate the contexts properly
TODO
What's left to do:
- [x] add unit tests