question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple S3SourceActions returns "already a Construct with name" error

See original GitHub issue

When adding more than one S3SourceAction to a pipeline I get a duplicate Construct name error.

jsii.errors.JSIIError: There is already a Construct with name ‘joetestintegrationpipelinePipeline5832AB7ESourceEventRule’ in Bucket [Bucket]

Reproduction Steps

from aws_cdk import (
    aws_codepipeline_actions as actions,
    aws_codepipeline as pipe,
    aws_s3 as s3,
    core
)

class MyStack(core.Stack):
    def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:
        super().__init__(scope, id, **kwargs)

        pipeline = pipe.Pipeline(self, "Pipeline")
        pipe_bucket = s3.Bucket(self, "Bucket", versioned=True)
        action1 = actions.S3SourceAction(
            bucket=pipe_bucket,
            bucket_key='test1',
            output=pipe.Artifact(),
            action_name='test1',
            trigger=actions.S3Trigger.EVENTS
        )
        action2 = actions.S3SourceAction(
            bucket=pipe_bucket,
            bucket_key='test2',
            output=pipe.Artifact(),
            action_name='test2',
            trigger=actions.S3Trigger.EVENTS
        )

        source_stage = pipeline.add_stage(
            stage_name='Source',
            actions=[action1, action2])


Error Log

jsii.errors.JavaScriptError: 
  Error: There is already a Construct with name 'joetestintegrationpipelinePipeline5832AB7ESourceEventRule' in Bucket [Bucket]
      at ConstructNode.addChild (/tmp/jsii-kernel-iAn6en/node_modules/@aws-cdk/core/lib/construct.js:420:19)
      at new ConstructNode (/tmp/jsii-kernel-iAn6en/node_modules/@aws-cdk/core/lib/construct.js:33:24)
      at new Construct (/tmp/jsii-kernel-iAn6en/node_modules/@aws-cdk/core/lib/construct.js:460:21)
      at new Resource (/tmp/jsii-kernel-iAn6en/node_modules/@aws-cdk/core/lib/resource.js:13:9)
      at new Rule (/tmp/jsii-kernel-iAn6en/node_modules/@aws-cdk/aws-events/lib/rule.js:14:9)
      at Bucket.onCloudTrailEvent (/tmp/jsii-kernel-iAn6en/node_modules/@aws-cdk/aws-s3/lib/bucket.js:49:22)
      at Bucket.onCloudTrailPutObject (/tmp/jsii-kernel-iAn6en/node_modules/@aws-cdk/aws-s3/lib/bucket.js:73:27)
      at S3SourceAction.bound (/tmp/jsii-kernel-iAn6en/node_modules/@aws-cdk/aws-codepipeline-actions/lib/s3/source-action.js:43:31)
      at S3SourceAction.bind (/tmp/jsii-kernel-iAn6en/node_modules/@aws-cdk/aws-codepipeline-actions/lib/action.js:23:21)
      at Kernel._wrapSandboxCode (/home/jlawson/src/codecommit/pipeline-cdk/.env/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:7253:19)
      at /home/jlawson/src/codecommit/pipeline-cdk/.env/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:6631:25
      at Kernel._ensureSync (/home/jlawson/src/codecommit/pipeline-cdk/.env/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:7226:20)
      at Kernel.invoke (/home/jlawson/src/codecommit/pipeline-cdk/.env/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:6630:26)
      at KernelHost.processRequest (/home/jlawson/src/codecommit/pipeline-cdk/.env/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:6327:28)
      at KernelHost.run (/home/jlawson/src/codecommit/pipeline-cdk/.env/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:6270:14)
      at Immediate._onImmediate (/home/jlawson/src/codecommit/pipeline-cdk/.env/lib/python3.7/site-packages/jsii/_embedded/jsii/jsii-runtime.js:6273:37)

Environment

  • CLI Version : 1.9.0 (build 30f158a)
  • Framework Version: 1.9.0
  • OS : Arch Linux
  • Language : Python 3.7

Other

N/A


This is 🐛 Bug Report

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
skinny85commented, Sep 25, 2019

Thanks for opening the issue @joekiller . You’re correct; a quick way to unblock yourself is to change one the of those actions.S3Trigger.EVENTS to actions.S3Trigger.POLL.

I’ll see what I can do here - the edge case here is that you’re using the same bucket twice in the pipeline, with different paths, which we didn’t anticipate.

0reactions
skinny85commented, Oct 15, 2019

NP @joekiller , glad it’s working now!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Solving There is Already a Construct with Name Error in CDK
To solve the "There is Already a Construct with Name" error we have to only provide unique IDs to constructs in the same...
Read more >
class Stack (construct) · AWS CDK
Returns the list of notification Amazon Resource Names (ARNs) for the current stack. partition. Type: string. The partition in which this stack is...
Read more >
A brand new website interface for an even better experience!
Multiple S3SourceActions returns "already a Construct with name" error.
Read more >
AWS CDK ERROR: There is already a Construct with name ...
In my original code, I was just passing the id two both construct, which was causing this error. constructor(scope: cdk.Construct, id: string, ...
Read more >
@aws-cdk/assert | Yarn - Package Manager
python: NameError: name 'SubnetSelection' is not defined (#21790 ... API previously returned a list of resources, but now returns a map of logical...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found