Creating a API Gateway

Setting Up the API Gateway

In this section, we will establish an API Gateway to facilitate data reception from the sensors. This API Gateway will trigger the Lambda function, which will subsequently store the data in Amazon S3 and OpenSearch Service.

  1. Access the API Gateway console. API Gateway Console

  2. On the REST API card, select Build. REST API Build Option

  3. For Create new API, opt for New API. Name the API as sensor-data and then initiate Create API. API Creation

  4. In the Resources section, from the Actions menu, choose Create Method. From the dropdown, select POST. POST Method Selection POST Method Selection

  5. For POST - Setup, ensure:

    • Integration type is set to Lambda Function.
    • Lambda Function box contains upload-data.
    • Confirm by selecting Save. Lambda Function Configuration Save Configuration

Testing the API Gateway

  1. In the POST - Method Execution section, opt for TEST. Method Execution Test

  2. In the Request Body box, input the following JSON:

    {
      "sensorID" : "0047",
      "temperature" : "23"
    }
    

    Request

Conclusion

Successfully, you’ve set up and tested an API Gateway to receive data from sensors and activate the Lambda function.