Function for allowing to pass API-Gateway generated api-keys as queryparameter. Allows for some edge-case usage.
This allows for the following usage with AWS API-key managing:
https://some-url/prod/transaction?apikey=some-api-key
# Install dependency in lambda function
npm i @adneovrebo/api-gateway-apikey-query-authorizer
// In your authorizer lambda function add the following
import apiKeyQueryAuthorizer from '@adneovrebo/api-gateway-apikey-query-authorizer';
exports.handler = apiKeyQueryAuthorizer;
# ZIP content and deploy lambda function with aws-cli (or any other way you like)
zip -r authorizer.zip . && aws lambda update-function-code --function-name <FunctionName> --zip-file fileb://authorizer.zip
-
Go to settings and select
API Key Source
to beAUTHORIZER
-
On the selected request select the authorizer and set
API Key Required
totrue
-
Deploy API for changes to take effect.
-
Create usage plans and API keys to the desired API.
Happy coding 🎉