terraform-plugin-sdk
terraform-plugin-sdk copied to clipboard
Allow ConflictsWith, ExactlyOneOf, and AtLeastOneOf to work in Lists
Use-cases
Currently ConflictsWith, ExactlyOneOf or AtLeastOneOf are set at the attribute level, which means we can't set it on a list of if we have a list of objects, and each object has a list of attributes that's AtLeastOneOf. We don't know the length of the list and there is no way to differentiate object[0] from object[1] with what is conflicting.
Proposal
We need to move ConflictsWith, ExactlyOneOf and AtLeastOneOf to the resource level to be able to determine which child fields are conflicting.
Just to document them, other (potentially mutually exclusive) ideas that have floated around this space are:
- Support for "relative" attribute paths (e.g. starting with a period to reference the same index of list/set block)
- Support for "wildcard" attribute paths (e.g. having an asterisk would match any index within a list/set block)