Skip to content

[aws-codepipeline] Cyclic reference error when importing an S3 bucket in a code pipeline defined in a different stack  #10896

@harshchhatwani

Description

@harshchhatwani

❓ General Issue

Hi- I am using CDK to create a code pipeline with an S3 bucket as its source. The S3 bucket and code pipeline are defined in different stacks and per the AWS documentation we can access resources in a different stack as long as they are in the same account and AWS region: https://docs.aws.amazon.com/cdk/latest/guide/resources.html#resource_stack

The Question

This doesn't seem to be working and I am getting a "Cyclic reference" error. Does this mean the AWS documentation is wrong? Or is there something in particular that's missing to make this work? Sample code below

        const pipelineSourceActionOutput = new Artifact();
        const pipelineSourceAction = new S3SourceAction({
            actionName: "S3SourceAction",
            bucket: s3Bucket, // Versioned Bucket (and CloudTrail) defined in a different stack
            bucketKey: `${id}/upload.zip`,
            output: pipelineSourceActionOutput,
            trigger: S3Trigger.EVENTS,
            runOrder: 1,
        });
        new Pipeline(this, pipelineId, {
            pipelineName: pipelineId,
            stages: [
                {
                    stageName: "Source",
                    actions: [pipelineSourceAction],
                }
            ],
        });

I think this line of code is causing the dependency of my stack containing S3 bucket on the stack that defined code pipeline infra: https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/aws-codepipeline-actions/lib/s3/source-action.ts#L120-L124

Environment

  • CDK CLI Version: 1.45.0
  • Module Version:
  • Node.js Version: 12.x.31654.0
  • OS: OSX Mojave
  • Language (Version): TypeScript

Other information

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-codepipelineRelated to AWS CodePipelinebugThis issue is a bug.effort/largeLarge work item – several weeks of effortp1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions