You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The proposal is to add a block to mark state to be removed from the state file.
The last few major Terraform releases has been good to us. We had moved, we got import, we got for_each over import blocks. With these, and the -replace flag, we can now prepare plans that encapsulate the entire transition of the infrastructure state, instead of doing:
Use terraform apply -replace=x over terraform taint x
Use import { from = x, to = y } over terraform import x y
Use moved { from = x, to = y } over terraform state mv x y
... but we have nothing for terraform state rm x
We support moving objects around, we support importing, but we cannot support un-importing. Being able to detach an object from being managed by Terraform during the application of a plan would prevent the last of our remaining needs to manually manipulate the state file. For now. :)
Attempted Solutions
Initial condition:
# main.tf:
resource "aws_vpc" "myvpc" {
...
}
resource "aws_vpc" "theirvpc" {
...
}
import {
id = "xxx"
to = aws_vpc.othervpc
}
moved {
from = aws_vpc.othervpc
to = aws_vpc.theirvpc
}
Now lets say that we have released this, and we either decide we've imported the wrong othervpc that has been moved to theirvpc. If we remove aws_vpc.their_vpc from main.tf, the object will be removed. In order to prevent this, we would do terraform state rm aws_vpc.theirvpc before applying these changes.
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Terraform Version
Use Cases
The proposal is to add a block to mark state to be removed from the state file.
The last few major Terraform releases has been good to us. We had
moved
, we gotimport
, we got for_each over import blocks. With these, and the-replace
flag, we can now prepare plans that encapsulate the entire transition of the infrastructure state, instead of doing:terraform apply -replace=x
overterraform taint x
import { from = x, to = y }
overterraform import x y
moved { from = x, to = y }
overterraform state mv x y
... but we have nothing for
terraform state rm x
We support moving objects around, we support importing, but we cannot support un-importing. Being able to detach an object from being managed by Terraform during the application of a plan would prevent the last of our remaining needs to manually manipulate the state file. For now. :)
Attempted Solutions
Initial condition:
Now lets say that we have released this, and we either decide we've imported the wrong
othervpc
that has been moved totheirvpc
. If we removeaws_vpc.their_vpc
frommain.tf
, the object will be removed. In order to prevent this, we would doterraform state rm aws_vpc.theirvpc
before applying these changes.Proposal
References
No response
The text was updated successfully, but these errors were encountered: