Error: project: required field is not set

I’m trying to complete a well overdue upgrade from Terraform v0.13.6 to v0.14.8 and run into an error that I can’t get past. The error is:

Error: project: required field is not set

The errors don’t seem to have any additional information so I am unsure where to look to fix/overcome the issue. I have set the logging to TRACE (TF_LOG=TRACE) but the log file doesn’t seem to have any errors in it.

The configuration is a few thousand lines of configuration across ~20 modules for a google cloud web project (with k8s, s3, pubsub, auth, GPU VM templates and a scaler).

I have upgraded (and downgraded) providers [google, google-beta, kubernetes, null, random] to latest. The version doesn’t seem to have much impact (same result).

The issue crops up with terraform plan. (terraform init and terraform validate are both good).

I have targeted one module at a time with plan and isolated that one module might be a problem (google pubsub subscription/topic), but when I comment out that code it doesn’t overcome the problem. I wonder if somehow something in the state config is an issue.

Note: I have setup the google (and google-beta) providers with a fixed known project identifier. This is put in from the top level .tf file via a variable.

Most issues relating to this error tend to have a source reference in the console output. My best google fu is failing me.

Help - how to I find and fix this? What information can I provide to help?

Thanks

Executive summary: terraform state has a null value for project in google_pubsub_subscription_iam_member resources.

I’ve had some success at getting terraform plan to run (and produce a set of changes).

Procedure

  1. terraform state pull > my-state.json
  2. edit the my-state,son and correct the "project" : null, settings in two places for resources of type google_pubsub_subscription_iam_member, and increment the serial number
  3. terraform state push my-state.json
  4. terraform plan

Note: a k8s resource had a null project, but didn’t need to be changed.

I suspect there might be an issue in the old/new version of google_pubsub_subscription_iam_member in the google provider. I’m not looking forward to rolling this out in production as it is likely to require manual intervention.