Remove redundant explicit dependsOn entries from Azure Resource Manager (ARM) JSON templates when the dependency is already implied by nested resources or by reference()/references()/list*() calls that target the same resourceId().
Remove redundant explicit dependsOn entries from Azure Resource Manager (ARM) JSON templates when the dependency is already implied by ARM evaluation semantics.
Installation
bash
# Install from registry
codemod run @codemod/arm-redundant-resource-dependson
# Or run locally
codemod run -w workflow.yaml
Usage
This codemod targets ARM template .json files and removes dependsOn entries in two conservative cases:
The resource already references the same template resource via reference(...), references(...), or a list* (...) function call whose first argument is the same resourceId(...) expression.
A nested child resource explicitly depends on its containing resource, even though that parent dependency is already implied by the nested resource relationship.
The codemod preserves dependsOn entries when it cannot prove the dependency is implicit. In particular, it leaves unrelated dependencies, non-resourceId(...) entries, and resources that only mention another resource ID as plain data unchanged.