hashicorp / terraform-plugin-sdk

Terraform Plugin SDK enables building plugins (providers) to manage any service providers or custom in-house solutions
https://developer.hashicorp.com/terraform/plugin
Mozilla Public License 2.0
432 stars 230 forks source link

Multi-attribute validation #233

Open radeksimko opened 4 years ago

radeksimko commented 4 years ago

Problem Statement

Providers today are able to validate multiple attributes using customdiff's Validate* functions:

https://godoc.org/github.com/hashicorp/terraform-plugin-sdk/helper/customdiff#ValidateValue https://godoc.org/github.com/hashicorp/terraform-plugin-sdk/helper/customdiff#ValidateChange

However - as the package name suggests - this package is not meant to deal with such validation and using it for simple multi-attribute plan-time validation can feel awkward.

Such validation also doesn't run during terraform validate, but "later" during terraform plan.

Examples

https://github.com/terraform-providers/terraform-provider-azurerm/blob/94cf18b287d634ee16aa5e37d3a73d3e8a356fa4/azurerm/resource_arm_cosmosdb_account.go#L384-L392

https://github.com/terraform-providers/terraform-provider-aws/blob/98b8b848ca94031b20c3e626c9d40484e3af80de/aws/resource_aws_lb_target_group.go#L684-L692

https://github.com/terraform-providers/terraform-provider-aws/issues/10963

Proposal

TODO

Tensho commented 4 years ago

Desperately would love to have it for terraform-provider-aws provider code simplification. Is there any plugin SDK design ossification on the way?