Ccodemod

codemod/arm-redundant-resource-dependson

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().

transformationarmazurejsondependsOn
Public
0 executions

Run locally

npx codemod @codemod/arm-redundant-resource-dependson

@codemod/arm-redundant-resource-dependson

Remove redundant explicit dependsOn entries from Azure Resource Manager (ARM) JSON templates when the dependency is already implied by ARM evaluation semantics.

Installation

bash

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.

Example:

json

Becomes:

json

Development

bash

License

MIT

Ready to contribute?

Build your own codemod and share it with the community.