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

CDKPipelines: cyclic reference when using cross-region actions #26691

Open
ldecaro opened this issue Aug 9, 2023 · 3 comments
Open

CDKPipelines: cyclic reference when using cross-region actions #26691

ldecaro opened this issue Aug 9, 2023 · 3 comments
Labels
@aws-cdk/pipelines CDK Pipelines library bug This issue is a bug. effort/medium Medium work item – several days of effort p2

Comments

@ldecaro
Copy link

ldecaro commented Aug 9, 2023

Describe the bug

A cyclic dependency is created when:

  • I create a cross-Region pipeline for regions A (us-west-2) and B (us-east-1)
  • that pipeline has a cross-region action in one of the stages
  • that cross-region action uses files that need to be transferred from region A to region B
  • a cross-region-stack-111111111111:us-east-1 deploys the replication bucket in region B

Expected Behavior

CDKPipelines creates and manages the cross-region stack and the role that the cross-region action is using. It needs to take care of how it manages dependencies and avoid throwing an error the user cannot fix.

Current Behavior

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:java (default-cli) on project service: An exception occured while executing the Java class. Error: 'DemoToolchain' depends on 'cross-region-stack-742584497250:us-east-1' ({DemoToolchain}.addDependency({cross-region-stack-742584497250:us-east-1})). Adding this dependency (replication bucket {cross-region-stack-742584497250:us-east-1/Default/CrossRegionCodePipelineReplicationBucket} to action role {DemoToolchain/Pipeline-Demo/Pipeline/UAT/Deploy/CodePipelineActionRole}) would create a cyclic reference.
[ERROR] @jsii/kernel.RuntimeError: Error: 'DemoToolchain' depends on 'cross-region-stack-742584497250:us-east-1' ({DemoToolchain}.addDependency({cross-region-stack-742584497250:us-east-1})). Adding this dependency (replication bucket {cross-region-stack-742584497250:us-east-1/Default/CrossRegionCodePipelineReplicationBucket} to action role {DemoToolchain/Pipeline-Demo/Pipeline/UAT/Deploy/CodePipelineActionRole}) would create a cyclic reference.
[ERROR]     at Kernel._Kernel_ensureSync (/private/var/folders/cx/_x5h45_j4j9287h_zmrdtz61lnbmp0/T/jsii-java-runtime18290442372859984211/lib/program.js:10385:23)
[ERROR]     at Kernel.invoke (/private/var/folders/cx/_x5h45_j4j9287h_zmrdtz61lnbmp0/T/jsii-java-runtime18290442372859984211/lib/program.js:9749:102)
[ERROR]     at KernelHost.processRequest (/private/var/folders/cx/_x5h45_j4j9287h_zmrdtz61lnbmp0/T/jsii-java-runtime18290442372859984211/lib/program.js:11598:36)
[ERROR]     at KernelHost.completeCallback (/private/var/folders/cx/_x5h45_j4j9287h_zmrdtz61lnbmp0/T/jsii-java-runtime18290442372859984211/lib/program.js:11585:33)
[ERROR]     at KernelHost.processRequest (/private/var/folders/cx/_x5h45_j4j9287h_zmrdtz61lnbmp0/T/jsii-java-runtime18290442372859984211/lib/program.js:11627:24)
[ERROR]     at KernelHost.completeCallback (/private/var/folders/cx/_x5h45_j4j9287h_zmrdtz61lnbmp0/T/jsii-java-runtime18290442372859984211/lib/program.js:11585:33)
[ERROR]     at KernelHost.processRequest (/private/var/folders/cx/_x5h45_j4j9287h_zmrdtz61lnbmp0/T/jsii-java-runtime18290442372859984211/lib/program.js:11627:24)
[ERROR]     at KernelHost.completeCallback (/private/var/folders/cx/_x5h45_j4j9287h_zmrdtz61lnbmp0/T/jsii-java-runtime18290442372859984211/lib/program.js:11585:33)
[ERROR]     at KernelHost.processRequest (/private/var/folders/cx/_x5h45_j4j9287h_zmrdtz61lnbmp0/T/jsii-java-runtime18290442372859984211/lib/program.js:11627:24)
[ERROR]     at KernelHost.completeCallback (/private/var/folders/cx/_x5h45_j4j9287h_zmrdtz61lnbmp0/T/jsii-java-runtime18290442372859984211/lib/program.js:11585:33)
[ERROR] @jsii/kernel.RuntimeError: Error: 'DemoToolchain' depends on 'cross-region-stack-742584497250:us-east-1' ({DemoToolchain}.addDependency({cross-region-stack-742584497250:us-east-1})). Adding this dependency (replication bucket {cross-region-stack-742584497250:us-east-1/Default/CrossRegionCodePipelineReplicationBucket} to action role {DemoToolchain/Pipeline-Demo/Pipeline/UAT/Deploy/CodePipelineActionRole}) would create a cyclic reference.

Reproduction Steps

Possible Solution

N/A

Additional Information/Context

It works well in different scenarios:

  • single region action
  • cross-account action
  • cross-account and cross-region action

CDK CLI Version

2.79.0

Framework Version

No response

Node.js Version

18.10.0

OS

macos and windows

Language

Java

Language Version

Java(8) and Java (11)

Other information

I wonder whether it relates to the following issue:

#25605. Reason I say this is because we have a scenario with two stacks and a replication bucket similar to the scenario described in this issue. Here, this is all managed by CDK.

@ldecaro ldecaro added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Aug 9, 2023
@github-actions github-actions bot added the @aws-cdk/pipelines CDK Pipelines library label Aug 9, 2023
@pahud
Copy link
Contributor

pahud commented Aug 14, 2023

Did you see this error when you cdk synth?

I just opened your repo with gitpod and run npx cdx synth, there's no error here.

@pahud pahud added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. p2 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Aug 14, 2023
@ldecaro
Copy link
Author

ldecaro commented Aug 14, 2023

Did you see this error when you cdk synth?

I just opened your repo with gitpod and run npx cdx synth, there's no error here.

You probably missed this step from the reproduction steps:

Change this and update the line 34 pointing SERVICE_REGION = 'us-east-1' (any region diffferent than "us-west-2")

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Aug 14, 2023
@ldecaro
Copy link
Author

ldecaro commented Oct 6, 2023

Hi, this error persists in CDK 2.99.1. Do you think it is possible to run it once to reproduce the error?
I created a branch:

  • git clone -b bug-report https://github.com/aws-samples/bluegreen-to-amazon-ecs-using-aws-cdk-aws-codedeploy.git
  • mvn clean package
  • cdk synth

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/pipelines CDK Pipelines library bug This issue is a bug. effort/medium Medium work item – several days of effort p2
Projects
None yet
Development

No branches or pull requests

2 participants