What is Stage in API Gateway: Definition and Usage
stage is a named reference to a deployment of your API. It acts like a version or environment (such as dev, test, or prod) where you can configure settings and access your API endpoints.How It Works
Think of a stage in API Gateway like a labeled checkpoint or environment for your API. When you create or update your API, you deploy it to a stage. This stage then holds a snapshot of your API configuration and code at that moment.
Just like a restaurant might have different menus for breakfast, lunch, and dinner, API Gateway stages let you have different versions of your API running simultaneously. Each stage has its own URL and settings, so you can test new features in a dev stage without affecting the live prod stage.
Example
This example shows how to create a deployment with a stage named dev for an API using AWS CLI.
aws apigateway create-deployment --rest-api-id a1b2c3d4 --stage-name dev
When to Use
Use stages to manage different environments of your API, such as development, testing, and production. This helps you safely test changes before making them live.
For example, you might deploy a new feature to a test stage to let your team try it out. Once verified, you deploy the same API version to the prod stage for your users.
Stages also allow you to configure settings like logging, throttling, and caching independently for each environment.
Key Points
- A
stageis a named snapshot of your API deployment. - Each stage has its own URL and settings.
- Stages help separate environments like dev, test, and prod.
- You can configure logging and throttling per stage.