# StagePlacement

Struct · Stable

Allows you to control where to place a new Stage when it's added to the Pipeline.

Note that you can provide only one of the below properties -
specifying more than one will result in a validation error.

- Source: [`aws-codepipeline/lib/pipeline.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-codepipeline/lib/pipeline.ts#L61)

## Example

TypeScript:

```ts
// Insert a new Stage at an arbitrary point
declare const pipeline: codepipeline.Pipeline;
declare const anotherStage: codepipeline.IStage;
declare const yetAnotherStage: codepipeline.IStage;

const someStage = pipeline.addStage({
  stageName: 'SomeStage',
  placement: {
    // note: you can only specify one of the below properties
    rightBefore: anotherStage,
    justAfter: yetAnotherStage,
  }
});
```

Python:

```python
# Insert a new Stage at an arbitrary point
# pipeline: codepipeline.Pipeline
# another_stage: codepipeline.IStage
# yet_another_stage: codepipeline.IStage

some_stage = pipeline.add_stage(
    stage_name="SomeStage",
    placement=codepipeline.StagePlacement(
        # note: you can only specify one of the below properties
        right_before=another_stage,
        just_after=yet_another_stage
    )
)
```

Java:

```java
// Insert a new Stage at an arbitrary point
Pipeline pipeline;
IStage anotherStage;
IStage yetAnotherStage;

IStage someStage = pipeline.addStage(StageOptions.builder()
        .stageName("SomeStage")
        .placement(StagePlacement.builder()
                // note: you can only specify one of the below properties
                .rightBefore(anotherStage)
                .justAfter(yetAnotherStage)
                .build())
        .build());
```

C#:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// Insert a new Stage at an arbitrary point
Pipeline pipeline;
IStage anotherStage;
IStage yetAnotherStage;

var someStage = pipeline.AddStage(new StageOptions {
    StageName = "SomeStage",
    Placement = new StagePlacement {
        // note: you can only specify one of the below properties
        RightBefore = anotherStage,
        JustAfter = yetAnotherStage
    }
});
```

Go:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// Insert a new Stage at an arbitrary point
var pipeline Pipeline
var anotherStage IStage
var yetAnotherStage IStage

someStage := pipeline.AddStage(&StageOptions{
	StageName: jsii.String("SomeStage"),
	Placement: &StagePlacement{
		// note: you can only specify one of the below properties
		RightBefore: anotherStage,
		JustAfter: yetAnotherStage,
	},
})
```

## Properties

- `justAfter`: [IStage](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codepipeline.IStage.html) — Inserts the new Stage as a child of the given Stage (changing its current child Stage, if it had one).

- `rightBefore`: [IStage](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codepipeline.IStage.html) — Inserts the new Stage as a parent of the given Stage (changing its current parent Stage, if it had one).
