Upgrading google_container_node_pool resources using create_before_destroy


I’m trying to set up my node pool resources for GKE, so that whenever I make a change to them that requires them to be recreated, it automatically first creates the new node pool before destroying the old one.

In order to achieve this I need to have some kind of random generation in order to make sure that the names for the node pools are unique. I’ve tried doing this with the random resource, but the problem is that the random identifier does not change when a force update to a resource is done, as the random id resource itself has not changed.

I read that the ‘name_prefix’ property is deprecated and should not be used for this purpose (although it seems to fit my needs perfectly).

What would according to you be the best way to model this in Terraform?

name_prefix was actually undeprecated in order to handle this sort of case, so you’re all set to use it freely (https://github.com/terraform-providers/terraform-provider-google/issues/2486)