github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/ebs/getSnapshot.go (about)

     1  // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
     2  // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
     3  
     4  package ebs
     5  
     6  import (
     7  	"context"
     8  	"reflect"
     9  
    10  	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
    11  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    12  )
    13  
    14  // Use this data source to get information about an EBS Snapshot for use when provisioning EBS Volumes
    15  //
    16  // ## Example Usage
    17  //
    18  // <!--Start PulumiCodeChooser -->
    19  // ```go
    20  // package main
    21  //
    22  // import (
    23  //
    24  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ebs"
    25  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    26  //
    27  // )
    28  //
    29  //	func main() {
    30  //		pulumi.Run(func(ctx *pulumi.Context) error {
    31  //			_, err := ebs.LookupSnapshot(ctx, &ebs.LookupSnapshotArgs{
    32  //				MostRecent: pulumi.BoolRef(true),
    33  //				Owners: []string{
    34  //					"self",
    35  //				},
    36  //				Filters: []ebs.GetSnapshotFilter{
    37  //					{
    38  //						Name: "volume-size",
    39  //						Values: []string{
    40  //							"40",
    41  //						},
    42  //					},
    43  //					{
    44  //						Name: "tag:Name",
    45  //						Values: []string{
    46  //							"Example",
    47  //						},
    48  //					},
    49  //				},
    50  //			}, nil)
    51  //			if err != nil {
    52  //				return err
    53  //			}
    54  //			return nil
    55  //		})
    56  //	}
    57  //
    58  // ```
    59  // <!--End PulumiCodeChooser -->
    60  func LookupSnapshot(ctx *pulumi.Context, args *LookupSnapshotArgs, opts ...pulumi.InvokeOption) (*LookupSnapshotResult, error) {
    61  	opts = internal.PkgInvokeDefaultOpts(opts)
    62  	var rv LookupSnapshotResult
    63  	err := ctx.Invoke("aws:ebs/getSnapshot:getSnapshot", args, &rv, opts...)
    64  	if err != nil {
    65  		return nil, err
    66  	}
    67  	return &rv, nil
    68  }
    69  
    70  // A collection of arguments for invoking getSnapshot.
    71  type LookupSnapshotArgs struct {
    72  	// One or more name/value pairs to filter off of. There are
    73  	// several valid keys, for a full reference, check out
    74  	// [describe-snapshots in the AWS CLI reference][1].
    75  	Filters []GetSnapshotFilter `pulumi:"filters"`
    76  	// If more than one result is returned, use the most recent snapshot.
    77  	MostRecent *bool `pulumi:"mostRecent"`
    78  	// Returns the snapshots owned by the specified owner id. Multiple owners can be specified.
    79  	Owners []string `pulumi:"owners"`
    80  	// One or more AWS accounts IDs that can create volumes from the snapshot.
    81  	RestorableByUserIds []string `pulumi:"restorableByUserIds"`
    82  	// Returns information on a specific snapshot_id.
    83  	SnapshotIds []string `pulumi:"snapshotIds"`
    84  	// Map of tags for the resource.
    85  	Tags map[string]string `pulumi:"tags"`
    86  }
    87  
    88  // A collection of values returned by getSnapshot.
    89  type LookupSnapshotResult struct {
    90  	// ARN of the EBS Snapshot.
    91  	Arn string `pulumi:"arn"`
    92  	// The data encryption key identifier for the snapshot.
    93  	DataEncryptionKeyId string `pulumi:"dataEncryptionKeyId"`
    94  	// Description for the snapshot
    95  	Description string `pulumi:"description"`
    96  	// Whether the snapshot is encrypted.
    97  	Encrypted bool                `pulumi:"encrypted"`
    98  	Filters   []GetSnapshotFilter `pulumi:"filters"`
    99  	// The provider-assigned unique ID for this managed resource.
   100  	Id string `pulumi:"id"`
   101  	// ARN for the KMS encryption key.
   102  	KmsKeyId   string `pulumi:"kmsKeyId"`
   103  	MostRecent *bool  `pulumi:"mostRecent"`
   104  	// ARN of the Outpost on which the snapshot is stored.
   105  	OutpostArn string `pulumi:"outpostArn"`
   106  	// Value from an Amazon-maintained list (`amazon`, `aws-marketplace`, `microsoft`) of snapshot owners.
   107  	OwnerAlias string `pulumi:"ownerAlias"`
   108  	// AWS account ID of the EBS snapshot owner.
   109  	OwnerId             string   `pulumi:"ownerId"`
   110  	Owners              []string `pulumi:"owners"`
   111  	RestorableByUserIds []string `pulumi:"restorableByUserIds"`
   112  	// Snapshot ID (e.g., snap-59fcb34e).
   113  	SnapshotId  string   `pulumi:"snapshotId"`
   114  	SnapshotIds []string `pulumi:"snapshotIds"`
   115  	// Snapshot state.
   116  	State string `pulumi:"state"`
   117  	// Storage tier in which the snapshot is stored.
   118  	StorageTier string `pulumi:"storageTier"`
   119  	// Map of tags for the resource.
   120  	Tags map[string]string `pulumi:"tags"`
   121  	// Volume ID (e.g., vol-59fcb34e).
   122  	VolumeId string `pulumi:"volumeId"`
   123  	// Size of the drive in GiBs.
   124  	VolumeSize int `pulumi:"volumeSize"`
   125  }
   126  
   127  func LookupSnapshotOutput(ctx *pulumi.Context, args LookupSnapshotOutputArgs, opts ...pulumi.InvokeOption) LookupSnapshotResultOutput {
   128  	return pulumi.ToOutputWithContext(context.Background(), args).
   129  		ApplyT(func(v interface{}) (LookupSnapshotResult, error) {
   130  			args := v.(LookupSnapshotArgs)
   131  			r, err := LookupSnapshot(ctx, &args, opts...)
   132  			var s LookupSnapshotResult
   133  			if r != nil {
   134  				s = *r
   135  			}
   136  			return s, err
   137  		}).(LookupSnapshotResultOutput)
   138  }
   139  
   140  // A collection of arguments for invoking getSnapshot.
   141  type LookupSnapshotOutputArgs struct {
   142  	// One or more name/value pairs to filter off of. There are
   143  	// several valid keys, for a full reference, check out
   144  	// [describe-snapshots in the AWS CLI reference][1].
   145  	Filters GetSnapshotFilterArrayInput `pulumi:"filters"`
   146  	// If more than one result is returned, use the most recent snapshot.
   147  	MostRecent pulumi.BoolPtrInput `pulumi:"mostRecent"`
   148  	// Returns the snapshots owned by the specified owner id. Multiple owners can be specified.
   149  	Owners pulumi.StringArrayInput `pulumi:"owners"`
   150  	// One or more AWS accounts IDs that can create volumes from the snapshot.
   151  	RestorableByUserIds pulumi.StringArrayInput `pulumi:"restorableByUserIds"`
   152  	// Returns information on a specific snapshot_id.
   153  	SnapshotIds pulumi.StringArrayInput `pulumi:"snapshotIds"`
   154  	// Map of tags for the resource.
   155  	Tags pulumi.StringMapInput `pulumi:"tags"`
   156  }
   157  
   158  func (LookupSnapshotOutputArgs) ElementType() reflect.Type {
   159  	return reflect.TypeOf((*LookupSnapshotArgs)(nil)).Elem()
   160  }
   161  
   162  // A collection of values returned by getSnapshot.
   163  type LookupSnapshotResultOutput struct{ *pulumi.OutputState }
   164  
   165  func (LookupSnapshotResultOutput) ElementType() reflect.Type {
   166  	return reflect.TypeOf((*LookupSnapshotResult)(nil)).Elem()
   167  }
   168  
   169  func (o LookupSnapshotResultOutput) ToLookupSnapshotResultOutput() LookupSnapshotResultOutput {
   170  	return o
   171  }
   172  
   173  func (o LookupSnapshotResultOutput) ToLookupSnapshotResultOutputWithContext(ctx context.Context) LookupSnapshotResultOutput {
   174  	return o
   175  }
   176  
   177  // ARN of the EBS Snapshot.
   178  func (o LookupSnapshotResultOutput) Arn() pulumi.StringOutput {
   179  	return o.ApplyT(func(v LookupSnapshotResult) string { return v.Arn }).(pulumi.StringOutput)
   180  }
   181  
   182  // The data encryption key identifier for the snapshot.
   183  func (o LookupSnapshotResultOutput) DataEncryptionKeyId() pulumi.StringOutput {
   184  	return o.ApplyT(func(v LookupSnapshotResult) string { return v.DataEncryptionKeyId }).(pulumi.StringOutput)
   185  }
   186  
   187  // Description for the snapshot
   188  func (o LookupSnapshotResultOutput) Description() pulumi.StringOutput {
   189  	return o.ApplyT(func(v LookupSnapshotResult) string { return v.Description }).(pulumi.StringOutput)
   190  }
   191  
   192  // Whether the snapshot is encrypted.
   193  func (o LookupSnapshotResultOutput) Encrypted() pulumi.BoolOutput {
   194  	return o.ApplyT(func(v LookupSnapshotResult) bool { return v.Encrypted }).(pulumi.BoolOutput)
   195  }
   196  
   197  func (o LookupSnapshotResultOutput) Filters() GetSnapshotFilterArrayOutput {
   198  	return o.ApplyT(func(v LookupSnapshotResult) []GetSnapshotFilter { return v.Filters }).(GetSnapshotFilterArrayOutput)
   199  }
   200  
   201  // The provider-assigned unique ID for this managed resource.
   202  func (o LookupSnapshotResultOutput) Id() pulumi.StringOutput {
   203  	return o.ApplyT(func(v LookupSnapshotResult) string { return v.Id }).(pulumi.StringOutput)
   204  }
   205  
   206  // ARN for the KMS encryption key.
   207  func (o LookupSnapshotResultOutput) KmsKeyId() pulumi.StringOutput {
   208  	return o.ApplyT(func(v LookupSnapshotResult) string { return v.KmsKeyId }).(pulumi.StringOutput)
   209  }
   210  
   211  func (o LookupSnapshotResultOutput) MostRecent() pulumi.BoolPtrOutput {
   212  	return o.ApplyT(func(v LookupSnapshotResult) *bool { return v.MostRecent }).(pulumi.BoolPtrOutput)
   213  }
   214  
   215  // ARN of the Outpost on which the snapshot is stored.
   216  func (o LookupSnapshotResultOutput) OutpostArn() pulumi.StringOutput {
   217  	return o.ApplyT(func(v LookupSnapshotResult) string { return v.OutpostArn }).(pulumi.StringOutput)
   218  }
   219  
   220  // Value from an Amazon-maintained list (`amazon`, `aws-marketplace`, `microsoft`) of snapshot owners.
   221  func (o LookupSnapshotResultOutput) OwnerAlias() pulumi.StringOutput {
   222  	return o.ApplyT(func(v LookupSnapshotResult) string { return v.OwnerAlias }).(pulumi.StringOutput)
   223  }
   224  
   225  // AWS account ID of the EBS snapshot owner.
   226  func (o LookupSnapshotResultOutput) OwnerId() pulumi.StringOutput {
   227  	return o.ApplyT(func(v LookupSnapshotResult) string { return v.OwnerId }).(pulumi.StringOutput)
   228  }
   229  
   230  func (o LookupSnapshotResultOutput) Owners() pulumi.StringArrayOutput {
   231  	return o.ApplyT(func(v LookupSnapshotResult) []string { return v.Owners }).(pulumi.StringArrayOutput)
   232  }
   233  
   234  func (o LookupSnapshotResultOutput) RestorableByUserIds() pulumi.StringArrayOutput {
   235  	return o.ApplyT(func(v LookupSnapshotResult) []string { return v.RestorableByUserIds }).(pulumi.StringArrayOutput)
   236  }
   237  
   238  // Snapshot ID (e.g., snap-59fcb34e).
   239  func (o LookupSnapshotResultOutput) SnapshotId() pulumi.StringOutput {
   240  	return o.ApplyT(func(v LookupSnapshotResult) string { return v.SnapshotId }).(pulumi.StringOutput)
   241  }
   242  
   243  func (o LookupSnapshotResultOutput) SnapshotIds() pulumi.StringArrayOutput {
   244  	return o.ApplyT(func(v LookupSnapshotResult) []string { return v.SnapshotIds }).(pulumi.StringArrayOutput)
   245  }
   246  
   247  // Snapshot state.
   248  func (o LookupSnapshotResultOutput) State() pulumi.StringOutput {
   249  	return o.ApplyT(func(v LookupSnapshotResult) string { return v.State }).(pulumi.StringOutput)
   250  }
   251  
   252  // Storage tier in which the snapshot is stored.
   253  func (o LookupSnapshotResultOutput) StorageTier() pulumi.StringOutput {
   254  	return o.ApplyT(func(v LookupSnapshotResult) string { return v.StorageTier }).(pulumi.StringOutput)
   255  }
   256  
   257  // Map of tags for the resource.
   258  func (o LookupSnapshotResultOutput) Tags() pulumi.StringMapOutput {
   259  	return o.ApplyT(func(v LookupSnapshotResult) map[string]string { return v.Tags }).(pulumi.StringMapOutput)
   260  }
   261  
   262  // Volume ID (e.g., vol-59fcb34e).
   263  func (o LookupSnapshotResultOutput) VolumeId() pulumi.StringOutput {
   264  	return o.ApplyT(func(v LookupSnapshotResult) string { return v.VolumeId }).(pulumi.StringOutput)
   265  }
   266  
   267  // Size of the drive in GiBs.
   268  func (o LookupSnapshotResultOutput) VolumeSize() pulumi.IntOutput {
   269  	return o.ApplyT(func(v LookupSnapshotResult) int { return v.VolumeSize }).(pulumi.IntOutput)
   270  }
   271  
   272  func init() {
   273  	pulumi.RegisterOutputType(LookupSnapshotResultOutput{})
   274  }