Serverless service which showcases how to build an API which is accessible through an API key.
Make sure that you use Serverless v1.
- Run
serverless install --url https://github.com/pmuens/serverless-secured-api
to install the service in your current working directory - Next up cd into the service with
cd serverless-secured-api
- Deploy with
serverless deploy
Simply perform a request against the exposed endpoint:
This request should return Forbidden
:
curl https://XXXX.execute-api.region.amazonaws.com/dev/greet
Whereas this one should suceeds:
(you get the API key in the info output after a successfull deployment or if you run serverless info
)
curl https://XXXX.execute-api.region.amazonaws.com/dev/greet --header "x-api-key: <api-key>"
- Lambda
- API Gateway