Ccodemod

codemod/arm-hardcoded-apiversion

Inline statically resolvable Azure Resource Manager (ARM) template resource apiVersion expressions as hard-coded string literals.

transformationmigrationazurearmjson
Public
0 executions

Run locally

npx codemod @codemod/arm-hardcoded-apiversion

@codemod/arm-hardcoded-apiversion

Inline statically resolvable Azure Resource Manager (ARM) template resource apiVersion expressions as hard-coded string literals.

Installation

bash

Usage

This codemod targets ARM template JSON files and rewrites resource apiVersion values when the value can be resolved to a concrete string at codemod time.

  • Rewrites "apiVersion": "[parameters('name')]" when the referenced parameter has a string defaultValue
  • Rewrites "apiVersion": "[variables('name')]" when the referenced variable resolves to a string literal
  • Rewrites "apiVersion": "[concat(...)]" when every concat segment resolves to a string literal
  • Leaves unresolved expressions unchanged, including references without a string default and expressions that depend on runtime-only ARM functions

Example:

json

becomes:

json

Development

bash

License

MIT

Ready to contribute?

Build your own codemod and share it with the community.