1. Packages
  2. AWS Classic
  3. API Docs
  4. ebs
  5. getVolume

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi

aws.ebs.getVolume

Explore with Pulumi AI

aws logo

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 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"],
            },
        ],
    });
    
    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"],
            },
        ])
    
    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
    	})
    }
    
    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",
                    },
                },
            },
        });
    
    });
    
    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());
    
        }
    }
    
    variables:
      ebsVolume:
        fn::invoke:
          Function: aws:ebs:getVolume
          Arguments:
            mostRecent: true
            filters:
              - name: volume-type
                values:
                  - gp2
              - name: tag:Name
                values:
                  - Example
    

    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>
    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]
    func LookupVolume(ctx *Context, args *LookupVolumeArgs, opts ...InvokeOption) (*LookupVolumeResult, error)
    func LookupVolumeOutput(ctx *Context, args *LookupVolumeOutputArgs, opts ...InvokeOption) LookupVolumeResultOutput

    > 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)
    }
    public static CompletableFuture<GetVolumeResult> getVolume(GetVolumeArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: aws:ebs/getVolume:getVolume
      arguments:
        # arguments dictionary

    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:0123456789012:volume/vol-59fcb34e).
    AvailabilityZone string
    AZ where the EBS volume exists.
    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:0123456789012:volume/vol-59fcb34e).
    AvailabilityZone string
    AZ where the EBS volume exists.
    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:0123456789012:volume/vol-59fcb34e).
    availabilityZone String
    AZ where the EBS volume exists.
    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:0123456789012:volume/vol-59fcb34e).
    availabilityZone string
    AZ where the EBS volume exists.
    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:0123456789012:volume/vol-59fcb34e).
    availability_zone str
    AZ where the EBS volume exists.
    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:0123456789012:volume/vol-59fcb34e).
    availabilityZone String
    AZ where the EBS volume exists.
    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 string
    Values List<string>
    Name string
    Values []string
    name String
    values List<String>
    name string
    values string[]
    name str
    values Sequence[str]
    name String
    values 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 logo

    Try AWS Native preview for resources not in the classic version.

    AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi