- Newest
- Most votes
- Most comments
Found solution myself. Posting the answer here in case it might be useful.
Option 1
It is possible to do it by using an existing pipeline as described in the documentation. https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.pipelines-readme.html#using-an-existing-aws-codepipeline
One can create pre Synth stages and have more fine grained control over the build process.
Example from the documentation:
declare const codePipeline: codepipeline.Pipeline;
const sourceArtifact = new codepipeline.Artifact('MySourceArtifact');
const pipeline = new pipelines.CodePipeline(this, 'Pipeline', {
codePipeline: codePipeline,
synth: new pipelines.ShellStep('Synth', {
input: pipelines.CodePipelineFileSet.fromArtifact(sourceArtifact),
commands: ['npm ci','npm run build','npx cdk synth'],
}),
});
Option 2
It turned out that additionalInputs accept Step as a source. It is mentioned in the documentation as well
https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.pipelines-readme.html#synth-and-sources
Example from the documentation:
const prebuild = new pipelines.ShellStep('Prebuild', {
input: pipelines.CodePipelineSource.gitHub('myorg/repo1', 'main'),
primaryOutputDirectory: './build',
commands: ['./build.sh'],
});
const pipeline = new pipelines.CodePipeline(this, 'Pipeline', {
synth: new pipelines.ShellStep('Synth', {
input: pipelines.CodePipelineSource.gitHub('myorg/repo2', 'main'),
additionalInputs: {
'subdir': pipelines.CodePipelineSource.gitHub('myorg/repo3', 'main'),
'../siblingdir': prebuild,
},
commands: ['./build.sh'],
})
});
Option 2 is what I ended up with since it looks cleaner.
Hi, cdk --build option seems to be what you are looking for
See https://github.com/aws/aws-cdk/commit/eb9b8e23906e2e1375f45f795d71b905bc0a52af
Or type 'cdk build --help' on your laptop
Relevant content
- asked 3 months ago
- asked 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 9 months ago
- AWS OFFICIALUpdated a year ago
Thanks for the reply, @Didier_AWS. But it does not look like something I am after. I have updated the question .