title: AWS CDK set Stage stageName
body: <p>I have an aws cdk project using typescript.
  I plan to set up a pipeline with 2 stages (dev and prod).</p>
  <p>I have a cdk stage which contains a stack with a gateway and lamba construct inside</p>
  <pre><code>/* eslint-disable max-classes-per-file */
  /* eslint-disable import/prefer-default-export */
  import { Construct, Stage, StageProps } from '@aws-cdk/core';
  
  import * as cdk from '@aws-cdk/core';
  import * as path from 'path';
  import * as lambda from '@aws-cdk/aws-lambda';
  import * as apigw from '@aws-cdk/aws-apigateway';
  // import { CdkPipelinesStack } from './cdk-pipeline-2-stack';
  
  class CdkPipelinesStack extends cdk.Stack {
    public readonly urlOutput: cdk.CfnOutput;
  
    constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
      super(scope, id, props);
  
      const handler = new lambda.Function(this, 'lambda', {
        code: lambda.Code.fromAsset(path.resolve(__dirname, 'lambda')),
        handler: 'index.handler',
        runtime: lambda.Runtime.NODEJS_12_X,
        environment: {},
      });
  
      const gw = new apigw.LambdaRestApi(this, 'Gateway', {
        description: 'Endpoint for lambda',
        handler,
      });
  
      this.urlOutput = new cdk.CfnOutput(this, 'url', { value: gw.url });
    }
  }
  
  export class CdkPipelinesDemoStage extends Stage {
    public readonly urlOutput: cdk.CfnOutput;
  
    constructor(scope: Construct, id: string, props?: StageProps) {
      super(scope, id, props);
  
      const service = new CdkPipelinesStack(this, 'webservice', { env: {}, stackName: 'bla' });
  
      this.urlOutput = service.urlOutput;
    }
  }
  
  </code></pre>
  <p>I want to deploy 2 stages (dev and prod) in a pipeline as follows</p>
  <pre><code> // Do this as many times as necessary with any account and region
      // Account and region may be different from the pipeline's.
      const devStage = pipeline.addApplicationStage(
        new CdkPipelinesDemoStage(this, 'Dev', {
          env: {
            account: '694710432912',
            region: 'ap-southeast-1',
          },
        })
      );
  
      devStage.addActions(
        new ManualApprovalAction({
          actionName: 'ManualApproval',
          runOrder: devStage.nextSequentialRunOrder(),
        })
      );
  
      // Do this as many times as necessary with any account and region
      // Account and region may be different from the pipeline's.
      pipeline.addApplicationStage(
        new CdkPipelinesDemoStage(this, 'Prod', {
          env: {
            account: '694710432912',
            region: 'ap-southeast-1',
          },
        })
      );
  </code></pre>
  <p>This works but both deployed gateways have stage name <code>prod</code>.</p>
  <p>I want to set the stage name of my first stage to <code>dev</code>.</p>
  <p>How can I do this?</p>
  <p>I thought it could just be as simple as passing a stageName from <a href="https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-apigateway.StageProps.html" rel="nofollow noreferrer">StageProps</a> to the stage constructor. But this causes a compiler error.</p>
  <pre><code>// Do this as many times as necessary with any account and region
      // Account and region may be different from the pipeline's.
      const devStage = pipeline.addApplicationStage(
        new CdkPipelinesDemoStage(this, 'Dev', {
          env: {
            account: '694710432912',
            region: 'ap-southeast-1',
          },
          stageName: 'dev'
        })
      );
  
  
  </code></pre>
  <p>Thanks :)</p>