Skip to content

Latest commit

 

History

History
50 lines (31 loc) · 2.77 KB

3-configure-api-gateway.md

File metadata and controls

50 lines (31 loc) · 2.77 KB

Configure Amazon API Gateway

Why

To trigger the execution of our web server lambda function across an internet away, ( tiers of routers away...to be more exact :) ) we need an API that bridges an URL with the lambda functions, and forwarding all parameters attached. This is what Amazon API Gateway is used for in our system.

How

  • Go to Amazon API Gateway, be consistent about your choice of region.
  • Create a new API, specifying API Name with anything you like. (e.g. "slidingPuzzleMotion")

1

  • Strongly Recommend: read this well-written tutorial
  • In the Action drop down menu,
    • Create Method creates a RESTful HTTP method for that particular URL. ( e.g. create GET under /about will allow GET requests )
    • Create Resource creates one more level traverse down the URL. ( e.g. create career resource under /website.com/ will creates an addressable URL of /website.com/career/)
  • In our case, we create a resource specific for /puzzle and GET method for the Arduino to pull Alexa Skill states.

3

4

  • Fill in the Integration Request details as follows: 5

  • Further add application/json into Body Mapping Templates, more importantly, specify the mapping from query string action to a field value under event input parameters.

7

  • Last steps on Method Request, enabling a validity check on query string which are expected to provide the required parameters like action. Yay! You are ready for testing and deployment.

6

Testing

Go to test with a thundering icon, and input any possible value for action field, which is equivalent to sending a GET request to https://xxxx.execute-api.us-east-1.amazonaws.com/STAGE_NAME/puzzle?action=... URL.

Your result should look like the following:

8

Deployment

Go to action dropdown menu and choose Deploy API, you should see a dialog window prompted out asking for stages. By convention, just create a new stage of prod, standing for your production stage. Then off you go.

You could verify the successful deployment by typing the URL from your browser.

9

10