aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.47k stars 3.83k forks source link

(aws-cdk-lib/pipelines): (muliple s3 sources from same bucket fails) #19875

Open mariusingjer opened 2 years ago

mariusingjer commented 2 years ago

Describe the bug

I add two files from the same s3 bucket as source:

    new pipelines.CodePipeline(this, 'pipeline', {
      synth: new pipelines.ShellStep('Build-codepipeline-and-self-update', {
        input: pipelines.CodePipelineSource.s3(
          artifactsBucket,
          'some-artifact.zip', {
          trigger: cdk.aws_codepipeline_actions.S3Trigger.NONE,
          actionName: 'source-nr-1'
        }),
        additionalInputs: {
          'somewhere': pipelines.CodePipelineSource.s3(
            artifactsBucket,
            'another-key-same-bucket.zip', {
            trigger: cdk.aws_codepipeline_actions.S3Trigger.NONE,
            actionName: 'source-nr-2'
          }),
        },
        commands: [
          '...',
        ],
      }),
    });

Fails with:

Error: Node with duplicate id: c8e9dd64d043805dea2bbc5f5d6ff6c442e1330971
    at Graph.add (C:\Kildekode\github\bsf-innsikt\deploy\service\node_modules\aws-cdk-lib\pipelines\lib\helpers-internal\graph.ts:180:15)
    at PipelineGraph.addAndRecurse (C:\Kildekode\github\bsf-innsikt\deploy\service\node_modules\aws-cdk-lib\pipelines\lib\helpers-internal\pipeline-graph.ts:266:12)
    at PipelineGraph.addAndRecurse (C:\Kildekode\github\bsf-innsikt\deploy\service\node_modules\aws-cdk-lib\pipelines\lib\helpers-internal\pipeline-graph.ts:270:33)
    at PipelineGraph.addBuildStep (C:\Kildekode\github\bsf-innsikt\deploy\service\node_modules\aws-cdk-lib\pipelines\lib\helpers-internal\pipeline-graph.ts:114:17)
    at new PipelineGraph (C:\Kildekode\github\bsf-innsikt\deploy\service\node_modules\aws-cdk-lib\pipelines\lib\helpers-internal\pipeline-graph.ts:74:29)
    at CodePipeline.doBuildPipeline (C:\Kildekode\github\bsf-innsikt\deploy\service\node_modules\aws-cdk-lib\pipelines\lib\codepipeline\codepipeline.ts:371:25)
    at CodePipeline.buildPipeline (C:\Kildekode\github\bsf-innsikt\deploy\service\node_modules\aws-cdk-lib\pipelines\lib\main\pipeline-base.ts:120:10)
    at new CodePipelineStack (C:\Kildekode\github\bsf-innsikt\deploy\service\lib\deploy-everything\code-pipeline-stack.ts:228:21)
    at main (C:\Kildekode\github\bsf-innsikt\deploy\service\bin\pipeline.ts:52:5)
    at Object.<anonymous> (C:\Kildekode\github\bsf-innsikt\deploy\service\bin\pipeline.ts:61:1)

Expected Behavior

Should not fail

Current Behavior

Throws error

Reproduction Steps

See above

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.20.0

Framework Version

No response

Node.js Version

16.14.2

OS

Windows 10

Language

Typescript

Language Version

No response

Other information

No response

mariusingjer commented 2 years ago

A workaround is to import the same source bucket twice in the stack.

    new pipelines.CodePipeline(this, 'pipeline', {
      synth: new pipelines.ShellStep('Build-codepipeline-and-self-update', {
        input: pipelines.CodePipelineSource.s3(
          bucket: // import bucket first time here,
          'some-artifact.zip', {
          trigger: cdk.aws_codepipeline_actions.S3Trigger.NONE,
          actionName: 'source-nr-1'
        }),
        additionalInputs: {
          'somewhere': pipelines.CodePipelineSource.s3(
            bucket: // import bucket second time here,
            'another-key-same-bucket.zip', {
            trigger: cdk.aws_codepipeline_actions.S3Trigger.NONE,
            actionName: 'source-nr-2'
          }),
        },
        commands: [
          '...',
        ],
      }),
    });