Home > Blockchain >  AWS CDK V2: How to create CodePipeline Action Group within a Stage
AWS CDK V2: How to create CodePipeline Action Group within a Stage

Time:09-10

I have an AWS CodePipeline defined in AWS CDK V2 (Typescript). I'm looking to add an 'action group' to my beta deployment stage. Currently I only see a way to add a list of actions which all execute concurrently through the 'actions' property in the StageProps.

In the AWS console there is an option to add an action group that allows another set of actions which don't execute until the first set of actions complete (almost like a sub-stage). (You can view by going to your pipeline then Edit -> Edit Stage -> Add action group. (Sorry I don't have the reputation to upload a screenshot yet)

How do I define and add action groups to my CodePipeline in CDK? Is it even possible? I have some arrays of deployment actions that I want to run sequentially, however currently I am having to run them concurrently. I know I could just make a separate stage to run each list of actions but I would prefer to have them in the same stage.

Please see my pipeline code below:

let stagesToDeployInOrder = []
// Deploy infrastructure for each stageStageConfigurations.ACTIVE_STAGES.forEach((stage: Stage) => {
        const stageToDeploy: StageProps = {
            stageName: `${stage.stageType}`,
            transitionToEnabled: true,
            actions: [
                ...codeDeploymentManager.getDeploymentActionsForStage(stage.stageType),
                ...stage.stageDeploymentActions
            ]
        }
        
        stagesToDeployInOrder.push(stageToDeploy);
    });
    
    // Define Pipeline itself. Stages are in order of deployment.
    new Pipeline(this, `Code-pipeline`, {
        pipelineName: `ProjectNamePipeline`,
        crossAccountKeys: false,
        stages: stagesToDeployInOrder
    });

CodePudding user response:

You can create actions groups with the CDK by adding the key runOrder. If you want to run one or more actions sequentially you can give them the same runOrder. Any action with a higher runOrder will be run after the ones with a lower runOrder have been executed.

More details can be found in the documentation here

  • Related