I followed the Continuous integration and delivery (CI/CD) using CDK Pipelines guide to implement a CodePipeline. I would like to know how to add a stage to my pipeline in CDK that will run after the Source stage but before the Build stage.
This is my pipeline code:
import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { Repository } from 'aws-cdk-lib/aws-codecommit';
import { CodePipeline, CodePipelineSource, ShellStep } from 'aws-cdk-lib/pipelines';
export class MyPipelineStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const repo = Repository.fromRepositoryName(this, 'CogClientRepo', 'cog-client');
const pipeline = new CodePipeline(this, 'Pipeline', {
pipelineName: 'MyPipeline',
synth: new ShellStep('Synth', {
input: CodePipelineSource.codeCommit(repo, 'main'),
commands: ['npm ci', 'npm run build', 'npx cdk synth']
})
});
}
}
After running cdk deploy I see that I can add a stage betwen Source and Build using the console, but I would like this to be a part of the CDK code.

CDK version 2.3.0 written in TypeScript
I am using the more recent aws-cdk-lib.pipelines module and not the aws-cdk-lib.aws_codepipeline module.