Skip to content

(pipelines): generates warning since CDK 2.128.0 due to addition of v2 pipeline support in aws-codepipeline #29190

@gossandr

Description

@gossandr

Describe the bug

pipelines is the opinionated construct library for creating codepipelines. while not labeled as such, i think it is a L3 Pattern Construct.

Since CDK 2.128.0, this construct generates a warning because PipelineType is not being provided when pipelines creates the aws-codepipeline.

This warning should have been caught before the release of 2.128.0, but instead the test that caught it was changed to effectively check nothing. See 40ffe2b#diff-8e15d23929b5ff6c128d73523da6a4322f975856fea30df4f969a21edf5f4eb2

I'm calling this an introduced bug because it breaks when running cdk synth --strict

Expected Behavior

I expect pipelines to not generate this warning by properly providing PipelineType when creating the underlying code pipeline resource.

Current Behavior

Currently it generates a warning like this: [Warning at example] V1 pipeline type is implicitly selected when pipelineType is not set. If you want to use V2 type, set PipelineType.V2. [ack: @aws-cdk/aws-codepipeline:unspecifiedPipelineType]

This warning will cause cdk synth strict to fail, which breaks numerous pipleines of ours based on the pipelines library.

Reproduction Steps

see example code from the docs

import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
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 pipeline = new CodePipeline(this, 'Pipeline', {
      pipelineName: 'MyPipeline',
      synth: new ShellStep('Synth', {
        input: CodePipelineSource.gitHub('OWNER/REPO', 'main'),
        commands: ['npm ci', 'npm run build', 'npx cdk synth']
      })
    });
  }
}

Possible Solution

For example, in this code block: https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/pipelines/lib/codepipeline/codepipeline.ts#L467-L480

change it to look something like this:

    } else {
      this._pipeline = new cp.Pipeline(this, 'Pipeline', {
        pipelineName: this.props.pipelineName,
        pipelineType: cp.PipelineType.V1,
        crossAccountKeys: this.props.crossAccountKeys ?? false,
        crossRegionReplicationBuckets: this.props.crossRegionReplicationBuckets,
        reuseCrossRegionSupportStacks: this.props.reuseCrossRegionSupportStacks,
        // This is necessary to make self-mutation work (deployments are guaranteed
        // to happen only after the builds of the latest pipeline definition).
        restartExecutionOnUpdate: true,
        role: this.props.role,
        enableKeyRotation: this.props.enableKeyRotation,
        artifactBucket: this.props.artifactBucket,
      });
    }

Additional Information/Context

No response

CDK CLI Version

2.128.0

Framework Version

No response

Node.js Version

18.2.0

OS

macos

Language

TypeScript

Language Version

No response

Other information

This was also mentioned in #29146 but this issue is looking to add v2 support. I haven't dug that deep to see how much other things would have to change to support that. This issue is merely looking to resolve the warning introduced. While this warning is suppressible, it isn't intuitive. Pipelines should at a minimum provide the PipelineType when it creates the pipeline to prevent this warning from being geneerated. v2 support as mentioned in the other issue would also resolve this, but I assume it takes longer than simply fixing this bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/pipelinesCDK Pipelines librarybugThis issue is a bug.effort/mediumMedium work item – several days of effortp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions