-
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
Project is getting tainted in TF state file, even though it got created; when billing id is incorrect #5222
Project is getting tainted in TF state file, even though it got created; when billing id is incorrect #5222
Comments
@chrisst here is the two plans
|
@pb0101 There was a change in 0.12 that will taint a resource when the create call throws an error for any reason unlike 0.11 which did not automatically taint the resource. Unfortunately there's no elegant solution in the provider to this problem with the existing version of Terraform core. The only way to avoid tainting the resource is to suppress the error, in which case the resource will appear to have succeeded and no error will be reported but subsequent plan's will show a diff on the billing account that won't make sense without an error. For now you can manually untaint the resource with If this solution doesn't work for your use case I suggest filing an issue against Terraform core with your specific use case and see if they can add more granular control over the taint process. Let me know if the workaround solves your use case! |
assigning to @hashibot and myself as @umairidris is working on a fix for this. |
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 👉 hashibot-feedback@hashicorp.com. Thanks! |
Community Note
Terraform Version
terraform -v
Terraform v0.12.17
Affected Resource(s)
Terraform Configuration Files
Debug Output
Panic Output
Expected Behavior
Project should update the correct billing id, instead of deleting and creating the project again.
Actual Behavior
When running terraform for creating project (with incorrect billing id), project gets created. But when applying an update to the project with correct billing id; terraform is destroying the project and creating it again. This causes name conflict, because the project is pending deletion.
Steps to Reproduce
Create project with incorrect billing id
Fix the billing id and apply changes.
terraform apply
Important Factoids
terraform apply --auto-approve (with incorrect billing id)
google_project.my_project: Creating...
Error: Error setting billing account "yyyyyyyyyyyyy" for project "projects/xxxxxxxxxx": googleapi: Error 400: Request contains an invalid argument., badRequest
on main.tf line 50, in resource "google_project" "my_project":
50: resource "google_project" "my_project" {
Apply after fixing the billing id
google_project.my_project: Destroying... [id=xxxxxxxxxxxxx]
google_project.my_project: Destruction complete after 5s
google_project.my_project: Creating...
Error: error creating project xxxxxxxxxxxx (xxxxxxxxxxxxxxx): googleapi: Error 409: Requested entity already exists, alreadyExists. If you received a 403 error, make sure you have the
roles/resourcemanager.projectCreator
permissionon main.tf line 50, in resource "google_project" "my_project":
50: resource "google_project" "my_project" {
References
The text was updated successfully, but these errors were encountered: