Skip to content

fix(pipelines): undeployable due to dependency cycle#18686

Merged
mergify[bot] merged 11 commits intomasterfrom
huijbers/dep-cycle
Jan 28, 2022
Merged

fix(pipelines): undeployable due to dependency cycle#18686
mergify[bot] merged 11 commits intomasterfrom
huijbers/dep-cycle

Conversation

@rix0rrr
Copy link
Copy Markdown
Contributor

@rix0rrr rix0rrr commented Jan 27, 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

We happily generate templates with dependency cycles. Those would be
undeployable in CloudFormation, so we should make it impossible that
templates like these pass unit test validation.

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.
@rix0rrr rix0rrr requested a review from a team January 27, 2022 11:10
@rix0rrr rix0rrr self-assigned this Jan 27, 2022
@gitpod-io
Copy link
Copy Markdown

gitpod-io bot commented Jan 27, 2022

@github-actions github-actions bot added the @aws-cdk/assertions Related to the @aws-cdk/assertv2 package label Jan 27, 2022
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Jan 27, 2022
@rix0rrr rix0rrr changed the title fix: dependency cycles fix(assertions): dependency cycles are not detected Jan 27, 2022
@rix0rrr rix0rrr changed the title fix(assertions): dependency cycles are not detected fix(pipelines): undeployable due to dependency cycle Jan 28, 2022
});
});

test('throws when given a templat with cyclic dependencies', () => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*template

// Don't know why this was added in the first place, but I'm disabling it for now and if
// no complaints come from this, we're probably safe to remove it altogether.
// attachment.node.addDependency(this);
Array.isArray(attachment);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It prevents an "unused variable" error :)

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Jan 28, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 6dd81c7
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 009d689 into master Jan 28, 2022
@mergify mergify bot deleted the huijbers/dep-cycle branch January 28, 2022 17:13
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Jan 28, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

Comment on lines +3 to +9
/**
* Check a template for cyclic dependencies
*
* This will make sure that we don't happily validate templates
* in unit tests that wouldn't deploy to CloudFormation anyway.
*/
export function checkTemplateForCyclicDependencies(template: Template): void {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So cool! 🎉

TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request 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/assertions Related to the @aws-cdk/assertv2 package contribution/core This is a PR that came from AWS.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CDK Pipelines: Circular dependency on initial CDK Deploy

6 participants