Partial State and Resource Creation


I am looking to make improvements in the Google Provider, specifically the resource google_project (

Currently, the google_project resource creates a project and also does some additional functions such as link a billing account and deleting the default network.

The problem occurs when the project itself is created properly, but a later call such as linking billing account fails. The resource becomes ‘tainted’ and forces a delete and recreate on the next run. Since projects have a 30 day recovery period, the re-create fails and thus the user ends up in a limbo.

I am looking to add partial state support here. Essentially what I would like is to partially commit the project to state. If there is a failure with the billing account link then we return an error. On retry, I would like to skip past the project creation and retry billing account link. Once billing account succeeds we add the billing account field to the state, and continue on.

Can partial state help here and do you have any examples for reference (on resource creation, not update).


Hi @umairidris,

I don’t work on the Google provider myself so I can’t answer fully here but I will say that your idea of using partial state to commit the partial result is the usual design pattern for this sort of thing, with some additional details:

  • The resource type implementation will need to ensure that a subsequent plan for the project will notice that the previous result was incomplete and reflect an “update” action to complete it. Depending on the specific details of this situation, that might just happen automatically as a consequence of certain items being absent in the partial state, but depending on the details of this API it might require additional computed attributes in the state to record that further work is required and a CustomizeDiff implementation to detect that and ensure the plan includes a change.
  • The Update implementation for that resource type must itself be able to handle this sort of partial fixup, which tends to require factoring out some of the functionality that would otherwise only be inside Create. This resource type may already be built in such a way, but if not then some refactoring would be required.

Since you are planning to make a code contribution to the Google Cloud Platform provider, I think a good next step would be to open an enhancement issue describing the problem as you’ve described it here along with how you’re thinking about solving it, and then the folks who maintain that provider should be able to give more specific feedback than I can with only my general knowledge of Terraform Core and the SDK.

Thanks Martin, I’ll engage the provider team as well.