Reputation: 5550
I have a resolver template that I use across several AppSync APIs using the Serverless framework. The same resolver template is deployed to each of my dev, stage, and production APIs.
I have a situation where this resolver template needs to know which AppSync API is calling it (dev, test, or production). I've checked out the docs but didn't see any variables that would help.
Is there a way for the resolver to be aware of which AppSync API is invoking it without resorting to custom headers passed from the client?
Upvotes: 0
Views: 25
Reputation: 8474
Although the stage isn't directly included in the params
(first argument) your lambda function is invoked with, you can infer it by looking at the value of params.request.headers.host
.
This will have the full url that your API was called with (for example: abcdefgh.appsync-api.eu-west-1.amazonaws.com
). Given that these are effectively constant, you can relate them back to your stage.
Upvotes: 1