This behavior can be replicated in a single project by deleting a service account (in Terraform) and attempting to apply the same Dataset IAM role on another service account.
Whether or not this is intended, if this causes Terraform state issues (e.g. trying to apply changes to the deleted service account), a solution is to delete the IAM permissions on the affected dataset. At the time of posting, that looks like:
Go to the affected GCP project's BigQuery service.
Click on the dataset the service account had IAM permissions on prior to deletion.
Click on Sharing > Permissions.
Find the permission on the deleted service account. Hovering over this will even clarify that the service account has been deleted.
Manually delete the permission, assuming the user has the permissions to do so.
Note that this (a) does not clarify the cause of the issue and (b) can probably done with a CLI command.
We have found a possible issue whereby Terraform seems to ignore IAM assignments for deleted service accounts.
Our scenario is as follows:
Is this behaviour expected or should the provider still remove the IAM assignment even after the Service Account has been deleted?
If you have a support request or question please submit them to one of these resources: