Change key

Apache 2.0

Rename an HCL attribute while leaving its value intact. Attributes with a computed key, or with a sibling attribute or block already named newKey, are left unchanged.

org.openrewrite.hcl.ChangeKey

Required

A JSONPath expression locating the attribute to rename.

The new name of the attribute selected by oldKeyPath.

mod run . --recipe=org.openrewrite.hcl.ChangeKey \ -P oldKeyPath='$.resource.name' \ -P newKey=db_name

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.