API, AWS, AWS API Gateway

5 Mins Read

Configuring The Usage Plan in AWS API Gateway

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:

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.

  • Cloud Migration
  • Devops
  • AIML & IoT
Know More

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.

Get your new hires billable within 1-60 days. Experience our Capability Development Framework today.

  • Cloud Training
  • Customized Training
  • Experiential Learning
Read More

About CloudThat

CloudThat is an official AWS (Amazon Web Services) Advanced Consulting Partner and Training partner, AWS Migration Partner, AWS Data and Analytics Partner, AWS DevOps Competency Partner, Amazon QuickSight Service Delivery Partner, AWS EKS Service Delivery Partner, and Microsoft Gold Partner, helping people develop knowledge of the cloud and help their businesses aim for higher goals using best-in-industry cloud computing practices and expertise. We are on a mission to build a robust cloud computing ecosystem by disseminating knowledge on technological intricacies within the cloud space. Our blogs, webinars, case studies, and white papers enable all the stakeholders in the cloud computing sphere.

To get started, go through our Training page and Managed Services PackageCloudThat’s offerings.

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!