hashicorp / hashicorp/terraform-plugin-sdk
Ability to prevent taints on create errors
- Dominant language
- Go
- Stars
- 485
- Forks
- 244
- Avg merge
- 19h 57m
- Merged PRs (30d)
- 4
Description
### SDK version
```
{
"Path": "github.com/hashicorp/terraform-plugin-sdk",
"Version": "v1.4.0"
}
```
### Use-cases
Some resources in the Google provider have multiple steps that happen on create. For example, [google_project](https://github.com/terraform-providers/terraform-provider-google/blob/master/google/resource_google_project.go) creates a project, but then it also adds a billing account to it and potentially deletes a network from the project. If the project gets created successfully but one of the other steps fails, the resource is tainted, which means retrying the apply after fixing whatever caused it to fail will destroy the project and recreate it, even though it's a perfectly good project. See https://github.com/terraform-google-modules/terraform-google-project-factory/issues/373 for further discussion.
### Attempted Solutions
`d.SetPartial` seems vaguely relevant to what we want, but it's been deprecated (and I'm not positive that it would have actually worked).
### Proposal
Basically anything where we, in the provider code, can tell Terraform to please not taint the resource (just like how a failed update doesn't taint it).
### References
https://github.com/hashicorp/terraform/issues/21652 (which was solved in a different way)
Contributor guide
Research direction
Start with the multi-step create flow in google/resource_google_project.go and review the issue's discussion of d.SetPartial and Terraform issue #21652. Determine how provider code could signal that a partially successful create should not taint the resource. Done means a failed later create step can be retried without destroying an already-created project.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100