github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/rds/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 rds
     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 a DB Snapshot for use when provisioning DB instances
    15  //
    16  // > **NOTE:** This data source does not apply to snapshots created on Aurora DB clusters.
    17  // See the `rds.ClusterSnapshot` data source for DB Cluster snapshots.
    18  //
    19  // ## Example Usage
    20  //
    21  // <!--Start PulumiCodeChooser -->
    22  // ```go
    23  // package main
    24  //
    25  // import (
    26  //
    27  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/rds"
    28  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    29  //
    30  // )
    31  //
    32  //	func main() {
    33  //		pulumi.Run(func(ctx *pulumi.Context) error {
    34  //			prod, err := rds.NewInstance(ctx, "prod", &rds.InstanceArgs{
    35  //				AllocatedStorage:   pulumi.Int(10),
    36  //				Engine:             pulumi.String("mysql"),
    37  //				EngineVersion:      pulumi.String("5.6.17"),
    38  //				InstanceClass:      pulumi.String(rds.InstanceType_T2_Micro),
    39  //				DbName:             pulumi.String("mydb"),
    40  //				Username:           pulumi.String("foo"),
    41  //				Password:           pulumi.String("bar"),
    42  //				DbSubnetGroupName:  pulumi.String("my_database_subnet_group"),
    43  //				ParameterGroupName: pulumi.String("default.mysql5.6"),
    44  //			})
    45  //			if err != nil {
    46  //				return err
    47  //			}
    48  //			latestProdSnapshot := rds.LookupSnapshotOutput(ctx, rds.GetSnapshotOutputArgs{
    49  //				DbInstanceIdentifier: prod.Identifier,
    50  //				MostRecent:           pulumi.Bool(true),
    51  //			}, nil)
    52  //			// Use the latest production snapshot to create a dev instance.
    53  //			_, err = rds.NewInstance(ctx, "dev", &rds.InstanceArgs{
    54  //				InstanceClass: pulumi.String(rds.InstanceType_T2_Micro),
    55  //				DbName:        pulumi.String("mydbdev"),
    56  //				SnapshotIdentifier: latestProdSnapshot.ApplyT(func(latestProdSnapshot rds.GetSnapshotResult) (*string, error) {
    57  //					return &latestProdSnapshot.Id, nil
    58  //				}).(pulumi.StringPtrOutput),
    59  //			})
    60  //			if err != nil {
    61  //				return err
    62  //			}
    63  //			return nil
    64  //		})
    65  //	}
    66  //
    67  // ```
    68  // <!--End PulumiCodeChooser -->
    69  func LookupSnapshot(ctx *pulumi.Context, args *LookupSnapshotArgs, opts ...pulumi.InvokeOption) (*LookupSnapshotResult, error) {
    70  	opts = internal.PkgInvokeDefaultOpts(opts)
    71  	var rv LookupSnapshotResult
    72  	err := ctx.Invoke("aws:rds/getSnapshot:getSnapshot", args, &rv, opts...)
    73  	if err != nil {
    74  		return nil, err
    75  	}
    76  	return &rv, nil
    77  }
    78  
    79  // A collection of arguments for invoking getSnapshot.
    80  type LookupSnapshotArgs struct {
    81  	// Returns the list of snapshots created by the specific db_instance
    82  	DbInstanceIdentifier *string `pulumi:"dbInstanceIdentifier"`
    83  	// Returns information on a specific snapshot_id.
    84  	DbSnapshotIdentifier *string `pulumi:"dbSnapshotIdentifier"`
    85  	// Set this value to true to include manual DB snapshots that are public and can be
    86  	// copied or restored by any AWS account, otherwise set this value to false. The default is `false`.
    87  	IncludePublic *bool `pulumi:"includePublic"`
    88  	// Set this value to true to include shared manual DB snapshots from other
    89  	// AWS accounts that this AWS account has been given permission to copy or restore, otherwise set this value to false.
    90  	// The default is `false`.
    91  	IncludeShared *bool `pulumi:"includeShared"`
    92  	// If more than one result is returned, use the most
    93  	// recent Snapshot.
    94  	MostRecent *bool `pulumi:"mostRecent"`
    95  	// Type of snapshots to be returned. If you don't specify a SnapshotType
    96  	// value, then both automated and manual snapshots are returned. Shared and public DB snapshots are not
    97  	// included in the returned results by default. Possible values are, `automated`, `manual`, `shared`, `public` and `awsbackup`.
    98  	SnapshotType *string `pulumi:"snapshotType"`
    99  	// Mapping of tags, each pair of which must exactly match
   100  	// a pair on the desired DB snapshot.
   101  	Tags map[string]string `pulumi:"tags"`
   102  }
   103  
   104  // A collection of values returned by getSnapshot.
   105  type LookupSnapshotResult struct {
   106  	// Allocated storage size in gigabytes (GB).
   107  	AllocatedStorage int `pulumi:"allocatedStorage"`
   108  	// Name of the Availability Zone the DB instance was located in at the time of the DB snapshot.
   109  	AvailabilityZone     string  `pulumi:"availabilityZone"`
   110  	DbInstanceIdentifier *string `pulumi:"dbInstanceIdentifier"`
   111  	// ARN for the DB snapshot.
   112  	DbSnapshotArn        string  `pulumi:"dbSnapshotArn"`
   113  	DbSnapshotIdentifier *string `pulumi:"dbSnapshotIdentifier"`
   114  	// Whether the DB snapshot is encrypted.
   115  	Encrypted bool `pulumi:"encrypted"`
   116  	// Name of the database engine.
   117  	Engine string `pulumi:"engine"`
   118  	// Version of the database engine.
   119  	EngineVersion string `pulumi:"engineVersion"`
   120  	// The provider-assigned unique ID for this managed resource.
   121  	Id            string `pulumi:"id"`
   122  	IncludePublic *bool  `pulumi:"includePublic"`
   123  	IncludeShared *bool  `pulumi:"includeShared"`
   124  	// Provisioned IOPS (I/O operations per second) value of the DB instance at the time of the snapshot.
   125  	Iops int `pulumi:"iops"`
   126  	// ARN for the KMS encryption key.
   127  	KmsKeyId string `pulumi:"kmsKeyId"`
   128  	// License model information for the restored DB instance.
   129  	LicenseModel string `pulumi:"licenseModel"`
   130  	MostRecent   *bool  `pulumi:"mostRecent"`
   131  	// Provides the option group name for the DB snapshot.
   132  	OptionGroupName string `pulumi:"optionGroupName"`
   133  	// Provides the time when the snapshot was taken, in Universal Coordinated Time (UTC). Doesn't change when the snapshot is copied.
   134  	OriginalSnapshotCreateTime string `pulumi:"originalSnapshotCreateTime"`
   135  	Port                       int    `pulumi:"port"`
   136  	// Provides the time when the snapshot was taken, in Universal Coordinated Time (UTC). Changes for the copy when the snapshot is copied.
   137  	SnapshotCreateTime string  `pulumi:"snapshotCreateTime"`
   138  	SnapshotType       *string `pulumi:"snapshotType"`
   139  	// DB snapshot ARN that the DB snapshot was copied from. It only has value in case of cross customer or cross region copy.
   140  	SourceDbSnapshotIdentifier string `pulumi:"sourceDbSnapshotIdentifier"`
   141  	// Region that the DB snapshot was created in or copied from.
   142  	SourceRegion string `pulumi:"sourceRegion"`
   143  	// Status of this DB snapshot.
   144  	Status string `pulumi:"status"`
   145  	// Storage type associated with DB snapshot.
   146  	StorageType string            `pulumi:"storageType"`
   147  	Tags        map[string]string `pulumi:"tags"`
   148  	// ID of the VPC associated with the DB snapshot.
   149  	VpcId string `pulumi:"vpcId"`
   150  }
   151  
   152  func LookupSnapshotOutput(ctx *pulumi.Context, args LookupSnapshotOutputArgs, opts ...pulumi.InvokeOption) LookupSnapshotResultOutput {
   153  	return pulumi.ToOutputWithContext(context.Background(), args).
   154  		ApplyT(func(v interface{}) (LookupSnapshotResult, error) {
   155  			args := v.(LookupSnapshotArgs)
   156  			r, err := LookupSnapshot(ctx, &args, opts...)
   157  			var s LookupSnapshotResult
   158  			if r != nil {
   159  				s = *r
   160  			}
   161  			return s, err
   162  		}).(LookupSnapshotResultOutput)
   163  }
   164  
   165  // A collection of arguments for invoking getSnapshot.
   166  type LookupSnapshotOutputArgs struct {
   167  	// Returns the list of snapshots created by the specific db_instance
   168  	DbInstanceIdentifier pulumi.StringPtrInput `pulumi:"dbInstanceIdentifier"`
   169  	// Returns information on a specific snapshot_id.
   170  	DbSnapshotIdentifier pulumi.StringPtrInput `pulumi:"dbSnapshotIdentifier"`
   171  	// Set this value to true to include manual DB snapshots that are public and can be
   172  	// copied or restored by any AWS account, otherwise set this value to false. The default is `false`.
   173  	IncludePublic pulumi.BoolPtrInput `pulumi:"includePublic"`
   174  	// Set this value to true to include shared manual DB snapshots from other
   175  	// AWS accounts that this AWS account has been given permission to copy or restore, otherwise set this value to false.
   176  	// The default is `false`.
   177  	IncludeShared pulumi.BoolPtrInput `pulumi:"includeShared"`
   178  	// If more than one result is returned, use the most
   179  	// recent Snapshot.
   180  	MostRecent pulumi.BoolPtrInput `pulumi:"mostRecent"`
   181  	// Type of snapshots to be returned. If you don't specify a SnapshotType
   182  	// value, then both automated and manual snapshots are returned. Shared and public DB snapshots are not
   183  	// included in the returned results by default. Possible values are, `automated`, `manual`, `shared`, `public` and `awsbackup`.
   184  	SnapshotType pulumi.StringPtrInput `pulumi:"snapshotType"`
   185  	// Mapping of tags, each pair of which must exactly match
   186  	// a pair on the desired DB snapshot.
   187  	Tags pulumi.StringMapInput `pulumi:"tags"`
   188  }
   189  
   190  func (LookupSnapshotOutputArgs) ElementType() reflect.Type {
   191  	return reflect.TypeOf((*LookupSnapshotArgs)(nil)).Elem()
   192  }
   193  
   194  // A collection of values returned by getSnapshot.
   195  type LookupSnapshotResultOutput struct{ *pulumi.OutputState }
   196  
   197  func (LookupSnapshotResultOutput) ElementType() reflect.Type {
   198  	return reflect.TypeOf((*LookupSnapshotResult)(nil)).Elem()
   199  }
   200  
   201  func (o LookupSnapshotResultOutput) ToLookupSnapshotResultOutput() LookupSnapshotResultOutput {
   202  	return o
   203  }
   204  
   205  func (o LookupSnapshotResultOutput) ToLookupSnapshotResultOutputWithContext(ctx context.Context) LookupSnapshotResultOutput {
   206  	return o
   207  }
   208  
   209  // Allocated storage size in gigabytes (GB).
   210  func (o LookupSnapshotResultOutput) AllocatedStorage() pulumi.IntOutput {
   211  	return o.ApplyT(func(v LookupSnapshotResult) int { return v.AllocatedStorage }).(pulumi.IntOutput)
   212  }
   213  
   214  // Name of the Availability Zone the DB instance was located in at the time of the DB snapshot.
   215  func (o LookupSnapshotResultOutput) AvailabilityZone() pulumi.StringOutput {
   216  	return o.ApplyT(func(v LookupSnapshotResult) string { return v.AvailabilityZone }).(pulumi.StringOutput)
   217  }
   218  
   219  func (o LookupSnapshotResultOutput) DbInstanceIdentifier() pulumi.StringPtrOutput {
   220  	return o.ApplyT(func(v LookupSnapshotResult) *string { return v.DbInstanceIdentifier }).(pulumi.StringPtrOutput)
   221  }
   222  
   223  // ARN for the DB snapshot.
   224  func (o LookupSnapshotResultOutput) DbSnapshotArn() pulumi.StringOutput {
   225  	return o.ApplyT(func(v LookupSnapshotResult) string { return v.DbSnapshotArn }).(pulumi.StringOutput)
   226  }
   227  
   228  func (o LookupSnapshotResultOutput) DbSnapshotIdentifier() pulumi.StringPtrOutput {
   229  	return o.ApplyT(func(v LookupSnapshotResult) *string { return v.DbSnapshotIdentifier }).(pulumi.StringPtrOutput)
   230  }
   231  
   232  // Whether the DB snapshot is encrypted.
   233  func (o LookupSnapshotResultOutput) Encrypted() pulumi.BoolOutput {
   234  	return o.ApplyT(func(v LookupSnapshotResult) bool { return v.Encrypted }).(pulumi.BoolOutput)
   235  }
   236  
   237  // Name of the database engine.
   238  func (o LookupSnapshotResultOutput) Engine() pulumi.StringOutput {
   239  	return o.ApplyT(func(v LookupSnapshotResult) string { return v.Engine }).(pulumi.StringOutput)
   240  }
   241  
   242  // Version of the database engine.
   243  func (o LookupSnapshotResultOutput) EngineVersion() pulumi.StringOutput {
   244  	return o.ApplyT(func(v LookupSnapshotResult) string { return v.EngineVersion }).(pulumi.StringOutput)
   245  }
   246  
   247  // The provider-assigned unique ID for this managed resource.
   248  func (o LookupSnapshotResultOutput) Id() pulumi.StringOutput {
   249  	return o.ApplyT(func(v LookupSnapshotResult) string { return v.Id }).(pulumi.StringOutput)
   250  }
   251  
   252  func (o LookupSnapshotResultOutput) IncludePublic() pulumi.BoolPtrOutput {
   253  	return o.ApplyT(func(v LookupSnapshotResult) *bool { return v.IncludePublic }).(pulumi.BoolPtrOutput)
   254  }
   255  
   256  func (o LookupSnapshotResultOutput) IncludeShared() pulumi.BoolPtrOutput {
   257  	return o.ApplyT(func(v LookupSnapshotResult) *bool { return v.IncludeShared }).(pulumi.BoolPtrOutput)
   258  }
   259  
   260  // Provisioned IOPS (I/O operations per second) value of the DB instance at the time of the snapshot.
   261  func (o LookupSnapshotResultOutput) Iops() pulumi.IntOutput {
   262  	return o.ApplyT(func(v LookupSnapshotResult) int { return v.Iops }).(pulumi.IntOutput)
   263  }
   264  
   265  // ARN for the KMS encryption key.
   266  func (o LookupSnapshotResultOutput) KmsKeyId() pulumi.StringOutput {
   267  	return o.ApplyT(func(v LookupSnapshotResult) string { return v.KmsKeyId }).(pulumi.StringOutput)
   268  }
   269  
   270  // License model information for the restored DB instance.
   271  func (o LookupSnapshotResultOutput) LicenseModel() pulumi.StringOutput {
   272  	return o.ApplyT(func(v LookupSnapshotResult) string { return v.LicenseModel }).(pulumi.StringOutput)
   273  }
   274  
   275  func (o LookupSnapshotResultOutput) MostRecent() pulumi.BoolPtrOutput {
   276  	return o.ApplyT(func(v LookupSnapshotResult) *bool { return v.MostRecent }).(pulumi.BoolPtrOutput)
   277  }
   278  
   279  // Provides the option group name for the DB snapshot.
   280  func (o LookupSnapshotResultOutput) OptionGroupName() pulumi.StringOutput {
   281  	return o.ApplyT(func(v LookupSnapshotResult) string { return v.OptionGroupName }).(pulumi.StringOutput)
   282  }
   283  
   284  // Provides the time when the snapshot was taken, in Universal Coordinated Time (UTC). Doesn't change when the snapshot is copied.
   285  func (o LookupSnapshotResultOutput) OriginalSnapshotCreateTime() pulumi.StringOutput {
   286  	return o.ApplyT(func(v LookupSnapshotResult) string { return v.OriginalSnapshotCreateTime }).(pulumi.StringOutput)
   287  }
   288  
   289  func (o LookupSnapshotResultOutput) Port() pulumi.IntOutput {
   290  	return o.ApplyT(func(v LookupSnapshotResult) int { return v.Port }).(pulumi.IntOutput)
   291  }
   292  
   293  // Provides the time when the snapshot was taken, in Universal Coordinated Time (UTC). Changes for the copy when the snapshot is copied.
   294  func (o LookupSnapshotResultOutput) SnapshotCreateTime() pulumi.StringOutput {
   295  	return o.ApplyT(func(v LookupSnapshotResult) string { return v.SnapshotCreateTime }).(pulumi.StringOutput)
   296  }
   297  
   298  func (o LookupSnapshotResultOutput) SnapshotType() pulumi.StringPtrOutput {
   299  	return o.ApplyT(func(v LookupSnapshotResult) *string { return v.SnapshotType }).(pulumi.StringPtrOutput)
   300  }
   301  
   302  // DB snapshot ARN that the DB snapshot was copied from. It only has value in case of cross customer or cross region copy.
   303  func (o LookupSnapshotResultOutput) SourceDbSnapshotIdentifier() pulumi.StringOutput {
   304  	return o.ApplyT(func(v LookupSnapshotResult) string { return v.SourceDbSnapshotIdentifier }).(pulumi.StringOutput)
   305  }
   306  
   307  // Region that the DB snapshot was created in or copied from.
   308  func (o LookupSnapshotResultOutput) SourceRegion() pulumi.StringOutput {
   309  	return o.ApplyT(func(v LookupSnapshotResult) string { return v.SourceRegion }).(pulumi.StringOutput)
   310  }
   311  
   312  // Status of this DB snapshot.
   313  func (o LookupSnapshotResultOutput) Status() pulumi.StringOutput {
   314  	return o.ApplyT(func(v LookupSnapshotResult) string { return v.Status }).(pulumi.StringOutput)
   315  }
   316  
   317  // Storage type associated with DB snapshot.
   318  func (o LookupSnapshotResultOutput) StorageType() pulumi.StringOutput {
   319  	return o.ApplyT(func(v LookupSnapshotResult) string { return v.StorageType }).(pulumi.StringOutput)
   320  }
   321  
   322  func (o LookupSnapshotResultOutput) Tags() pulumi.StringMapOutput {
   323  	return o.ApplyT(func(v LookupSnapshotResult) map[string]string { return v.Tags }).(pulumi.StringMapOutput)
   324  }
   325  
   326  // ID of the VPC associated with the DB snapshot.
   327  func (o LookupSnapshotResultOutput) VpcId() pulumi.StringOutput {
   328  	return o.ApplyT(func(v LookupSnapshotResult) string { return v.VpcId }).(pulumi.StringOutput)
   329  }
   330  
   331  func init() {
   332  	pulumi.RegisterOutputType(LookupSnapshotResultOutput{})
   333  }