# StageDeployment

Deployment of a single `Stage`.

A `Stage` consists of one or more `Stacks`, which will be
deployed in dependency order.

Obtainable from: StageDeployment.fromStage
Returned by: [PipelineBase.addStage](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.pipelines.PipelineBase.html#addstage), [Wave.addStage](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.pipelines.Wave.html#addstage)

- Source: [`pipelines/lib/blueprint/stage-deployment.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/pipelines/lib/blueprint/stage-deployment.ts#L49)
- Type last changed: v2.44.0 · 29 Sep 2022

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { pipelines } from 'aws-cdk-lib';

declare const stack: cdk.Stack;
declare const stage: cdk.Stage;
declare const step: pipelines.Step;
const stageDeployment = pipelines.StageDeployment.fromStage(stage, /* all optional props */ {
  post: [step],
  pre: [step],
  stackSteps: [{
    stack: stack,

    // the properties below are optional
    changeSet: [step],
    post: [step],
    pre: [step],
  }],
  stageName: 'stageName',
});
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk
from aws_cdk import pipelines

# stack: cdk.Stack
# stage: cdk.Stage
# step: pipelines.Step

stage_deployment = pipelines.StageDeployment.from_stage(stage,
    post=[step],
    pre=[step],
    stack_steps=[pipelines.StackSteps(
        stack=stack,

        # the properties below are optional
        change_set=[step],
        post=[step],
        pre=[step]
    )],
    stage_name="stageName"
)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;
import software.amazon.awscdk.pipelines.*;

Stack stack;
Stage stage;
Step step;

StageDeployment stageDeployment = StageDeployment.fromStage(stage, StageDeploymentProps.builder()
        .post(List.of(step))
        .pre(List.of(step))
        .stackSteps(List.of(StackSteps.builder()
                .stack(stack)

                // the properties below are optional
                .changeSet(List.of(step))
                .post(List.of(step))
                .pre(List.of(step))
                .build()))
        .stageName("stageName")
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;
using Amazon.CDK.Pipelines;

Stack stack;
Stage stage;
Step step;

var stageDeployment = StageDeployment.FromStage(stage, new StageDeploymentProps {
    Post = new [] { step },
    Pre = new [] { step },
    StackSteps = new [] { new StackSteps {
        Stack = stack,

        // the properties below are optional
        ChangeSet = new [] { step },
        Post = new [] { step },
        Pre = new [] { step }
    } },
    StageName = "stageName"
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import cdk "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var stack Stack
var stage Stage
var step Step

stageDeployment := awscdk.Pipelines.StageDeployment_FromStage(stage, &StageDeploymentProps{
	Post: []Step{
		step,
	},
	Pre: []Step{
		step,
	},
	StackSteps: []StackSteps{
		&StackSteps{
			Stack: stack,

			// the properties below are optional
			ChangeSet: []Step{
				step,
			},
			Post: []Step{
				step,
			},
			Pre: []Step{
				step,
			},
		},
	},
	StageName: jsii.String("stageName"),
})
```

## Properties

- `post`: [Step](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.pipelines.Step.html)[] — Additional steps that are run after all of the stacks in the stage.

- `pre`: [Step](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.pipelines.Step.html)[] — Additional steps that are run before any of the stacks in the stage.

- `prepareStep`: boolean — Determine if all stacks in stage should be deployed with prepare step or not.

- `stacks`: [StackDeployment](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.pipelines.StackDeployment.html)[] — The stacks deployed in this stage.

- `stackSteps`: [StackSteps](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.pipelines.StackSteps.html)[] — Instructions for additional steps that are run at stack level.

- `stageName`: string — The display name of this stage.

## Methods

- `addPost(...steps: Step[]): void` — Add an additional step to run after all of the stacks in this stage.

- `addPre(...steps: Step[]): void` — Add an additional step to run before any of the stacks in this stage.

- `fromStage(stage: Stage, props?: StageDeploymentProps): StageDeployment // chainable` (static) — Create a new `StageDeployment` from a `Stage`.

  Synthesizes the target stage, and deployes the stacks found inside
  in dependency order.
