Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't we add this as
ConflictsWith
onname
andname_prefix
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ConflictsWith
doesn't support nested fields. It only works with top-level fields.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to clarify- I'm pretty sure
ConflictsWith
does work with nested fields, but you have to specify the full path to the field, i.e.node_pool.0.name_prefix
, which won't work if there are multiple node pools specified in a cluster (this schema is shared between the node pool and cluster resources)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything Dana said is true.
Just to clarify, ConflictsWith works on nested field IFF you know the index of the other field in
ConflictsWith
. When you have a list of nested objects and you want two fields inside that nested object to be mutually exclusive, it is NOT supported.For instance, this works:
But if you want to say, two fields under the same entry should be conflicting, then this is not possible:
For the example above, there is no way to express that
name
andname_prefix
shouldConflictsWith
each other.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be nice if ConflictsWith supported a notation (exact notation TBD) like:
I vaguely remember opening an issue with Terraform core about this. I will try to dig it out or open one if I had not opened one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two issues are already tracking this:
https://github.com/hashicorp/terraform/issues/13016
https://github.com/hashicorp/terraform/issues/11101
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoooops. Sorry about that. Ignore this comment then. :)