Create a deployment for a REST API in API Gateway
In API Gateway, a REST API deployment is represented by a Deployment resource. It's similar to an executable of an API that is represented by a RestApi resource.
For the client to call your API, you must create a deployment and associate a stage with it. A stage is represented by a Stage resource. It represents a snapshot of the API, including methods, integrations, models, mapping templates, and Lambda authorizers (formerly known as custom authorizers). When you update the API, you can redeploy the API by associating a new stage with the existing deployment. We discuss creating a stage in Set up a stage for a REST API in API Gateway.
Create a deployment
The following procedures show how to create a deployment for a REST API.
To redeploy an API, perform the same steps. You can reuse the same stage as many times as desired.
Next steps for your API deployment
The following are next steps for your API deployment.
- Modify stage settings
-
After an API is deployed, you can modify the stage settings to enable or disable the API cache, logging, or request throttling. You can also choose a client certificate for the backend to authenticate API Gateway and set stage variables to pass deployment context to the API integration at runtime. For more information, see Modify stage settings
After modifying stage settings, you must redeploy the API for the changes to take effect.
Note
If the updated settings, such as enabling logging, requires a new IAM role, you can add the required IAM role without redeploying the API. However, it might take a few minutes before the new IAM role takes effect. Before that happens, traces of your API calls are not logged even if you have enabled the logging option.
- Choose different deployment-stage combinations
Because a deployment represents an API snapshot and a stage defines a path into a snapshot, you can choose different deployment-stage combinations to control how users call into different versions of the API. This is useful, for example, when you want to roll back API state to a previous deployment or to merge a 'private branch' of the API into the public one.
The following procedure shows how to do this using the Stage Editor in the API Gateway console. It is assumed that you must have deployed an API more than once.
-
If you're not already on the Stages pane, in the main navigation pane, choose Stages.
Select the stage you want to update.
-
On the Deployment history tab, select the deployment you want the stage to use.
-
Choose Change active deployment.
Confirm you want to change the active deployment and choose Change active deployment in the Make active deployment dialog box.
-
- Pass deployment-specific data to your API.
For a deployment, you can set or modify stage variables to pass deployment-specific data to the API integration at runtime. You can do this on the Stage Variables tab in the Stage Editor. For more information, see instructions in Use stage variables for a REST API in API Gateway.