diff --git a/packages/@aws-cdk/pipelines/lib/stage.ts b/packages/@aws-cdk/pipelines/lib/stage.ts index 6b379f686fe2e..dd5aa28c5e50e 100644 --- a/packages/@aws-cdk/pipelines/lib/stage.ts +++ b/packages/@aws-cdk/pipelines/lib/stage.ts @@ -184,7 +184,7 @@ export class CdkStage extends Construct { if (this._prepared) { return; } this._prepared = true; - for (const { prepareRunOrder: runOrder, stackArtifact } of this.stacksToDeploy) { + for (const { prepareRunOrder, stackArtifact, executeRunOrder } of this.stacksToDeploy) { const artifact = this.host.stackOutputArtifact(stackArtifact.id); this.pipelineStage.addAction(DeployCdkStackAction.fromStackArtifact(this, stackArtifact, { @@ -192,7 +192,8 @@ export class CdkStage extends Construct { cloudAssemblyInput: this.cloudAssemblyArtifact, output: artifact, outputFileName: artifact ? 'outputs.json' : undefined, - prepareRunOrder: runOrder, + prepareRunOrder, + executeRunOrder, })); } } @@ -387,4 +388,4 @@ interface DeployStackCommand { prepareRunOrder: number; executeRunOrder: number; stackArtifact: cxapi.CloudFormationStackArtifact; -} \ No newline at end of file +} diff --git a/packages/@aws-cdk/pipelines/test/stack-ordering.test.ts b/packages/@aws-cdk/pipelines/test/stack-ordering.test.ts index e755572c78544..45d0cb76bf6b8 100644 --- a/packages/@aws-cdk/pipelines/test/stack-ordering.test.ts +++ b/packages/@aws-cdk/pipelines/test/stack-ordering.test.ts @@ -55,6 +55,29 @@ test('multiple independent stacks go in parallel', () => { }); }); +test('manual approval is inserted in correct location', () => { + // WHEN + pipeline.addApplicationStage(new TwoStackApp(app, 'MyApp'), { + manualApprovals: true, + }); + + // THEN + expect(pipelineStack).toHaveResourceLike('AWS::CodePipeline::Pipeline', { + Stages: arrayWith({ + Name: 'MyApp', + Actions: sortedByRunOrder([ + objectLike({ Name: 'Stack1.Prepare' }), + objectLike({ Name: 'ManualApproval' }), + objectLike({ Name: 'Stack1.Deploy' }), + objectLike({ Name: 'Stack2.Prepare' }), + objectLike({ Name: 'ManualApproval2' }), + objectLike({ Name: 'Stack2.Deploy' }), + ]), + }), + }); +}); + + class TwoStackApp extends Stage { constructor(scope: Construct, id: string, props?: StageProps) { super(scope, id, props); @@ -80,4 +103,4 @@ class ThreeStackApp extends Stage { stack3.addDependency(stack1); stack3.addDependency(stack2); } -} \ No newline at end of file +}