Skip to content
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

ValidateFunc should support validation of two fields dependent on each other that are defined in resource schema #354

Closed
saloneerege opened this issue Mar 11, 2020 · 2 comments

Comments

@saloneerege
Copy link

Current Terraform Version

Terraform v0.12.20

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

@jbardin jbardin transferred this issue from hashicorp/terraform Mar 13, 2020
@paultyng
Copy link
Contributor

I think this is the same issue as #233

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.

@ghost
Copy link

ghost commented Apr 13, 2020

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 ghost locked and limited conversation to collaborators Apr 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants