GCP: move from project_id(int) to project_name(string) without recreation of resources

We have the following problem with our main terraform repository for GCP resources:
Longer time ago already, when the repo was set up, a lot of GCP resources like VPC’s and GKE clusters where created differently with for the two environments staging and production:

  • For staging, the GCP project name(a string like up42-staging-project) was used for resources creation using it as the project_id parameter.
  • For production, the GCP project id(an integer like 1234565678) was used for resources creation using it as the project_id parameter.

Since that divergence is biting us in many ways, we would like to streamline the two environments and we would like to use the project name for our production environment as well.
The problems is, that an update in the project_id parameter always forces a recreation of the respective resource and we would not like to recreate our whole production environment because of that technicality.

Is there some way around it?

In the end, we would need to update that parameter forcefully without having terraform recreate the respective resource.

Thanks a lot for your help in advance.

Hi @robert.andruschow,

I’m not familiar with the details of the provider, so I would need some specific resources to look at in order to figure out what could be changed. In most cases, if a provider indicates that a change requires replacement of a resource, it is because the remote service has the same requirements. You could check each resource in the remote console and see if that value can actually be changed without replacement and do a manual batch update, but I wouldn’t be surprised if that could only be done for a small minority, if at all. It’s also possible the provider uses the IDs in other ways in the background, and changing the ID values may still not be possible.

Only if the values can all be updated manually, then you could combine that batch update with a corresponding change to the configuration and the next refresh operation should synchronize the state. I would however first setup a complete, temporary test environment to see what actually happens if you were to try this.

Thanks @jbardin for your answer.

Indeed, in the GCP console, you cannot change the regarding value.
Also not via the api, since the project_id is used as a unique identifier for the resource and part of a path variable(and not in the json payload that indicates fields to be updated).

I think I will try to clarify the situation with GCP support, except anybody has a different suggestion.