You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am writing a custom provider in which I have 2 fields defined in the schema namely : host_instance_type and storage_capacity. What is the best way to write a validation function for storage_capacity whose behavior is different for different host_instance_type ? In this the storage_capacity, must be specified only for a specific host_instance_type (say A). But storage_capacity should not be specified for a host_instance_type (say B).
Attempted Solutions
Currently there seems to be no solution for performing such a validation in the terraform plan stage. I can perform such a validation in terraform apply which might not be the most efficient way to do it.
Proposal
ValidateFunc should support a method where two fields of the resource can be compared with a custom validate function.
References
The text was updated successfully, but these errors were encountered:
Until a better way to support this is added, you do have a Plan time hook with the CustomizeDiff method. You can look at other providers who have utilized it to write more sophisticated multi-attribute validation at Plan time.
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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
ghost
locked and limited conversation to collaborators
Apr 13, 2020
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Current Terraform Version
Use-cases
I am writing a custom provider in which I have 2 fields defined in the schema namely : host_instance_type and storage_capacity. What is the best way to write a validation function for storage_capacity whose behavior is different for different host_instance_type ? In this the storage_capacity, must be specified only for a specific host_instance_type (say A). But storage_capacity should not be specified for a host_instance_type (say B).
Attempted Solutions
Currently there seems to be no solution for performing such a validation in the terraform plan stage. I can perform such a validation in terraform apply which might not be the most efficient way to do it.
Proposal
ValidateFunc should support a method where two fields of the resource can be compared with a custom validate function.
References
The text was updated successfully, but these errors were encountered: