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

CDK Pipelines: Circular dependency on initial CDK Deploy #18673

Closed
ewang101 opened this issue Jan 26, 2022 · 10 comments · Fixed by #18686
Closed

CDK Pipelines: Circular dependency on initial CDK Deploy #18673

ewang101 opened this issue Jan 26, 2022 · 10 comments · Fixed by #18686
Assignees
Labels
@aws-cdk/pipelines CDK Pipelines library bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. p0

Comments

@ewang101
Copy link

ewang101 commented Jan 26, 2022

What is the problem?

I am trying to deploy a pipeline using the aws-cdk/pipelines library and I am receiving a circular dependency error. I have no other resources in this stack other than the pipeline itself.

Reproduction Steps

Outer Stack:

import 'source-map-support/register';
import * as cdk from 'aws-cdk-lib';
import { SplitMonitorStackStack } from '../lib/MainPipelineStack';

const app = new cdk.App();
new SplitMonitorStackStack(app, 'SplitMonitorMainStack');
app.synth();

Inner Stack:


import { Stack, StackProps,SecretValue} from 'aws-cdk-lib';
import { Construct } from 'constructs'; // construct is in a separate package
import * as pipelines from 'aws-cdk-lib/pipelines';

export class SplitMonitorStackStack extends Stack {
  constructor(scope: Construct, id: string, props?: StackProps) {
    super(scope, id, props);


    const splitMonitoringStackPipeline = new pipelines.CodePipeline(this, "pipeline", {
      pipelineName: "Split-Monitor-Main",
      synth: new pipelines.ShellStep('Synth', {
          input: pipelines.CodePipelineSource.gitHub('PlaceholderRepoName', "main", {
            authentication: SecretValue.secretsManager('Token'),
          }),
          commands: [
            'npm install -g aws-cdk@latest',
            'npm ci',
            'npm run build',
            'npx cdk synth',
          ],
        }),
        crossAccountKeys: true
    });

  }
}

What did you expect to happen?

The pipeline and CDK deploy do be successful.

What actually happened?

