How to validate a field that depends on other fields to catch problems during plan?

101 views
Skip to first unread message

Ashish Thakur

unread,
Oct 6, 2017, 2:28:05 PM10/6/17
to Terraform
Basically I want to get the terraform plan to find issues early on. I have two fields A and B. A can have certain values based on what B is holding at a point.

So if someones specifies these two fields in the schema, how can I leverage validateFunc (or otherwise)to put proper validation so that problem is found at plan stage itself.

For example if B is true A could be 1,2,3,4 and if B is false A could be 8,9.

Paddy Carver

unread,
Oct 6, 2017, 7:29:34 PM10/6/17
to terrafo...@googlegroups.com
Unfortunately, this isn't something that the provider framework supports just yet, but it is something that the core team discusses and knows is an issue. I don't have a timeline for resolution, but it's definitely a known limitation. Sorry I can't offer more here.

Best,
Paddy

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/62f32cb3-dc08-4d43-8e5f-7ea21779c76a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ashish Thakur

unread,
Oct 7, 2017, 2:49:26 PM10/7/17
to Terraform
Thanks for the information Paddy. While I am on the topic of validation, I would like some confirmation on whether only validations on static information can be achieved during terraform plan. For example while ordering something on some cloud services some chosen data centers  by the user in the schema could be at capacity for a particular resource and hence no more resources of a particular kind can be provisioned. Can this type of issues be caught at plan time?

Regards
Ashish


On Saturday, 7 October 2017 04:59:34 UTC+5:30, Paddy Carver wrote:
Unfortunately, this isn't something that the provider framework supports just yet, but it is something that the core team discusses and knows is an issue. I don't have a timeline for resolution, but it's definitely a known limitation. Sorry I can't offer more here.

Best,
Paddy
On Fri, Oct 6, 2017 at 11:28 AM, Ashish Thakur <ashis...@gmail.com> wrote:
Basically I want to get the terraform plan to find issues early on. I have two fields A and B. A can have certain values based on what B is holding at a point.

So if someones specifies these two fields in the schema, how can I leverage validateFunc (or otherwise)to put proper validation so that problem is found at plan stage itself.

For example if B is true A could be 1,2,3,4 and if B is false A could be 8,9.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com.

Paddy Carver

unread,
Oct 12, 2017, 12:52:27 AM10/12/17
to terrafo...@googlegroups.com
Hi Ashish,

So this is a slightly complicated question. Technically, right now, the `terraform validate` command is what's doing the validation; it's just run as part of `terraform plan`, as well. And from what I understand, there are no plans to allow network access to the functions run as part of that, as the intention is to allow e.g. editors to run it inline. I do know, however, that the team is aware that network-accessible validation, as well as validation across fields, are things that would be really useful and are discussing the possibility of future improvements. I can't promise a timeline, or even that it will happen, but they're things we're aware of.

Cheers,
Paddy

To unsubscribe from this group and stop receiving emails from it, send an email to terraform-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/65d47607-fa36-4a03-9590-a4b859f7e8e1%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages