Update the API Gateway Stage Name in AWS CDK


Borislav Hadzhiev

Sat May 01 20211 min read

In order to update the Stage Name of an API Gateway deployment, we have to pass the `deployOptions` prop when instantiating the `RestApi` class.

Updating the API Gateway Stage Name in AWS CDK #

By default the RestApi class creates a stage named prod in which it deploys our APIs.

In order to update the name of the stage for an API Gateway deployment in CDK, we have to set the deployOptions prop when instantiating the RestApi class.

import * as apigateway from '@aws-cdk/aws-apigateway';
import * as cdk from '@aws-cdk/core';

export class CdkStarterStack extends cdk.Stack {
  constructor(scope: cdk.App, id: string, props: StackProps) {
    super(scope, id, props);

    const api = new apigateway.RestApi(this, 'api', {
      deployOptions: {
        // ๐Ÿ‘‡ update stage name to `dev`
        stageName: 'dev',

The deployOptions prop allows us to set the stage name for the API Gateway deployment.

The name of the stage is then included in the API url, for example: https://api-id.execute-api.region.amazonaws.com/STAGE-NAME/.

Further Reading #

Join my newsletter

I'll send you 1 email a week with links to all of the articles I've written that week

Buy Me A Coffee