1. Packages
  2. AWS
  3. API Docs
  4. ebs
  5. getVolume
AWS v6.77.1 published on Friday, Apr 18, 2025 by Pulumi

aws.ebs.getVolume

Explore with Pulumi AI

AWS v6.77.1 published on Friday, Apr 18, 2025 by Pulumi

Use this data source to get information about an EBS volume for use in other resources.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const ebsVolume = aws.ebs.getVolume({
    mostRecent: true,
    filters: [
        {
            name: "volume-type",
            values: ["gp2"],
        },
        {
            name: "tag:Name",
            values: ["Example"],
        },
    ],
});
Copy
import pulumi
import pulumi_aws as aws

ebs_volume = aws.ebs.get_volume(most_recent=True,
    filters=[
        {
            "name": "volume-type",
            "values": ["gp2"],
        },
        {
            "name": "tag:Name",
            "values": ["Example"],
        },
    ])
Copy
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ebs"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := ebs.LookupVolume(ctx, &ebs.LookupVolumeArgs{
			MostRecent: pulumi.BoolRef(true),
			Filters: []ebs.GetVolumeFilter{
				{
					Name: "volume-type",
					Values: []string{
						"gp2",
					},
				},
				{
					Name: "tag:Name",
					Values: []string{
						"Example",
					},
				},
			},
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() => 
{
    var ebsVolume = Aws.Ebs.GetVolume.Invoke(new()
    {
        MostRecent = true,
        Filters = new[]
        {
            new Aws.Ebs.Inputs.GetVolumeFilterInputArgs
            {
                Name = "volume-type",
                Values = new[]
                {
                    "gp2",
                },
            },
            new Aws.Ebs.Inputs.GetVolumeFilterInputArgs
            {
                Name = "tag:Name",
                Values = new[]
                {
                    "Example",
                },
            },
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ebs.EbsFunctions;
import com.pulumi.aws.ebs.inputs.GetVolumeArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var ebsVolume = EbsFunctions.getVolume(GetVolumeArgs.builder()
            .mostRecent(true)
            .filters(            
                GetVolumeFilterArgs.builder()
                    .name("volume-type")
                    .values("gp2")
                    .build(),
                GetVolumeFilterArgs.builder()
                    .name("tag:Name")
                    .values("Example")
                    .build())
            .build());

    }
}
Copy
variables:
  ebsVolume:
    fn::invoke:
      function: aws:ebs:getVolume
      arguments:
        mostRecent: true
        filters:
          - name: volume-type
            values:
              - gp2
          - name: tag:Name
            values:
              - Example
Copy

Using getVolume

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getVolume(args: GetVolumeArgs, opts?: InvokeOptions): Promise<GetVolumeResult>
function getVolumeOutput(args: GetVolumeOutputArgs, opts?: InvokeOptions): Output<GetVolumeResult>
Copy
def get_volume(filters: Optional[Sequence[GetVolumeFilter]] = None,
               most_recent: Optional[bool] = None,
               tags: Optional[Mapping[str, str]] = None,
               opts: Optional[InvokeOptions] = None) -> GetVolumeResult
def get_volume_output(filters: Optional[pulumi.Input[Sequence[pulumi.Input[GetVolumeFilterArgs]]]] = None,
               most_recent: Optional[pulumi.Input[bool]] = None,
               tags: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
               opts: Optional[InvokeOptions] = None) -> Output[GetVolumeResult]
Copy
func LookupVolume(ctx *Context, args *LookupVolumeArgs, opts ...InvokeOption) (*LookupVolumeResult, error)
func LookupVolumeOutput(ctx *Context, args *LookupVolumeOutputArgs, opts ...InvokeOption) LookupVolumeResultOutput
Copy

> Note: This function is named LookupVolume in the Go SDK.

public static class GetVolume 
{
    public static Task<GetVolumeResult> InvokeAsync(GetVolumeArgs args, InvokeOptions? opts = null)
    public static Output<GetVolumeResult> Invoke(GetVolumeInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetVolumeResult> getVolume(GetVolumeArgs args, InvokeOptions options)
public static Output<GetVolumeResult> getVolume(GetVolumeArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: aws:ebs/getVolume:getVolume
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Filters List<GetVolumeFilter>
One or more name/value pairs to filter off of. There are several valid keys, for a full reference, check out [describe-volumes in the AWS CLI reference][1].
MostRecent bool
If more than one result is returned, use the most recent volume.
Tags Dictionary<string, string>
Map of tags for the resource.
Filters []GetVolumeFilter
One or more name/value pairs to filter off of. There are several valid keys, for a full reference, check out [describe-volumes in the AWS CLI reference][1].
MostRecent bool
If more than one result is returned, use the most recent volume.
Tags map[string]string
Map of tags for the resource.
filters List<GetVolumeFilter>
One or more name/value pairs to filter off of. There are several valid keys, for a full reference, check out [describe-volumes in the AWS CLI reference][1].
mostRecent Boolean
If more than one result is returned, use the most recent volume.
tags Map<String,String>
Map of tags for the resource.
filters GetVolumeFilter[]
One or more name/value pairs to filter off of. There are several valid keys, for a full reference, check out [describe-volumes in the AWS CLI reference][1].
mostRecent boolean
If more than one result is returned, use the most recent volume.
tags {[key: string]: string}
Map of tags for the resource.
filters Sequence[GetVolumeFilter]
One or more name/value pairs to filter off of. There are several valid keys, for a full reference, check out [describe-volumes in the AWS CLI reference][1].
most_recent bool
If more than one result is returned, use the most recent volume.
tags Mapping[str, str]
Map of tags for the resource.
filters List<Property Map>
One or more name/value pairs to filter off of. There are several valid keys, for a full reference, check out [describe-volumes in the AWS CLI reference][1].
mostRecent Boolean
If more than one result is returned, use the most recent volume.
tags Map<String>
Map of tags for the resource.

getVolume Result

The following output properties are available:

Arn string
Volume ARN (e.g., arn:aws:ec2:us-east-1:123456789012:volume/vol-59fcb34e).
AvailabilityZone string
Availability zone where the EBS volume exists.
CreateTime string
Timestamp when volume creation was initiated.
Encrypted bool
Whether the disk is encrypted.
Id string
The provider-assigned unique ID for this managed resource.
Iops int
Amount of IOPS for the disk.
KmsKeyId string
ARN for the KMS encryption key.
MultiAttachEnabled bool
(Optional) Specifies whether Amazon EBS Multi-Attach is enabled.
OutpostArn string
ARN of the Outpost.
Size int
Size of the drive in GiBs.
SnapshotId string
Snapshot_id the EBS volume is based off.
Tags Dictionary<string, string>
Map of tags for the resource.
Throughput int
Throughput that the volume supports, in MiB/s.
VolumeId string
Volume ID (e.g., vol-59fcb34e).
VolumeType string
Type of EBS volume.
Filters List<GetVolumeFilter>
MostRecent bool
Arn string
Volume ARN (e.g., arn:aws:ec2:us-east-1:123456789012:volume/vol-59fcb34e).
AvailabilityZone string
Availability zone where the EBS volume exists.
CreateTime string
Timestamp when volume creation was initiated.
Encrypted bool
Whether the disk is encrypted.
Id string
The provider-assigned unique ID for this managed resource.
Iops int
Amount of IOPS for the disk.
KmsKeyId string
ARN for the KMS encryption key.
MultiAttachEnabled bool
(Optional) Specifies whether Amazon EBS Multi-Attach is enabled.
OutpostArn string
ARN of the Outpost.
Size int
Size of the drive in GiBs.
SnapshotId string
Snapshot_id the EBS volume is based off.
Tags map[string]string
Map of tags for the resource.
Throughput int
Throughput that the volume supports, in MiB/s.
VolumeId string
Volume ID (e.g., vol-59fcb34e).
VolumeType string
Type of EBS volume.
Filters []GetVolumeFilter
MostRecent bool
arn String
Volume ARN (e.g., arn:aws:ec2:us-east-1:123456789012:volume/vol-59fcb34e).
availabilityZone String
Availability zone where the EBS volume exists.
createTime String
Timestamp when volume creation was initiated.
encrypted Boolean
Whether the disk is encrypted.
id String
The provider-assigned unique ID for this managed resource.
iops Integer
Amount of IOPS for the disk.
kmsKeyId String
ARN for the KMS encryption key.
multiAttachEnabled Boolean
(Optional) Specifies whether Amazon EBS Multi-Attach is enabled.
outpostArn String
ARN of the Outpost.
size Integer
Size of the drive in GiBs.
snapshotId String
Snapshot_id the EBS volume is based off.
tags Map<String,String>
Map of tags for the resource.
throughput Integer
Throughput that the volume supports, in MiB/s.
volumeId String
Volume ID (e.g., vol-59fcb34e).
volumeType String
Type of EBS volume.
filters List<GetVolumeFilter>
mostRecent Boolean
arn string
Volume ARN (e.g., arn:aws:ec2:us-east-1:123456789012:volume/vol-59fcb34e).
availabilityZone string
Availability zone where the EBS volume exists.
createTime string
Timestamp when volume creation was initiated.
encrypted boolean
Whether the disk is encrypted.
id string
The provider-assigned unique ID for this managed resource.
iops number
Amount of IOPS for the disk.
kmsKeyId string
ARN for the KMS encryption key.
multiAttachEnabled boolean
(Optional) Specifies whether Amazon EBS Multi-Attach is enabled.
outpostArn string
ARN of the Outpost.
size number
Size of the drive in GiBs.
snapshotId string
Snapshot_id the EBS volume is based off.
tags {[key: string]: string}
Map of tags for the resource.
throughput number
Throughput that the volume supports, in MiB/s.
volumeId string
Volume ID (e.g., vol-59fcb34e).
volumeType string
Type of EBS volume.
filters GetVolumeFilter[]
mostRecent boolean
arn str
Volume ARN (e.g., arn:aws:ec2:us-east-1:123456789012:volume/vol-59fcb34e).
availability_zone str
Availability zone where the EBS volume exists.
create_time str
Timestamp when volume creation was initiated.
encrypted bool
Whether the disk is encrypted.
id str
The provider-assigned unique ID for this managed resource.
iops int
Amount of IOPS for the disk.
kms_key_id str
ARN for the KMS encryption key.
multi_attach_enabled bool
(Optional) Specifies whether Amazon EBS Multi-Attach is enabled.
outpost_arn str
ARN of the Outpost.
size int
Size of the drive in GiBs.
snapshot_id str
Snapshot_id the EBS volume is based off.
tags Mapping[str, str]
Map of tags for the resource.
throughput int
Throughput that the volume supports, in MiB/s.
volume_id str
Volume ID (e.g., vol-59fcb34e).
volume_type str
Type of EBS volume.
filters Sequence[GetVolumeFilter]
most_recent bool
arn String
Volume ARN (e.g., arn:aws:ec2:us-east-1:123456789012:volume/vol-59fcb34e).
availabilityZone String
Availability zone where the EBS volume exists.
createTime String
Timestamp when volume creation was initiated.
encrypted Boolean
Whether the disk is encrypted.
id String
The provider-assigned unique ID for this managed resource.
iops Number
Amount of IOPS for the disk.
kmsKeyId String
ARN for the KMS encryption key.
multiAttachEnabled Boolean
(Optional) Specifies whether Amazon EBS Multi-Attach is enabled.
outpostArn String
ARN of the Outpost.
size Number
Size of the drive in GiBs.
snapshotId String
Snapshot_id the EBS volume is based off.
tags Map<String>
Map of tags for the resource.
throughput Number
Throughput that the volume supports, in MiB/s.
volumeId String
Volume ID (e.g., vol-59fcb34e).
volumeType String
Type of EBS volume.
filters List<Property Map>
mostRecent Boolean

Supporting Types

GetVolumeFilter

Name This property is required. string
Values This property is required. List<string>
Name This property is required. string
Values This property is required. []string
name This property is required. String
values This property is required. List<String>
name This property is required. string
values This property is required. string[]
name This property is required. str
values This property is required. Sequence[str]
name This property is required. String
values This property is required. List<String>

Package Details

Repository
AWS Classic pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.
AWS v6.77.1 published on Friday, Apr 18, 2025 by Pulumi