hashicorp / hashicorp/terraform-plugin-sdk
lifecycle configuration to disable field validation
- Dominant language
- Go
- Stars
- 485
- Forks
- 244
- Avg merge
- 19h 57m
- Merged PRs (30d)
- 4
Description
### Feature Description
Terraform should provide a way for the user to disable the `ValidationFunc` for a specific field via a lifecycle configuration.
#### Example (from @bflad)
```tf
resource "XXX" "example" {
# ... potentially other configuration ...
example_attribute = "incorrectly-validated-value"
lifecycle {
ignore_validation = ["example_attribute"]
}
}
```
### Reasoning
While discussing [an MR](https://github.com/terraform-providers/terraform-provider-aws/pull/4497) about upgrading the validation on S3 bucket names the need of a feature like this came up due to the fact that there could be old resources that would fail the validation even though no new ones not passing the `ValidateFunc` can be created. The proposed feature would provide a way for providers to adapt to new requirements and still provide a way for users with grandfathered resources to upgrade.
As @bflad mentioned in the linked MR this would have the additional use case of being able to disable validations in cases where a service changed in a way that a `ValidateFunc` is unnecessary strict and the provider didn't update yet.
#### Possible other solutions:
Initially I proposed to solve the problem of grandfathered resources with having a way for providers to declare `ValidateFunc`'s that only get executed against resources that will be created and not against existing once, but I think this will be unevenly more complex and of less general use then this proposal.
### References
- https://github.com/terraform-providers/terraform-provider-aws/pull/4497
Contributor guide
Research direction
Start with the lifecycle configuration and ValidationFunc behavior described in the issue, then read the referenced AWS provider pull request for the grandfathered S3 bucket-name case. Determine the configuration and provider behavior needed for a per-field ignore_validation setting, and verify that existing resources can bypass validation while the requested lifecycle option remains explicit.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, terraform
- Domain
- infrastructure, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100