My use case is that I have a module that creates AWS instances and EBS volumes based on some parameters I input.
Some of the aws_ebs_volume resource arguments are only valid for particular volume types - for example “throughput” is " Only valid for
gp3 .", and “iops” has a similar description.
If I want to create an instance with 2 volumes, one of type gp3 and the other of type sc1, using a “volume” module which takes a list of some parameters, what do I do about “throughput”? If I specify to take it’s value from the parameter, is it valid to specify it as “” (empty) for sc1 and a value (if I need one) for gp3, or will terraform generate an error saying that I shouldn’t be providing the “throughput” argument (albeit with an empty value) as the type is “sc1”?
I’m using terraform v0.13.6 and aws provider 3.29.1.
Or is there a way of conditionally specifying an argument, such as “if type = gp3, add the ‘throughput’ argument”? Think of it like when you’re using “count” on a resource, where count=0 if you want to define the code but don’t want it to create any resources…but instead of doing the count at resource level, you’re doing it at resource argument level.
Of course, if terraform doesn’t generate an error if I supply both “iops” and “throughput” arguments regardless of the volume type, but does throw an error if I’m e.g. trying to provide a non-null value for type sc1, then my question is moot; I would just need to know if it would generate an error for non-gp3 types.