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.
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 }
}
filter
- (Optional) Custom filter block as described below.
tags
- (Optional) Map of tags, each pair of which must exactly match
a pair on the desired volumes.
More complex filters can be expressed using one or more filter
sub-blocks,
which take the following arguments:
name
- (Required) Name of the field to filter by, as defined by
the underlying AWS API.
For example, if matching against the size
filter, use:data "aws_ebs_volumes" "ten_or_twenty_gb_volumes" {
filter {
name = "size"
values = ["10", "20"]
}
}
values
- (Required) Set of values that are accepted for the given field.
EBS Volume IDs will be selected if any one of the given values match.This data source exports the following attributes in addition to the arguments above:
id
- AWS Region.ids
- Set of all the EBS Volume IDs found. This data source will fail if
no volumes match the provided criteria.read
- (Default 20m
)