Skip to content

Creating AWS API Gateway

Hovhannes Apinyan edited this page Apr 5, 2024 · 1 revision

Creating an HTTP API with AWS API Gateway and Lambda Integration

Step 1: Accessing AWS API Gateway

  • Navigate to the AWS Management Console in your web browser.
  • Open the AWS API Gateway service by either searching for "API Gateway" in the search bar or locating it in the services list.
  • Once in the API Gateway dashboard, click on the Create API button to initiate the process.

Step 2: Selecting the API Type

  • In the Create API interface, choose the HTTP API option. HTTP APIs are designed for low-latency, cost-effective integrations with AWS services, including AWS Lambda and HTTP endpoints.
  • Click the Build button to proceed.

Step 3: Integrating with AWS Lambda

  • In the Configure Integrations section, click on Add Integration.
  • Select Lambda as the integration type. This choice allows your API to connect and interact with an AWS Lambda function.
  • From the list, choose the Lambda function you have previously created and wish to use with this API.
  • After selecting the Lambda function, proceed by entering a name for your API in the API name field and click Next.

Step 4: Configuring Routes

  • In the Configure routes section, set the Method to GET. This HTTP method specifies the type of operation your API will perform.
  • In the Resource path field, enter /getData. This path is the endpoint at which your API will be accessible.
  • Verify the Integration target to ensure that the correct Lambda function is specified. If everything is correct, click Next.

Step 5: Setting the Stage

  • In the Stage configuration, you can leave the Stage name as $default. This is a predefined stage provided by AWS, which represents the initial deployment stage of your API.
  • Click Next to continue.

Step 6: Review and Create

  • You will be presented with a review page summarizing the settings and configurations of your API. Carefully check all the details to ensure they are correct and meet your requirements.
  • If all information is accurate, click on the Create button to finalize the creation of your HTTP API.

Step 7: Retrieving the Invoke URL for Your API

After successfully creating your API, you will be redirected to the main page of your API in the AWS API Gateway console. To find the Invoke URL, follow these steps:

  • On the left side of the screen, you will see a navigation pane. Look for a section labeled with your API name, formatted as API: MyApiName (myapiid). Click on this section to access the settings and details of your API.
  • Inside your API's dashboard, locate the Invoke URL section. This URL represents the entry point for your API and is the base URL to which you will append your resource paths (like /getData) to access different functions of your API.
  • The Invoke URL will be something like https://myapiid.execute-api.region.amazonaws.com. To construct the full URL for accessing a specific resource like /getData, append the resource path to the Invoke URL, resulting in https://myapiid.execute-api.region.amazonaws.com/getData.

Upon completion, AWS will deploy your HTTP API, making it accessible at the specified resource path. You can then test the API to ensure it interacts correctly with your Lambda function, facilitating the intended data retrieval or processing operations.