Skip to content

Pre-deployment check on circular dependencies possible? #191

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

Open
vicary opened this issue Sep 6, 2022 · 2 comments
Open

Pre-deployment check on circular dependencies possible? #191

vicary opened this issue Sep 6, 2022 · 2 comments

Comments

@vicary
Copy link
Contributor

vicary commented Sep 6, 2022

During a refactoring of our internal fork of this repo, we recently discovered the test util function doesNotBecomeCircular (linked below).

const doesNotBecomeCircular = function (resources) {
const memo = {};
Object.keys(resources).forEach(resourceName => {
const resource = resources[resourceName];
if (resource.DependsOn) {
resource.DependsOn.forEach(parent => {
if (!memo[parent]) {
memo[parent] = [resourceName];
} else {
memo[parent].push(resourceName);
}
});
}
});
return Object.keys(memo).every(parentName => memo[parentName].length <= 1);
};

We think this is a good starting point to detect potential errors before we wait for the long-running deployment process in CloudFormation, the situation gets significant for projects with more than 300 functions like ours. We have to wait for more than 1 hour just to discover this error.

This should also improve the situation in #20 #53 #83 #102 #105 #116 #122

@dougmoscrop Do you think this function is good enough as a pre-deployment assertion?

@dougmoscrop
Copy link
Owner

dougmoscrop commented Sep 6, 2022

Oh wow, an hour! Yeah. I think I have some util code that also finds references via intrinsic functions not just dependsOn, which would add more cases to this early* detection

@vicary
Copy link
Contributor Author

vicary commented Sep 6, 2022

I am excited to see it happen!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants