aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.68k stars 3.93k forks source link

pipelines: specify dependencies between pre/post steps #17945

Closed jeromevdl closed 2 years ago

jeromevdl commented 2 years ago

What is the problem?

When adding multiple pre (or post) steps to a stage, I cannot specify the order. If I'm adding them in the order I'd like (using addPre or addPost), the generated pipeline actions are not in the correct order but alphabetically ordered.

Reproduction Steps

Have a stage and add multiple pre steps:

prodStage.addPre(
      new pipelines.ManualApprovalStep('Validation'),
      new pipelines.CodeBuildStep('Bootstrap', {...})
);

The Validation Step is after the Boostrap one in my template, while it should be before as I've added it before.

If I change "Validation" to "Approval":

prodStage.addPre(
      new pipelines.ManualApprovalStep('Approval'),
      new pipelines.CodeBuildStep('Bootstrap', {...})
);

Approval is now before Bootstrap.

What did you expect to happen?

I expect to have the steps in the order I add them:

prodStage.addPre(
      new pipelines.ManualApprovalStep('Validation'),
      new pipelines.CodeBuildStep('Bootstrap', {...})
);

Should give Validation first and then Bootstrap

What actually happened?

Validation was after Bootstrap.

CDK CLI Version

2.0.0 (build 4b6ce31)

Framework Version

No response

Node.js Version

v17.0.1

OS

macOS BigSur 11.6.1 (M1)

Language

Typescript

Language Version

Typescript (4.5.2)

Other information

No response

markusl commented 2 years ago

This sounds a bit like https://github.com/aws/aws-cdk/issues/16130 where I encountered a problem about adding a manual approval step using the pre/post commands in the CDK Pipelines.

FreeWillaert commented 2 years ago

I have a similar issue: no matter what I do - pass an array of steps in addStage, do one or multiple calls to addPost,... - the steps just end up side-by-side, being executed in parallel. In my case, it's a S3 deploy step and a cloudfront invalidation step. Using CDK 1.133.

I'm not sure though about the expected behavior: should e.g. multiple calls to addPost effectively result in steps being executed sequentially? There are other cases where parallel execution is desired, and there seems to be no way to specify which is preferred, I think?

FreeWillaert commented 2 years ago

I finally managed to work around this by creating a wave, adding the stage to it with the first post step, then adding the second post step to the wave. This results in the two steps being sequential in the code pipeline, in the correct order.

github-actions[bot] commented 2 years ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

ssljivic commented 11 months ago

I have a similar issue: no matter what I do - pass an array of steps in addStage, do one or multiple calls to addPost,... - the steps just end up side-by-side, being executed in parallel. In my case, it's a S3 deploy step and a cloudfront invalidation step. Using CDK 1.133.

I'm not sure though about the expected behavior: should e.g. multiple calls to addPost effectively result in steps being executed sequentially? There are other cases where parallel execution is desired, and there seems to be no way to specify which is preferred, I think?

@FreeWillaert which class/construct do you use for S3 deploy step and a CloudFront invalidation step?