Amazon API Gateway
Developer Guide

Create a Deployment in API Gateway

In API Gateway, a deployment is represented by a Deployment resource. It is like an executable of an API represented by a RestApi resource. For the client to call your API, you must create a deployment and associate a stage to it. A stage is represented by a Stage resource and represents a snapshot of the API, including methods, integrations, models, mapping templates, custom authorizers, etc. 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 in API Gateway.

Create a Deployment Using AWS CLI

Creating an deployment amounts to instantiating the Deployment resource. You can use the API Gateway console, AWS CLI, an AWS SDK or the API Gateway REST API to create an deployment.

To use CLI to create a deployment, use the create-deployment command:

aws apigateway create-deployment --rest-api-id <rest-api-id> --region <region>

The API is not callable until you associate this deployment with a stage. With an existing stage, you can do so by updating the stage's deploytmentId property with the newly created deployment ID (<deployment-id>).

aws apigateway update-stage --region <region> \ --rest-api-id <rest-api-id> \ --stage-name <stage-name> \ --patch-operations op='replace',path='/deploymemtId',value='<deployment-id>'

When deploying an API the first time, you can combine the stage creation and deployment creation at the same time:

aws apigateway create-deployment --region <region> \ --rest-api-id <rest-api-id> \ --stage-name <stage-name>

This is what is done behind the scenes in the API Gateway console, when you deploy an API the first time or when you redeploy the API to a new stage.