Out of date information on how to access function through API
The tutorial's section about accessing a Lambda function through an API gateway is out of date. This needs updating.
Right now @finnhodgkin and I are researching how to actually do this (which is what the current time estimate is for), and once we have worked that out and finished running through the tutorial we will work on updating the tutorial (for which we'll add another time estimate).
Possibly relates to #62
Following this first: http://docs.aws.amazon.com/apigateway/latest/developerguide/getting-started.html
Using the link @finnhodgkin has posted above I have gotten the lambda function running through and API without an API key. Now trying to get it working with an API key. Proving complicated.
Got this working! Will write the basic process here and then when we are done going through the tutorial we will start working on a PR to fix the stuff we've found.
process is as follows:
- make a lamba function (done in prev steps)
- on that function go to "triggers"
- Make an API Gateway trigger
- It will be created with "any" method
- Delete any by selecting it, clicking "actions" and then "delete method"
- create a post method (actions -> create method -> post)
- click on it
- click "method request"
- change "api key required" to true
- click on "stages" on the left
- click "create"
- make a stage with a name of your choice
- go to "usage plans"
- create -> add a name -> you can turn off throttling and rate limiting for the test one if you like
- click next
- add api stage -> choose yr api from dropdown -> choose the stage u just made from the next dropdown -> click rge tick -> next
- create api key + add to usage plan -> give itt a name, let it auto generate -> done
- on the left go to api keys
- click yr api key
- click "show" next to api key
- take a note of yr key
- deploy your api (apis -> your api -> actions -> deploy)
- copy the invoke url and add your endpoint to the end of it.
- paste this into postman (or similar)
- set "body" to a json of whatever yr function is expecting
- go to headers and add a header called "x-api-key" with a value of the api key that you noted down earlier.
- send the post request
- see the result of your function
Time estimate of 1hr was too short. still needs to be written up to be put into the readme though.
@ZooeyMiller yeah, T1h was unlikely, please add a revised estimate label for the time you expect to spend as per: dwyl/contributing#revising-a-time-estimate 👍
@nelsonic the initial research has now been completed (in around 2 hours) and I imagine the actual update to the readme as it relates directly to this issue will be between 1 and 2 hours so have added a t4h label to encapsulate this total.