I’ll try to explain the issue that I’m facing with an example.
I had following terraform code for creating multiple EBS volumes in loop.
main.tf
resource "aws_ebs_volume" "ebs_volume" {
count = var.count_drive
type = element(var.ebs_drive_type, count.index)
size = element(var.ebs_devices_size, count.index)
iops = element(var.ebs_iops, count.index)
}
variables.tfvars
ebs_devices_names = ["/dev/xvdd", "/dev/xvdi", "/dev/xvdg"]
ebs_devices_size = ["250", "6000", "2000"]
ebs_drive_type = ["gp3", "io2", "gp3"]
ebs_iops = ["3000", "5000", "3000"]
Above code is working fine. Now the issue is that I also want to specify throughput. I can add one more variable of list type like others but throughput can only be specified for gp3. Hence I’ll get an error for other EBS types like gp2, io1, io2.
So to summarize what changes need to be done in code so that we can skip throughput assignment for other than gp3 types?
2
Answers
Set it to
null
if you want to skip it:Here is what you could do:
You don’t have to use the variable
throughput
, you might as well set it to a number you want that falls between the lowest and highest possible throughput. Also, take note thatavailability_zone
is a required parameter. Additionally, theiops
parameter is not available for thegp2
type of volume.