API Gateway

API Gateway
March 8, 2021

AWS API Gateway helps us to develop RESTful APIs. In some cases, especially for a B2B business, sometimes we need to expose the APIs to a few customers and restrict them on the number or the rate of API calls.

Usage plans help you to define maximum request quotas and manage request rates while sharing your API with others. API Gateway allows us to create API Keys for each of the customers.

By using Usage Plans, you can control the 3 aspects of accessing an API:

  1. Quota
  2. Throttling
  3. API/Stage that can be accessed

Create a usage plan

  1. Go to the API Gateway console and go to Usage Plans on the left side pane.
  2. Enter the Usage Plan name, throttling rate, and quota you want to set on the API, and click Next.
AWS API gateway
AWS API gateway

  1. In the next window, Associated API Stages, select the API from the drop-down and then select the corresponding stage on which you want to apply the usage plan. Click on Next.
  2. Now comes the API Keys part. Create a new API Key. Give the Customer name, and you can select Auto Generate option or provide your Custom Key. Save it.
Creating new API key

As we have configured the usage plan with an API Key, it will start tracking the number of calls if the customer makes the call using the API Key. You can see the usage by going to the plan, the API Keys tab, and clicking Usage.

To complete the configuration, go to the API to which you have applied the Usage plan.

Under Method Execution, set API Key Required to true so that API can’t be invoked without the key.

Do not forget to deploy the API after making the changes.

configured the usage plan with an API Key

When calling the API, the person needs to give the API key in the x-API-key  header, and the usage can be tracked and limited.

Thus, Usage Plans help the business track the customer’s API call, which can be part of different plans. Also, the end customer can be billed based on the usage of the APIs. You can also control access to the API and its resources and allow special grants to users as needed.

Written by – Atin Mittal

Cloud Computing Insights and Resources

gen ai evolution of cloud computing

Transforming Web Development: The Modern Era Advancement of Microservices Architecture

The evolution of traditional processes has been propelled by advancing technology and the integration of recent discoveries. The web development […]

gen ai evolution of cloud computing

Future-Proofing Infrastructure: How Generative AI Shapes the Evolution of Cloud Computing 

The reality of cloud computing stands at the edge of a vast transformation, all thanks to the emergence of Generative […]

cloud computing security

What are the security issues in cloud? 

What is cloud?  Cloud computing refers to the delivery of computing services, including servers, storage, databases, networking, software, analytics, and […]