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

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

AWS Classic v6.28.1 published on Thursday, Mar 28, 2024 by Pulumi

aws.ebs.getSnapshot

Explore with Pulumi AI

aws logo

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

AWS Classic v6.28.1 published on Thursday, Mar 28, 2024 by Pulumi

    Use this data source to get information about an EBS Snapshot for use when provisioning EBS Volumes

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const ebsVolume = aws.ebs.getSnapshot({
        mostRecent: true,
        owners: ["self"],
        filters: [
            {
                name: "volume-size",
                values: ["40"],
            },
            {
                name: "tag:Name",
                values: ["Example"],
            },
        ],
    });
    
    import pulumi
    import pulumi_aws as aws
    
    ebs_volume = aws.ebs.get_snapshot(most_recent=True,
        owners=["self"],
        filters=[
            aws.ebs.GetSnapshotFilterArgs(
                name="volume-size",
                values=["40"],
            ),
            aws.ebs.GetSnapshotFilterArgs(
                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.LookupSnapshot(ctx, &ebs.LookupSnapshotArgs{
    			MostRecent: pulumi.BoolRef(true),
    			Owners: []string{
    				"self",
    			},
    			Filters: []ebs.GetSnapshotFilter{
    				{
    					Name: "volume-size",
    					Values: []string{
    						"40",
    					},
    				},
    				{
    					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.GetSnapshot.Invoke(new()
        {
            MostRecent = true,
            Owners = new[]
            {
                "self",
            },
            Filters = new[]
            {
                new Aws.Ebs.Inputs.GetSnapshotFilterInputArgs
                {
                    Name = "volume-size",
                    Values = new[]
                    {
                        "40",
                    },
                },
                new Aws.Ebs.Inputs.GetSnapshotFilterInputArgs
                {
                    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.GetSnapshotArgs;
    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.getSnapshot(GetSnapshotArgs.builder()
                .mostRecent(true)
                .owners("self")
                .filters(            
                    GetSnapshotFilterArgs.builder()
                        .name("volume-size")
                        .values("40")
                        .build(),
                    GetSnapshotFilterArgs.builder()
                        .name("tag:Name")
                        .values("Example")
                        .build())
                .build());
    
        }
    }
    
    variables:
      ebsVolume:
        fn::invoke:
          Function: aws:ebs:getSnapshot
          Arguments:
            mostRecent: true
            owners:
              - self
            filters:
              - name: volume-size
                values:
                  - '40'
              - name: tag:Name
                values:
                  - Example
    

    Using getSnapshot

    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 getSnapshot(args: GetSnapshotArgs, opts?: InvokeOptions): Promise<GetSnapshotResult>
    function getSnapshotOutput(args: GetSnapshotOutputArgs, opts?: InvokeOptions): Output<GetSnapshotResult>
    def get_snapshot(filters: Optional[Sequence[GetSnapshotFilter]] = None,
                     most_recent: Optional[bool] = None,
                     owners: Optional[Sequence[str]] = None,
                     restorable_by_user_ids: Optional[Sequence[str]] = None,
                     snapshot_ids: Optional[Sequence[str]] = None,
                     tags: Optional[Mapping[str, str]] = None,
                     opts: Optional[InvokeOptions] = None) -> GetSnapshotResult
    def get_snapshot_output(filters: Optional[pulumi.Input[Sequence[pulumi.Input[GetSnapshotFilterArgs]]]] = None,
                     most_recent: Optional[pulumi.Input[bool]] = None,
                     owners: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
                     restorable_by_user_ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
                     snapshot_ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
                     tags: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
                     opts: Optional[InvokeOptions] = None) -> Output[GetSnapshotResult]
    func LookupSnapshot(ctx *Context, args *LookupSnapshotArgs, opts ...InvokeOption) (*LookupSnapshotResult, error)
    func LookupSnapshotOutput(ctx *Context, args *LookupSnapshotOutputArgs, opts ...InvokeOption) LookupSnapshotResultOutput

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

    public static class GetSnapshot 
    {
        public static Task<GetSnapshotResult> InvokeAsync(GetSnapshotArgs args, InvokeOptions? opts = null)
        public static Output<GetSnapshotResult> Invoke(GetSnapshotInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetSnapshotResult> getSnapshot(GetSnapshotArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: aws:ebs/getSnapshot:getSnapshot
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Filters List<GetSnapshotFilter>
    One or more name/value pairs to filter off of. There are several valid keys, for a full reference, check out [describe-snapshots in the AWS CLI reference][1].
    MostRecent bool
    If more than one result is returned, use the most recent snapshot.
    Owners List<string>
    Returns the snapshots owned by the specified owner id. Multiple owners can be specified.
    RestorableByUserIds List<string>
    One or more AWS accounts IDs that can create volumes from the snapshot.
    SnapshotIds List<string>
    Returns information on a specific snapshot_id.
    Tags Dictionary<string, string>
    Map of tags for the resource.
    Filters []GetSnapshotFilter
    One or more name/value pairs to filter off of. There are several valid keys, for a full reference, check out [describe-snapshots in the AWS CLI reference][1].
    MostRecent bool
    If more than one result is returned, use the most recent snapshot.
    Owners []string
    Returns the snapshots owned by the specified owner id. Multiple owners can be specified.
    RestorableByUserIds []string
    One or more AWS accounts IDs that can create volumes from the snapshot.
    SnapshotIds []string
    Returns information on a specific snapshot_id.
    Tags map[string]string
    Map of tags for the resource.
    filters List<GetSnapshotFilter>
    One or more name/value pairs to filter off of. There are several valid keys, for a full reference, check out [describe-snapshots in the AWS CLI reference][1].
    mostRecent Boolean
    If more than one result is returned, use the most recent snapshot.
    owners List<String>
    Returns the snapshots owned by the specified owner id. Multiple owners can be specified.
    restorableByUserIds List<String>
    One or more AWS accounts IDs that can create volumes from the snapshot.
    snapshotIds List<String>
    Returns information on a specific snapshot_id.
    tags Map<String,String>
    Map of tags for the resource.
    filters GetSnapshotFilter[]
    One or more name/value pairs to filter off of. There are several valid keys, for a full reference, check out [describe-snapshots in the AWS CLI reference][1].
    mostRecent boolean
    If more than one result is returned, use the most recent snapshot.
    owners string[]
    Returns the snapshots owned by the specified owner id. Multiple owners can be specified.
    restorableByUserIds string[]
    One or more AWS accounts IDs that can create volumes from the snapshot.
    snapshotIds string[]
    Returns information on a specific snapshot_id.
    tags {[key: string]: string}
    Map of tags for the resource.
    filters Sequence[GetSnapshotFilter]
    One or more name/value pairs to filter off of. There are several valid keys, for a full reference, check out [describe-snapshots in the AWS CLI reference][1].
    most_recent bool
    If more than one result is returned, use the most recent snapshot.
    owners Sequence[str]
    Returns the snapshots owned by the specified owner id. Multiple owners can be specified.
    restorable_by_user_ids Sequence[str]
    One or more AWS accounts IDs that can create volumes from the snapshot.
    snapshot_ids Sequence[str]
    Returns information on a specific snapshot_id.
    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-snapshots in the AWS CLI reference][1].
    mostRecent Boolean
    If more than one result is returned, use the most recent snapshot.
    owners List<String>
    Returns the snapshots owned by the specified owner id. Multiple owners can be specified.
    restorableByUserIds List<String>
    One or more AWS accounts IDs that can create volumes from the snapshot.
    snapshotIds List<String>
    Returns information on a specific snapshot_id.
    tags Map<String>
    Map of tags for the resource.

    getSnapshot Result

    The following output properties are available:

    Arn string
    ARN of the EBS Snapshot.
    DataEncryptionKeyId string
    The data encryption key identifier for the snapshot.
    Description string
    Description for the snapshot
    Encrypted bool
    Whether the snapshot is encrypted.
    Id string
    The provider-assigned unique ID for this managed resource.
    KmsKeyId string
    ARN for the KMS encryption key.
    OutpostArn string
    ARN of the Outpost on which the snapshot is stored.
    OwnerAlias string
    Value from an Amazon-maintained list (amazon, aws-marketplace, microsoft) of snapshot owners.
    OwnerId string
    AWS account ID of the EBS snapshot owner.
    SnapshotId string
    Snapshot ID (e.g., snap-59fcb34e).
    State string
    Snapshot state.
    StorageTier string
    Storage tier in which the snapshot is stored.
    Tags Dictionary<string, string>
    Map of tags for the resource.
    VolumeId string
    Volume ID (e.g., vol-59fcb34e).
    VolumeSize int
    Size of the drive in GiBs.
    Filters List<GetSnapshotFilter>
    MostRecent bool
    Owners List<string>
    RestorableByUserIds List<string>
    SnapshotIds List<string>
    Arn string
    ARN of the EBS Snapshot.
    DataEncryptionKeyId string
    The data encryption key identifier for the snapshot.
    Description string
    Description for the snapshot
    Encrypted bool
    Whether the snapshot is encrypted.
    Id string
    The provider-assigned unique ID for this managed resource.
    KmsKeyId string
    ARN for the KMS encryption key.
    OutpostArn string
    ARN of the Outpost on which the snapshot is stored.
    OwnerAlias string
    Value from an Amazon-maintained list (amazon, aws-marketplace, microsoft) of snapshot owners.
    OwnerId string
    AWS account ID of the EBS snapshot owner.
    SnapshotId string
    Snapshot ID (e.g., snap-59fcb34e).
    State string
    Snapshot state.
    StorageTier string
    Storage tier in which the snapshot is stored.
    Tags map[string]string
    Map of tags for the resource.
    VolumeId string
    Volume ID (e.g., vol-59fcb34e).
    VolumeSize int
    Size of the drive in GiBs.
    Filters []GetSnapshotFilter
    MostRecent bool
    Owners []string
    RestorableByUserIds []string
    SnapshotIds []string
    arn String
    ARN of the EBS Snapshot.
    dataEncryptionKeyId String
    The data encryption key identifier for the snapshot.
    description String
    Description for the snapshot
    encrypted Boolean
    Whether the snapshot is encrypted.
    id String
    The provider-assigned unique ID for this managed resource.
    kmsKeyId String
    ARN for the KMS encryption key.
    outpostArn String
    ARN of the Outpost on which the snapshot is stored.
    ownerAlias String
    Value from an Amazon-maintained list (amazon, aws-marketplace, microsoft) of snapshot owners.
    ownerId String
    AWS account ID of the EBS snapshot owner.
    snapshotId String
    Snapshot ID (e.g., snap-59fcb34e).
    state String
    Snapshot state.
    storageTier String
    Storage tier in which the snapshot is stored.
    tags Map<String,String>
    Map of tags for the resource.
    volumeId String
    Volume ID (e.g., vol-59fcb34e).
    volumeSize Integer
    Size of the drive in GiBs.
    filters List<GetSnapshotFilter>
    mostRecent Boolean
    owners List<String>
    restorableByUserIds List<String>
    snapshotIds List<String>
    arn string
    ARN of the EBS Snapshot.
    dataEncryptionKeyId string
    The data encryption key identifier for the snapshot.
    description string
    Description for the snapshot
    encrypted boolean
    Whether the snapshot is encrypted.
    id string
    The provider-assigned unique ID for this managed resource.
    kmsKeyId string
    ARN for the KMS encryption key.
    outpostArn string
    ARN of the Outpost on which the snapshot is stored.
    ownerAlias string
    Value from an Amazon-maintained list (amazon, aws-marketplace, microsoft) of snapshot owners.
    ownerId string
    AWS account ID of the EBS snapshot owner.
    snapshotId string
    Snapshot ID (e.g., snap-59fcb34e).
    state string
    Snapshot state.
    storageTier string
    Storage tier in which the snapshot is stored.
    tags {[key: string]: string}
    Map of tags for the resource.
    volumeId string
    Volume ID (e.g., vol-59fcb34e).
    volumeSize number
    Size of the drive in GiBs.
    filters GetSnapshotFilter[]
    mostRecent boolean
    owners string[]
    restorableByUserIds string[]
    snapshotIds string[]
    arn str
    ARN of the EBS Snapshot.
    data_encryption_key_id str
    The data encryption key identifier for the snapshot.
    description str
    Description for the snapshot
    encrypted bool
    Whether the snapshot is encrypted.
    id str
    The provider-assigned unique ID for this managed resource.
    kms_key_id str
    ARN for the KMS encryption key.
    outpost_arn str
    ARN of the Outpost on which the snapshot is stored.
    owner_alias str
    Value from an Amazon-maintained list (amazon, aws-marketplace, microsoft) of snapshot owners.
    owner_id str
    AWS account ID of the EBS snapshot owner.
    snapshot_id str
    Snapshot ID (e.g., snap-59fcb34e).
    state str
    Snapshot state.
    storage_tier str
    Storage tier in which the snapshot is stored.
    tags Mapping[str, str]
    Map of tags for the resource.
    volume_id str
    Volume ID (e.g., vol-59fcb34e).
    volume_size int
    Size of the drive in GiBs.
    filters Sequence[GetSnapshotFilter]
    most_recent bool
    owners Sequence[str]
    restorable_by_user_ids Sequence[str]
    snapshot_ids Sequence[str]
    arn String
    ARN of the EBS Snapshot.
    dataEncryptionKeyId String
    The data encryption key identifier for the snapshot.
    description String
    Description for the snapshot
    encrypted Boolean
    Whether the snapshot is encrypted.
    id String
    The provider-assigned unique ID for this managed resource.
    kmsKeyId String
    ARN for the KMS encryption key.
    outpostArn String
    ARN of the Outpost on which the snapshot is stored.
    ownerAlias String
    Value from an Amazon-maintained list (amazon, aws-marketplace, microsoft) of snapshot owners.
    ownerId String
    AWS account ID of the EBS snapshot owner.
    snapshotId String
    Snapshot ID (e.g., snap-59fcb34e).
    state String
    Snapshot state.
    storageTier String
    Storage tier in which the snapshot is stored.
    tags Map<String>
    Map of tags for the resource.
    volumeId String
    Volume ID (e.g., vol-59fcb34e).
    volumeSize Number
    Size of the drive in GiBs.
    filters List<Property Map>
    mostRecent Boolean
    owners List<String>
    restorableByUserIds List<String>
    snapshotIds List<String>

    Supporting Types

    GetSnapshotFilter

    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.28.1 published on Thursday, Mar 28, 2024 by Pulumi