Data Source: aws_ebs_volumes

aws_ebs_volumes provides identifying information for EBS volumes matching given criteria.

This data source can be useful for getting a list of volume IDs with (for example) matching tags.

Example Usage

The following demonstrates obtaining a map of availability zone to EBS volume ID for volumes with a given tag value.

data "aws_ebs_volumes" "example" {
  tags = {
    VolumeSet = "TestVolumeSet"
  }
}

data "aws_ebs_volume" "example" {
  for_each = data.aws_ebs_volumes.example.ids
  filter {
    name   = "volume-id"
    values = [each.value]
  }
}

output "availability_zone_to_volume_id" {
  value = { for s in data.aws_ebs_volume.example : s.id => s.availability_zone }
}

Argument Reference

More complex filters can be expressed using one or more filter sub-blocks, which take the following arguments:

data "aws_ebs_volumes" "ten_or_twenty_gb_volumes" {
  filter {
    name   = "size"
    values = ["10", "20"]
  }
}

Attribute Reference

This data source exports the following attributes in addition to the arguments above:

Timeouts

Configuration options: