Open Gary-Armstrong opened 7 years ago
You can also rename a resource into something that is not a recognized resource, which is then hard to fix without a manual edit. Definitely would like more guardrails.
I did the exact same thing once and had to pull my state file from remote and edit locally to fix it. Fortunately, the "type" property was still maintained so terraform plan/apply knew something was very wrong and aborted, but state mv couldn't fix it.
I wanted to rename a AWS SG rule resource but I accidentally did this:
I'd like to ask that TF not allow such terrible things without a force flag. I say force flag because I seem to all-too-frequently need to jump guardrails. I want to be alerted when I do dumb things but not outright prevented from doing dumb things.
Terraform Version
0.8.1
Affected Resource(s)
Core , presumably
Expected Behavior
I expected to "rename" a resource but I typoed the resource type. I'd expect TF to complain that I am changing one resource into another.
Actual Behavior
TF happily did what I said instead of what I wanted. Welcome to Computer!
Steps to Reproduce
Just use
state mv
to change aaws_security_group_rule
into aaws_security_group
. I haven't made time to test permutations of this with varying HCL and resource types, but it seems trivial.