Thanks for sharing your solution, @massung!
Although it came too late to help you this time, it might interest you to know that we’ve been working on a specialized feature for renaming and moving resources which is currently in the v1.1 alpha releases and expected for Terraform v1.1.
Based on what you described here, I think this new feature would’ve given you a more direct path of just adding a moved
block to your configuration to record that you renamed the resource:
moved {
from = aws_iam_group.foo
to = aws_iam_group.bar
}
I’m sorry this feature is coming too late to help you with this particular situation, but hopefully if someone else finds this topic in future the new feature will either be already shipped or closer to shipping, and I hope it can also help you with similar refactoring efforts in the future!