-
Notifications
You must be signed in to change notification settings - Fork 54
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
Rename folder cause deletion #38
Comments
If you want to rename the folders in the Terraform state, you should use
|
I'm going to try this then ! Thanks for your quick response |
Ran into a similar issue with renaming already created folders via the module. Shouldn't the behavior of the module mimic that of the folder resource. When creating a folder with the folder resource, the folder
When doing the same with the module, create then change the name of the folder, it will destroy the folder and re create it to alter the If a folder is created via Terrafrom via the module and renamed via the console or The module does not seem to be following the same pattern when renaming as when using a simple resource and does seem able to make an in place change in a specif circumstance if the folder is renamed outside of Terraform but not when renaming it is handled by Terraform & the module alone. I get that |
Terraform requires every resource in its state to have a "key" for mapping to the Google Cloud API. For this module, the key is the folder name so changing the name necessarily means the state location is moving. This is a fundamental limitation of Terraform, not something that can be fixed in this module. You can work around it using |
@morgante There is no terraform blocking topic here. This has to be changed because:
Proposed solution: For example: and for folders resource, replace toset with something similar to: This way, when we change folder_name later to "new_name", we do not change folder_key, the state key is unchanged and the folder is renamed as expected. |
TL;DR
I used the module to create a set of folders, then I tried to rename it but instead of update-in-place, the plan announced that it would be a destroy.
Expected behavior
~ update in-place
Terraform will perform the following actions:
google_folder.department1 will be updated in-place
~ resource "google_folder" "department1" {
~ display_name = "test-folder" -> "test-folders"
id = "folders/273697474191"
name = "folders/273697474191"
# (4 unchanged attributes hidden)
}
Observed behavior
module.folders_commoncoreplatform.google_folder.folders["Prod"] will be destroyed
}
module.folders_commoncoreplatform.google_folder.folders["Prods"] will be created
}
Terraform Configuration
Terraform Version
Additional information
No response
The text was updated successfully, but these errors were encountered: