API, AWS, AWS API Gateway

5 Mins Read

Configuring The Usage Plan in AWS API Gateway

Voiced by Amazon Polly

Introduction

In Amazon API Gateway, a usage plan allows API providers to bundle multiple APIs and define usage policies and quotas for those APIs. This feature enables API providers to control access to their APIs, manage request rates, and establish billing and operational policies for API consumers. Usage plans are essential to control and monitor how clients are using your APIs, ensuring fairness and preventing overuse of API resources.

Configuring a usage plan in AWS API Gateway involves several steps to control and manage access to your API resources. Here’s a general guide on how to set up a usage plan in AWS API Gateway:

Freedom Month Sale — Upgrade Your Skills, Save Big!

  • Up to 80% OFF AWS Courses
  • Up to 30% OFF Microsoft Certs
Act Fast!

Step 1: Create a Usage Plan

  1. Sign into the AWS Management Console: Go to the AWS Management Console and navigate to API Gateway.

  1. Create a Usage Plan:
    • In the API Gateway console, choose the API you want to create a usage plan.
    • In the left navigation pane, select “Usage Plans.”

    • Click on the “Create” button to create a new usage plan.
  1. Configure Usage Plan Details:
    • Enter a name and an optional description for your usage plan.

    • Choose throttling and quota settings. Throttling limits the number of requests per second (RPS) a user can make, while quota limits the total number of requests per day, per month, or per week.

Step 2: Add API Stages to the Usage Plan

  1. Add API Stages:
    • In the usage plan details page, scroll down to the “API Stages” section.

 

    • Click “Add API Stage” to associate your API with the usage plan.

    • Select the API you want to add and choose the deployment stage (like “prod” or “test”).

Step 3: Configure Throttling and Quotas

  1. Set Throttling and Quotas:
    • Specify the desired request throttling (requests per second) and request quota (maximum number of requests per day) for the usage plan.

Step 4: Set Up API Keys:

Usage plans are often associated with API keys. API keys act as unique identifiers for clients consuming your APIs. Clients must include their API keys in the API request headers, allowing API Gateway to identify the client and apply the applicable usage plan policies.

  1. Create API Keys: If you want to control access to your API through API keys, you can create API keys in the API Gateway console. To create API keys, follow the steps below:
    • In the left navigation pane, select “API Keys”. Click on Create API Keys.

    • Give the name for the API key, select Autogenerate, and Save

    • Once the API is created, you can see the API key as shown below:

 

  1. Associate API Keys with Usage Plan:
    • In the usage plan details page, you can associate created API keys with the usage plan. This step is optional, as you can use usage plans without API keys as well.

Choose the API key you created in the previous step.

 

Step 5: Deploy the API Changes

  1. Deploy API Changes:
    • After configuring the usage plan, make sure to deploy the API changes for the settings to take effect.

Deploy the API to the “Test Stage” of your API gateway.

Step 6: Test the Usage Plan

  1. Test Access:
    • Go to your API, set the API key required to True, and deploy your API

    • Once you deploy your API, test the API in a browser, or You can use the Postman Tool to test your API.

    • You get a Forbidden message as API key is required to access your API’s
    • Use the configured API key (if applicable) and endpoints to test the access control based on the configured usage plan using Postman. Give the API key as the value for the x-api-key header. Now, you can access your Lambda.

Conclusion

In summary, usage plans are an integral part of API Gateway that serves both security and business needs. Usage plans empower API providers with the necessary tools to ensure secure, controlled, and efficient API usage. Usage plans enable API providers to implement billing and monetization models, charging clients based on their actual API usage. This is especially useful for businesses offering paid services through their APIs. By leveraging these plans, businesses can offer reliable API services to clients, foster trust, drive successful API ecosystems in the AWS environment, and potentially generate revenue from their APIs.

Freedom Month Sale — Discounts That Set You Free!

  • Up to 80% OFF AWS Courses
  • Up to 30% OFF Microsoft Certs
Act Fast!

About CloudThat

CloudThat is an award-winning company and the first in India to offer cloud training and consulting services worldwide. As a Microsoft Solutions Partner, AWS Advanced Tier Training Partner, and Google Cloud Platform Partner, CloudThat has empowered over 850,000 professionals through 600+ cloud certifications winning global recognition for its training excellence including 20 MCT Trainers in Microsoft’s Global Top 100 and an impressive 12 awards in the last 8 years. CloudThat specializes in Cloud Migration, Data Platforms, DevOps, IoT, and cutting-edge technologies like Gen AI & AI/ML. It has delivered over 500 consulting projects for 250+ organizations in 30+ countries as it continues to empower professionals and enterprises to thrive in the digital-first world.

Share

Comments

    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!