aws / aws/aws-cdk

(pipelines): allow builds to happen after UpdatePipeline

Open
#29,863 3 comments 1 reaction 0 assignees View on GitHub
@aws-cdk/core @aws-cdk/pipelines effort/medium feature-request p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the feature

Ability to specify an additional build step after `synth` and after `self-update` and use this as a source for later Stages.

### Use Case

Pretty frustrating that I can't do this - I am creating a Stack, which I put into a Stage. This works, except that

- I have to `cdk synth` in my Pipeline
- Which means that I have to build my source before performing the `synth` in order for the stack to pull Assets from the artifacts created by those tasks
- But the self-update does not trigger when I push updates to the build because the build has to happen first before the self-update. This is counter-intuitive. I have to manually perform stack updates through `cdk deploy` from my machine instead. and then when I push to my repo, it triggers another build again.

The intuitive solution if you're new to CDK (like I am) is to add a `Wave` to the Pipeline, before adding the Stage.

But the resulting Pipeline adds the "Assets" stage in between the UpdatePipeline stage and the Wave and there's no way to specify the Steps in the Wave as Outputs for the stack deployment Stage.

### Proposed Solution

Allow us to specify a CodeBuildStep as a source for later Stacks I guess? 🤷‍♂️

### Other Information

I've tried the following based on other topics along the same lines

- first calling `pipeline.buildPipeline()` then accessing the underlying pipeline to add an additional CodeBuildAction after the "self-update" action
- then trying to update the FileAsset CodeBuildActions to use different `input`
- this unfortunately fails as the CodeBuildActions are immutable after they are created

```typescript

const buildArtifact = new Artifact('custom_output')
const codeBuildAction = new CodeBuildAction({
actionName: 'Build',
project,
input: sourceArtifact,
outputs: [
buildArtifact,
],
runOrder: 2,
})

// pipeline.pipeline.stages[2] is the self-update stage. setting runOrder to 2 makes this run after the self-update.
pipeline.pipeline.stages[2].addAction(codeBuildAction)

for (const action of pipeline.pipeline.stages[3].actions) {
// neither of this seems to work
(action as unknown as any).props.inputs = [
buildArtifact,
];

(action as unknown as any).providedActionProperties.inputs = [
buildArtifact,
]
}
````

### Acknowledgements

- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change

### CDK version used

2.133

### Environment details (OS name and version, etc.)

os x

Contributor guide

Open the contributing guide

Research direction

Start with pipeline.buildPipeline(), pipeline.pipeline.stages, Wave, UpdatePipeline, and the CodeBuildAction usage shown in the issue. Trace how synth and self-update stages produce inputs for later Stages, then define how a post-synth or post-self-update CodeBuildStep can provide a source without mutating immutable actions. Done means later stack deployments can consume that build output and the pipeline updates when the build changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
ci-cd, cloud, devops
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.