aws-cdk-lib.Stage

class Stage (construct)

LanguageType name
.NETAmazon.CDK.Stage
Gogithub.com/aws/aws-cdk-go/awscdk/v2#Stage
Javasoftware.amazon.awscdk.Stage
Pythonaws_cdk.Stage
TypeScript (source)aws-cdk-lib » Stage

Implements IConstruct, IDependable

An abstract application modeling unit consisting of Stacks that should be deployed together.

Derive a subclass of Stage and use it to model a single instance of your application.

You can then instantiate your subclass multiple times to model multiple copies of your application which should be be deployed to different environments.

Example

declare const pipeline: pipelines.CodePipeline;
const preprod = new MyApplicationStage(this, 'PreProd');
const prod = new MyApplicationStage(this, 'Prod');

pipeline.addStage(preprod, {
  post: [
    new pipelines.ShellStep('Validate Endpoint', {
      commands: ['curl -Ssf https://my.webservice.com/'],
    }),
  ],
});
pipeline.addStage(prod, {
  pre: [
    new pipelines.ManualApprovalStep('PromoteToProd'),
  ],
});

Initializer

new Stage(scope: Construct, id: string, props?: StageProps)

Parameters

  • scope Construct
  • id string
  • props StageProps

Construct Props

NameTypeDescription
env?EnvironmentDefault AWS environment (account/region) for Stacks in this Stage.
outdir?stringThe output directory into which to emit synthesized artifacts.
permissionsBoundary?PermissionsBoundaryOptions for applying a permissions boundary to all IAM Roles and Users created within this Stage.
policyValidationBeta1?IPolicyValidationPluginBeta1[]Validation plugins to run during synthesis.
stageName?stringName of this stage.

env?

Type: Environment (optional, default: The environments should be configured on the Stacks.)

Default AWS environment (account/region) for Stacks in this Stage.

Stacks defined inside this Stage with either region or account missing from its env will use the corresponding field given here.

If either region or accountis is not configured for Stack (either on the Stack itself or on the containing Stage), the Stack will be environment-agnostic.

Environment-agnostic stacks can be deployed to any environment, may not be able to take advantage of all features of the CDK. For example, they will not be able to use environmental context lookups, will not automatically translate Service Principals to the right format based on the environment's AWS partition, and other such enhancements. Example

// Use a concrete account and region to deploy this Stage to
new Stage(app, 'Stage1', {
  env: { account: '123456789012', region: 'us-east-1' },
});

// Use the CLI's current credentials to determine the target environment
new Stage(app, 'Stage2', {
  env: { account: process.env.CDK_DEFAULT_ACCOUNT, region: process.env.CDK_DEFAULT_REGION },
});

outdir?

Type: string (optional, default: for nested stages, outdir will be determined as a relative directory to the outdir of the app. For apps, if outdir is not specified, a temporary directory will be created.)

The output directory into which to emit synthesized artifacts.

Can only be specified if this stage is the root stage (the app). If this is specified and this stage is nested within another stage, an error will be thrown.


permissionsBoundary?

Type: PermissionsBoundary (optional, default: no permissions boundary is applied)

Options for applying a permissions boundary to all IAM Roles and Users created within this Stage.


policyValidationBeta1?

Type: IPolicyValidationPluginBeta1[] (optional, default: no validation plugins are used)

Validation plugins to run during synthesis.

If any plugin reports any violation, synthesis will be interrupted and the report displayed to the user.


stageName?

Type: string (optional, default: Derived from the id.)

Name of this stage.

Properties

NameTypeDescription
artifactIdstringArtifact ID of the assembly if it is a nested stage. The root stage (app) will return an empty string.
assetOutdirstringThe cloud assembly asset output directory.
nodeNodeThe tree node.
outdirstringThe cloud assembly output directory.
policyValidationBeta1IPolicyValidationPluginBeta1[]Validation plugins to run during synthesis.
stageNamestringThe name of the stage.
account?stringThe default account for all resources defined within this stage.
parentStage?StageThe parent stage or undefined if this is the app.
region?stringThe default region for all resources defined within this stage.

artifactId

Type: string

Artifact ID of the assembly if it is a nested stage. The root stage (app) will return an empty string.

Derived from the construct path.


assetOutdir

Type: string

The cloud assembly asset output directory.


node

Type: Node

The tree node.


outdir

Type: string

The cloud assembly output directory.


policyValidationBeta1

Type: IPolicyValidationPluginBeta1[]

Validation plugins to run during synthesis.

If any plugin reports any violation, synthesis will be interrupted and the report displayed to the user.


stageName

Type: string

The name of the stage.

Based on names of the parent stages separated by hypens.


account?

Type: string (optional)

The default account for all resources defined within this stage.


parentStage?

Type: Stage (optional)

The parent stage or undefined if this is the app.


region?

Type: string (optional)

The default region for all resources defined within this stage.

Methods

NameDescription
synth(options?)Synthesize this stage into a cloud assembly.
toString()Returns a string representation of this construct.
static isStage(x)Test whether the given construct is a stage.
static of(construct)Return the stage this construct is contained with, if available.

synth(options?)

public synth(options?: StageSynthesisOptions): CloudAssembly

Parameters

  • options StageSynthesisOptions

Returns

  • CloudAssembly

Synthesize this stage into a cloud assembly.

Once an assembly has been synthesized, it cannot be modified. Subsequent calls will return the same assembly.


toString()

public toString(): string

Returns

  • string

Returns a string representation of this construct.


static isStage(x)

public static isStage(x: any): boolean

Parameters

  • x any

Returns

  • boolean

Test whether the given construct is a stage.


static of(construct)

public static of(construct: IConstruct): Stage

Parameters

  • construct IConstruct

Returns

  • Stage

Return the stage this construct is contained with, if available.

If called on a nested stage, returns its parent.