-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: Provider produced inconsistent result after apply at GCP project + SA creation #6377
Error: Provider produced inconsistent result after apply at GCP project + SA creation #6377
Comments
Hi,
tfstate and debug log: |
Only arrive on fresh project creation |
idem with provider 3.17 and 3.21 |
I encountered this issue yesterday. On first Apply I saw that the resources that depended on the service account failed. A subsequent terraform plan showed that the service account needed to be created, running apply again gave the error service account alreadyExists. terraform version: 0.11.14 when investigating I found:
I resolved by:
Looks related to: #6362 |
I met the same issue with Terraform 0.11.14/0.12.24 and Google Provider 2.20.1. I wrote a minimal code to reproduce this behavior, which repeats create a new service account -> get it -> delete it using raw IAM API client. However, actually it's still hard to reproduce... when I started running this script, I sometimes encountered the following error which looks the same as this issue. However, after running several times, I couldn't see the error again...
|
After some test it's an async data on google. |
I have also started seeing this same error with a TF file similar to #6377 (comment) provider "google" {
version = "~> 3.20.0"
}
resource "google_project" "project" {
name = "foo"
project_id = "foo"
billing_account = ""
folder_id = ""
}
resource "google_service_account" "foo" {
account_id = "example"
display_name = "example"
project = google_project.project.project_id
}
version: logs: https://gist.github.com/bharathkkb/936c43d253ffc01a353bd16a6c2be3b0 |
Hi all,
60 seconds seems to enough so far, but it is easily adjustable. Hopefully this helps anyone unblock themselves before waiting for the fix to be released, or using an older version. |
Hi, But I noticed the sa creation begin while the project resource is still activating api. So added depends_on section with depends_on = [google_project_service.main] in service account creation and the issue do not appear anymore. I tried only twice, but before I got the issue everytime. |
Hi @mldmld68, thanks for the input, and I'm glad you were able to figure out a workaround! So you had |
Hi @c2thorn, here is an extract of the project creation :
|
Could this be related to Cloud Console and gCloud also not being in agreement as to whether the service account was created? I have concerns with this timeout workaround as I have waited 3 days for Console to show the info that gCloud has with no luck. |
@benjamin-kaiser The root problem is certainly service account creation, unfortunately all the Terraform provider can do is use what the information the API returns and wait for eventual consistency. |
The same issue even after provider update to the version 3.22.0 |
Hi @unclebene |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks! |
Community Note
modular-magician
user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned tohashibot
, a community member has claimed the issue already.Terraform Version
Terraform version: 0.12.24
terraform-provider-google-beta_v3.21.0_x5
"terraform-provider-google-beta_v3.21.0_x5"
"terraform-provider-google_v3.21.0_x5"
"terraform-provider-null_v2.1.2_x4"
"terraform-provider-random_v2.2.1_x4"
"terraform-provider-template_v2.1.2_x4"
Affected Resource(s)
The error is around service account but don't know which resource exactly. The code creates 2 SA and may fail for one or other SA. Or not fail at all
Terraform Configuration Files
Debug Output
https://gist.github.com/mldmld68/c08c9db8383736e1df31a49cdbe10ab3
Panic Output
Expected Behavior
Terraform apply finish without error
Actual Behavior
I can get an error on 2 SA, but not everytime the same
I terraform plan+apply/terraform destroy/terraform plan+apply
Error: Provider produced inconsistent result after apply
When applying changes to google_service_account.appli_sa, provider
"registry.terraform.io/-/google" produced an unexpected new value for was
present, but now absent.
This is a bug in the provider, which should be reported in the provider's own
issue tracker.
If one restart terraform apply, on get
Error: Error creating service account: googleapi: Error 409: Service account sa-xxxxx-appli already exists within project projects/xxxxxxx., alreadyExists
on service_account.tf line 9, in resource "google_service_account" "appli_sa":
Error: Provider produced inconsistent result after apply
When applying changes to google_service_account.project_runner, provider
"registry.terraform.io/-/google" produced an unexpected new value for was
present, but now absent.
This is a bug in the provider, which should be reported in the provider's own
issue tracker.
ERROR: Job failed: exit code 1
Steps to Reproduce
terraform apply
terraform apply
Important Factoids
This job create a GCP projet, give roles to user groups and SAs.
If one destroy the faultly SA and restart the job, the terrform plan plays successfully
References
The text was updated successfully, but these errors were encountered: