aws / aws/aws-cdk

> For some reason publishAssetsInParallel must be set true though (default). Otherwiese got "This BuildSpec contains CloudFormation references and is supported by publishInParallel=false" and the build failed.

Open
#29,028 0 comments 4 reactions 0 assignees View on GitHub
@aws-cdk/pipelines bug effort/medium p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

> For some reason publishAssetsInParallel must be set true though (default). Otherwise got "This BuildSpec contains CloudFormation references and is supported by publishInParallel=false" and the build failed.

Just banged my head on this for ~4~ 7 hours today... -_- This has to be a bug right?

_Originally posted by @cheruvian in https://github.com/aws/aws-cdk/issues/10999#issuecomment-1933638576_

CDK Pipelines (`CodePipeline`) fails if you add CloudFormation references (for example with `dockerCredentials`) and `publishAssetsInParallel=false`.

It looks like this is [caused here:](https://github.com/aws/aws-cdk/blob/431df3b67bc2dd2d0e833642a67cff890fc6be29/packages/aws-cdk-lib/pipelines/lib/codepipeline/codepipeline.ts#L858-L860)
```
// If we use a single publisher, pass buildspec via file otherwise it'll
// grow too big.
passBuildSpecViaCloudAssembly: this.singlePublisherPerAssetType,
```

This is then used in the [`CodePipelineFactory`](https://github.com/aws/aws-cdk/blob/431df3b67bc2dd2d0e833642a67cff890fc6be29/packages/aws-cdk-lib/pipelines/lib/codepipeline/private/codebuild-factory.ts#L263-L277)

```
if (this.props.passBuildSpecViaCloudAssembly) {
...
if (typeof fileContents !== 'string') {
throw new Error(`This BuildSpec contains CloudFormation references and is supported by publishInParallel=false: ${JSON.stringify(fileContents, undefined, 2)}`);
}
...
} else {
projectBuildSpec = actualBuildSpec;
}
```

So tl;dr; seems as though

1. Deploying BuildSpec via CloudAssembly is not possible (this makes sense)
2. BuildSpecs are passed via CloudAssembly only if `singlePublisherPerAssetType` (this maybe makes sense?)
3. `singlePublisherPerAssetType` is only set if `publishAssetsInParallel` is `true` (this doesn't make sense necessarily?)

FWIW setting `publishAssetsInParallel=false` is the recommendation from the `[aws-deployment-pipeline-reference-architecture](https://github.com/aws-samples/aws-deployment-pipeline-reference-architecture/blob/8e5989a467834fa3a6c84bbe79295641bc2361ed/examples/cdk-application-pipeline/infrastructure/src/pipeline.ts#L112)

Contributor guide

Open the contributing guide

Research direction

Start in packages/aws-cdk-lib/pipelines/lib/codepipeline/codepipeline.ts and follow passBuildSpecViaCloudAssembly into private/codebuild-factory.ts. Reproduce a CodePipeline with dockerCredentials or another CloudFormation reference and publishAssetsInParallel=false, then trace the singlePublisherPerAssetType decision. Done means that configuration no longer fails because the BuildSpec is passed through the Cloud Assembly.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
ci-cd, cloud, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.