-
Notifications
You must be signed in to change notification settings - Fork 613
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
hclwrite: Add RenameAttribute on Body #506
Conversation
Hi @raymyers! Thanks for working on this. I agree that this seems like a valuable thing for A hypothetical What do you think? 🤔 |
This makes sense, I've renamed Thanks for reviewing! |
04ad5d1
to
b9b4a14
Compare
Looks like CI has some linux-only failures in |
@apparentlymart Would you be able to approve the workflow to run the build? |
Hi @raymyers @apparentlymart, Thank you for working on this! Is there anything I can help move this forward? I have another use case. Upgrading Terraform AWS provider v3 to v4 requires renaming some attributes. I’m currently removing an old attribute and adding a new one, which causes a loss of comments. |
Hi, I have another use case. Terraform v1.10 introduced DynamoDB-free S3-native state locking in the s3 backend, and the upcoming Terraform v1.11 will start deprecating the old dynamodb_table attribute and recommend using the new use_lockfile. hashicorp/terraform#36257 It's easy to rewrite a few files by hand, but I need to rewrite 300+ backend configurations across some repositories. I will not be alone in this transition because the dynamodb_table attribute has long been recommended as a best practice. I believe the pattern "attribute A is deprecated, use B instead” is a generic use case. The current functionality only allows removing the old attribute and appending a new one to the end, which changes the order of the attributes. I don't want to change the order because meaningful order contributes to reducing cognitive load. Please let me know if there is anything I can do to help move this issue forward. |
Yet another use case: #680 |
If this patch is merged, I can provide a command line interface for this feature. See minamijoyo/hcledit#111 for details. |
Hi @minamijoyo, I'll re-raise this in triage next week. Thanks! |
Hi @crw, I appreciate your support. Hi @raymyers, Thank you for working on this. I need this functionality as well. As this branch looks so old, its CI check status is pending now. Can you rebase this patch on the latest main branch and see if all CI checks have been passed? Please let me know if you are too busy to do so; then, I can take it over and create a new pull request. |
a5ac2ee
to
1ad7abd
Compare
Right behind ya! Rebased, thanks for reviving this and generally for your work on Terraform refactoring support. |
@raymyers Thanks for your quick response 🤗 |
@hashicorp/team-ip-compliance we will need your approval to move this review forward, either before or after the core team reviews it. Thanks! |
Thanks to all who worked on this 🎉 |
The patch for upstream needed to implement the attribute mv/replace command has been merged. hashicorp/hcl#506 So use the latest main branch of upstream instead of the forked version.
Adding the ability to change the name of an attribute already set on a block body. This can be used to automate renaming of terraform
locals
.Without this, the only obvious approach is to remove the current attribute and add a new one, but this loses the order and comments which isn't desirable.
Usage
UPDATE