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

Implement basic resource equivalence #132

Open
otaviomacedo opened this issue Feb 25, 2025 · 0 comments
Open

Implement basic resource equivalence #132

otaviomacedo opened this issue Feb 25, 2025 · 0 comments

Comments

@otaviomacedo
Copy link
Contributor

To detect which resources should be refactored, we need to indentify which
resources have only changed their location, but have remained "the same", in
some sense. This can be made precise by defining an equivalence relation on
the set of resources.

Before that, let's define a digest function, d:

d(resource) = hash(type + properties + dependencies.map(d))

where hash is a cryptographic hash function. In other words, the hash
is computed from its type, its own properties (that is, excluding properties
that refer to other resources), and the digests of each of its dependencies.

The digest of a resource, defined recursively this way, remains stable even if
one or more of its dependencies gets renamed. Since the resources in a
CloudFormation template form an acyclic graph, this function is well-defined.

The equivalence relation then follows directly: two resources r1 and r2
are equivalent if d(r1) = d(r2).

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

1 participant