Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pipelines] extra room for actions in cdkStage addApplication() #11333

Closed
1 task done
adriantaut opened this issue Nov 6, 2020 · 4 comments · Fixed by #11376
Closed
1 task done

[pipelines] extra room for actions in cdkStage addApplication() #11333

adriantaut opened this issue Nov 6, 2020 · 4 comments · Fixed by #11376
Assignees
Labels
@aws-cdk/pipelines CDK Pipelines library effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. good first issue Related to contributions. See CONTRIBUTING.md in-progress This issue is being actively worked on. p2

Comments

@adriantaut
Copy link
Contributor

adriantaut commented Nov 6, 2020

Reserve room for more actions between the prepare and execute actions added within addApplication() method in the CdkStage class.

Use Case

Currently there is no way of reordering stages/actions ( #10127 ) once they are created. Getting to the Prepare and Execute change set actions while adding an application stage, we identified a use case within our company that needs one or more intermediary actions before actually executing the change set. To be more specific, once the prepared change set is reviewed and manually approved, we have to reach out our ticketing tool for creating a change request before actual deployment to production. All the above must run sequentially, as the change request needs the user email that approved the deploy.

Proposed Solution

To resolve the problem, I would suggest extending the AddStageOptions interface with an optional property representing the number of intermediary actions you need room for, thus the executeRunOrder will get increased with this optional property. I've already tested it roughly, and it works like expected.

Raw implementation

--- a/packages/@aws-cdk/pipelines/lib/stage.ts
+++ b/packages/@aws-cdk/pipelines/lib/stage.ts
@@ -76,6 +76,7 @@ export class CdkStage extends CoreConstruct {
    */
   public addApplication(appStage: Stage, options: AddStageOptions = {}) {
     const asm = appStage.synth();
+    const roomForIntermediaryActions = options.roomForIntermediaryActions ?? 0;

     if (asm.stacks.length === 0) {
       // If we don't check here, a more puzzling "stage contains no actions"
@@ -88,8 +89,8 @@ export class CdkStage extends CoreConstruct {
       stack => stack.dependencies.map(d => d.id));

     for (const stacks of sortedTranches) {
-      const runOrder = this.nextSequentialRunOrder(2); // We need 2 actions
-      let executeRunOrder = runOrder + 1;
+      const runOrder = this.nextSequentialRunOrder(roomForIntermediaryActions + 2); // We need 2 actions for stack actions
+      let executeRunOrder = runOrder + roomForIntermediaryActions + 1;

       // If we need to insert a manual approval action, then what's the executeRunOrder
       // now is where we add a manual approval step, and we allocate 1 more runOrder
@@ -371,6 +372,15 @@ export interface AddStageOptions {
    * @default false
    */
   readonly manualApprovals?: boolean;
+  /**
+   * Add room for intermediary actions
+   *
+   * This increases the executeRunOrder of the execute change set action with
+   * the value passed.
+   *
+   * @default 0
+   */
+  readonly roomForIntermediaryActions?: number;
 }
  • 👋 I am able to implement this feature request if it's welcome.

This is a 🚀 Feature Request

@adriantaut adriantaut added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Nov 6, 2020
@github-actions github-actions bot added the @aws-cdk/pipelines CDK Pipelines library label Nov 6, 2020
@rix0rrr
Copy link
Contributor

rix0rrr commented Nov 9, 2020

@rix0rrr rix0rrr added effort/small Small work item – less than a day of effort good first issue Related to contributions. See CONTRIBUTING.md p2 labels Nov 9, 2020
@adriantaut
Copy link
Contributor Author

@rix0rrr unfortunately not, we are using the manualApprovals option also, but the extra action we need both consumes the approver email and must run before the ExecuteChangeSet, thus the need for sequential actions.

adriantaut added a commit to adriantaut/aws-cdk that referenced this issue Nov 9, 2020
…kStage addApplication()

Currently there is no way of reordering stages/actions once they are created. Getting to

the Prepare and Execute change set actions while adding an application stage, we identified a

use case within our company that needs one or more intermediary sequential actions before

actually executing the change set. To resolve the problem, I suggest extending

the AddStageOptions interface with an optional property representing the number of

intermediary actions you need room for.

Closes aws#11333
adriantaut added a commit to adriantaut/aws-cdk that referenced this issue Nov 9, 2020
…kStage addApplication()

Currently there is no way of reordering stages/actions once they are created. Getting to

the Prepare and Execute change set actions while adding an application stage, we identified a

use case within our company that needs one or more intermediary sequential actions before

actually executing the change set. To resolve the problem, I suggest extending

the AddStageOptions interface with an optional property representing the number of

intermediary actions you need room for.

Closes aws#11333
adriantaut added a commit to adriantaut/aws-cdk that referenced this issue Nov 9, 2020
…kStage addApplication()

Currently there is no way of reordering stages/actions once they are created. Getting to

the Prepare and Execute change set actions while adding an application stage, we identified a

use case within our company that needs one or more intermediary sequential actions before

actually executing the change set. To resolve the problem, I suggest extending

the AddStageOptions interface with an optional property representing the number of

intermediary actions you need room for.

Closes aws#11333
adriantaut added a commit to adriantaut/aws-cdk that referenced this issue Nov 9, 2020
…kStage addApplication()

Currently there is no way of reordering stages/actions once they are created. Getting to

the Prepare and Execute change set actions while adding an application stage, we identified a

use case within our company that needs one or more intermediary sequential actions before

actually executing the change set. To resolve the problem, I suggest extending

the AddStageOptions interface with an optional property representing the number of

intermediary actions you need room for.

Closes aws#11333
@adriantaut
Copy link
Contributor Author

@rix0rrr I've implemented the above in #11376, a review would be highly appreciated! Thanks a lot 💯

@SomayaB SomayaB added in-progress This issue is being actively worked on. and removed needs-triage This issue or PR still needs to be triaged. labels Nov 9, 2020
adriantaut added a commit to adriantaut/aws-cdk that referenced this issue Nov 10, 2020
…kStage addApplication()

naming changes as per reviewer recommendation

Closes aws#11333
@mergify mergify bot closed this as completed in #11376 Nov 10, 2020
mergify bot pushed a commit that referenced this issue Nov 10, 2020
…kStage addApplication() (#11376)

Currently there is no way of reordering stages/actions once they are created. Getting to the Prepare and Execute change set actions while adding an application stage, we identified a use case within our company that needs one or more intermediary sequential actions before actually executing the change set. Moreover, I can imagine there can be plenty of use cases with similar requirements of having certain actions to fulfil between the Prepare and actual Execution of the Change Sets.

To resolve the problem, I suggest extending the AddStageOptions interface with an optional property representing the number of intermediary actions you need room for.

Closes #11333


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/pipelines CDK Pipelines library effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. good first issue Related to contributions. See CONTRIBUTING.md in-progress This issue is being actively worked on. p2
Projects
None yet
3 participants