SplitMonitorMainStack failed: Error [ValidationError]: Circular dependency between resources: [pipelineUpdatePipelineSelfMutation14A96D2F, pipelinePipelineBuildSynthCdkBuildProject4237770A, pipelinePipelineBuildSynthCdkBuildProjectRoleDefaultPolicyB3981181, pipelineUpdatePipelineSelfMutationRoleDefaultPolicy095404B8, pipelinePipeline4163A4B1, pipelinePipelineUpdatePipelineSelfMutateCodePipelineActionRoleDefaultPolicy09E3C254, pipelinePipelineSourceIvellaSplitMonitorStackWebhookResource4158C29A, pipelinePipelineBuildSynthCodePipelineActionRoleDefaultPolicy7B8E3FCA] at Request.extractError (/opt/homebrew/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/protocol/query.js:50:29) at Request.callListeners (/opt/homebrew/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/sequential_executor.js:106:20) at Request.emit (/opt/homebrew/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/sequential_executor.js:78:10) at Request.emit (/opt/homebrew/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/request.js:686:14) at Request.transition (/opt/homebrew/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/request.js:22:10) at AcceptorStateMachine.runTo (/opt/homebrew/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/state_machine.js:14:12) at /opt/homebrew/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/state_machine.js:26:10 at Request.<anonymous> (/opt/homebrew/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/request.js:38:9) at Request.<anonymous> (/opt/homebrew/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/request.js:688:12) at Request.callListeners (/opt/homebrew/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/sequential_executor.js:116:18) { code: 'ValidationError', time: 2022-01-26T18:54:30.449Z, requestId: '913f9618-4a60-483a-b8b4-aec4be38998a', statusCode: 400, retryable: false, retryDelay: 755.4424894449671 } Circular dependency between resources: [pipelineUpdatePipelineSelfMutation14A96D2F, pipelinePipelineBuildSynthCdkBuildProject4237770A, pipelinePipelineBuildSynthCdkBuildProjectRoleDefaultPolicyB3981181, pipelineUpdatePipelineSelfMutationRoleDefaultPolicy095404B8, pipelinePipeline4163A4B1, pipelinePipelineUpdatePipelineSelfMutateCodePipelineActionRoleDefaultPolicy09E3C254, pipelinePipelineSourceIvellaSplitMonitorStackWebhookResource4158C29A, pipelinePipelineBuildSynthCodePipelineActionRoleDefaultPolicy7B8E3FC

CDK CLI Version

2.9.0

Framework Version

No response

Node.js Version

v16.13.0

OS

macOS Monterey

Language

Typescript

Language Version

No response

Other information

No response

@ewang101 ewang101 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 26, 2022
@github-actions github-actions bot added the @aws-cdk/pipelines CDK Pipelines library label Jan 26, 2022
@ewang101
Copy link
Author

I downgraded my CDK version to 2.3.0 and I was able to successfully deploy the pipeline

@psoaresgit
Copy link

@rix0rrr it seems it might be the reference to the CodePipeline resource for it's name to add to the the CodeBuild Project description that is creating the circular dependency. #18492

@mrpackethead
Copy link

I can confirm the same error, in my pipelines as well, pinned aws-cdk-lib to 2.8.0 and the problem goes away.

@rix0rrr , when you come are online, and if you are looking at it, i'll be online till around around 10:30 am UTC

@AlessandroVol23
Copy link

AlessandroVol23 commented Jan 27, 2022

I got kinda a similar problem. Not sure if it relates

CDK 2.8.0
Synth works with

    const stackA = new StackA(this, "A");
    const stackB = new StackB(this, "B");
    stackB.addDependency(stackA);

CDK Synth fails with circular dependency

    const stackA = new StackAthis, "A");

    const stackB = new StackB(this, "B", {prop: stackA.prop);
    stackB.addDependency(stackA);

Not sure if this is intendend but I wouldn't see why

Update:
Okay error comes just if I try granting some permissions in stack B to the resource prop of stackA. Still don't understand it but maybe not the same error here.

@wjax
Copy link

wjax commented Jan 27, 2022

Uau,

I am having the same problem.
Deleted everything, reboot strap etc and in the end it is a 2.9.0 issue!!

@markusl
Copy link
Contributor

markusl commented Jan 27, 2022

We are seeing this as well

@wilhen01
Copy link
Contributor

wilhen01 commented Jan 27, 2022

Also seeing this issue with existing pipelines attempting to self mutate on upgrade to 2.9.0. Will revert to 2.8.0 in our pipelines...

EDIT: Pipelines reverted to 2.8.0, can confirm the issue is resolved.

@LukvonStrom
Copy link
Contributor

LukvonStrom commented Jan 27, 2022

@rix0rrr when removing ${options.pipeline.pipeline.pipelineName} from line f6dab8d#diff-44a0c126c8ec5cd427ab5acfc48dd3cdaefea1ffba3caf8892d829c5a56d5c30R276, everything works as expected - this is a regression introduced via #18492

LukvonStrom added a commit to LukvonStrom/aws-cdk that referenced this issue Jan 27, 2022
@rix0rrr rix0rrr added the p0 label Jan 27, 2022
@mergify mergify bot closed this as completed in #18686 Jan 28, 2022
mergify bot pushed a commit that referenced this issue Jan 28, 2022
A dependency cycle was inadvertently introduced to CDK Pipelines in #18492.

Fix that dependency cycle, and also one in Cognito IdentityPools.

Add facilities to the `assertions` library to automatically detect this in the future,
to stop errors like this from slipping in.

We could make it a separate assertion method
(`Template.fromStack().assertNoCycles()`), but the only thing that will
do is give you an opportunity to forget to put the test in.

Instead, we just check it by default for every generated template.

Fixes #18673.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@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.

@terryobot
Copy link

terryobot commented Feb 7, 2022

im still having this issue on python a version downgrade has not resolved it.
❌ TAPP-Infrastructure-Pipeline failed: Error [ValidationError]: Circular dependency between resources: [TappPipeline03E6EFD5, TappPipelineBuildSynthCodePipelineActionRoleDefaultPolicy0692F3F9, TappPipelineBuildSynthCdkBuildProject1ABF2DA8, TappPipelineSourceterryobotdevopsWebhookResourceDFC0CED5, TappPipelineBuildSynthCdkBuildProjectRoleDefaultPolicyB7B22B1C]
at Request.extractError (/usr/local/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/protocol/query.js:50:29)
at Request.callListeners (/usr/local/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at Request.emit (/usr/local/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/usr/local/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/request.js:686:14)
at Request.transition (/usr/local/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/usr/local/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /usr/local/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request. (/usr/local/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/request.js:38:9)
at Request. (/usr/local/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/request.js:688:12)
at Request.callListeners (/usr/local/lib/node_modules/aws-cdk/node_modules/aws-sdk/lib/sequential_executor.js:116:18) {
code: 'ValidationError',
time: 2022-02-07T10:14:20.629Z,
requestId: '721d0849-f24a-4c6f-bf8f-d715686bb81d',
statusCode: 400,
retryable: false,
retryDelay: 64.29169948893887
}
Circular dependency between resources: [TappPipeline03E6EFD5, TappPipelineBuildSynthCodePipelineActionRoleDefaultPolicy0692F3F9, TappPipelineBuildSynthCdkBuildProject1ABF2DA8, TappPipelineSourceterryobotdevopsWebhookResourceDFC0CED5, TappPipelineBuildSynthCdkBuildProjectRoleDefaultPolicyB7B22B1C]

TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this issue Feb 21, 2022
A dependency cycle was inadvertently introduced to CDK Pipelines in aws#18492.

Fix that dependency cycle, and also one in Cognito IdentityPools.

Add facilities to the `assertions` library to automatically detect this in the future,
to stop errors like this from slipping in.

We could make it a separate assertion method
(`Template.fromStack().assertNoCycles()`), but the only thing that will
do is give you an opportunity to forget to put the test in.

Instead, we just check it by default for every generated template.

Fixes aws#18673.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
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. needs-triage This issue or PR still needs to be triaged. p0
Projects
None yet
10 participants