Skip to content

Pre-deployment check on circular dependencies possible? #191

@vicary

Description

@vicary

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions