Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CodePipeline: CodeBuildAppStack' depends on 'CodePipelineAppStack' cyclic reference #18671

Closed
AreebSiddiqui opened this issue Jan 26, 2022 · 4 comments
Assignees
Labels
@aws-cdk/aws-codepipeline Related to AWS CodePipeline bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@AreebSiddiqui
Copy link

AreebSiddiqui commented Jan 26, 2022

What is the problem?

I have two stacks.
One for CodeBuild and another for CodePipeline. I have been passing CodeBuild Stack into the CodePipeline Stack.

const codebuildStack = new CodeBuildStack(app, 'CodeBuildAppStack');

new CodePipeline(app, 'CodePipelineAppStack', codebuildStack);

This Gives me an error:

/node_modules/aws-cdk-lib/core/lib/stack.ts:395
throw new Error('${target.node.path}' depends on '${this.node.path}' (${cycle.join(', ')}). Adding this dependency (${reason}) would create a cyclic reference.);

The CodeBuildStacks works fine alone but once I pass this stack in CodePipelineStack the error pops up.

Reproduction Steps

CodePipeline.ts

export class CodePipeline extends Stack {
  public readonly SourceStage: codepipeline.IStage;
  public readonly BuildStage: codepipeline.IStage;
  public readonly DeployStage: codepipeline.IStage;
  public readonly codePipelineRole: iam.Role;

  constructor(scope: Construct, id: string, codeBuild: CodeBuildStack, props?: StackProps) {
    super(scope, id, props)
    this.codePipelineRole = new iam.Role(this, `CodePipelineRole`, {
      roleName: `CodePipelineRole`,
      assumedBy: new iam.ServicePrincipal('codebuild.amazonaws.com'),
      managedPolicies: [
        iam.ManagedPolicy.fromAwsManagedPolicyName(
          'AmazonEC2ContainerRegistryPowerUser',
        ),
      ]
    });
    
    const pipeline = new codepipeline.Pipeline(this, `MyCodePipeline`, {
      pipelineName: 'my-codepipeline',
      role:this.codePipelineRole,
      crossAccountKeys: false,
    });
    
    const sourceOutput = new codepipeline.Artifact();

    this.SourceStage = pipeline.addStage({
      stageName: 'Source',
      actions: [
        new codepipelineActions.CodeStarConnectionsSourceAction({
          actionName: 'Source',
          owner: `onwername`,
          repo: 'reponame',
          connectionArn:'my-arn',
          triggerOnPush:true,
          output: sourceOutput
        })
      ],
    })


    this.BuildStage = pipeline.addStage({
      stageName: 'Build',
      placement: {
        justAfter: this.SourceStage
      },
      actions: [
        new codepipelineActions.CodeBuildAction({
          actionName:'CodeBuild',
          input:sourceOutput,
          project: codeBuild.projectABC
        })
      ]
    })
  }
}

What did you expect to happen?

I am trying to use codebuild stack inside codepipeline stack.

What actually happened?

This Gives me an error:

/node_modules/aws-cdk-lib/core/lib/stack.ts:395
throw new Error('${target.node.path}' depends on '${this.node.path}' (${cycle.join(', ')}). Adding this dependency (${reason}) would create a cyclic reference.);

CDK CLI Version

2.8.0 (build 8a5eb49)

Framework Version

No response

Node.js Version

v16.6.2

OS

Ubuntu 20.04.1 LTS (fossa-beric-tgl X40)

Language

Typescript

Language Version

No response

Other information

No response

@AreebSiddiqui AreebSiddiqui added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 26, 2022
@peterwoodworth peterwoodworth changed the title CodePipeline: CodeBuildAppStack' depends on 'CodePipelineAppStack' cyclic reference CodePipeline: CodeBuildAppStack' depends on 'CodePipelineAppStack' cyclic reference Jan 26, 2022
@github-actions github-actions bot added the @aws-cdk/aws-codepipeline Related to AWS CodePipeline label Jan 26, 2022
@skinny85
Copy link
Contributor

Hey @AreebSiddiqui,

is the problem you're experiencing the same as in #3300?

Thanks,
Adam

@skinny85 skinny85 added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Jan 26, 2022
@AreebSiddiqui
Copy link
Author

AreebSiddiqui commented Jan 26, 2022

Hi @skinny85 ,
Yes, but a little different I am not targeting to deploy both stack in different accounts.

I need to deploy both stacks in same account.

@skinny85
Copy link
Contributor

I don't think cross-account is the crux of the problem in that issue either.

I'll close this as a duplicate, and let's move the conversation to #3300 - if you could post there, I would appreciate it.

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-codepipeline Related to AWS CodePipeline bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

2 participants