github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/memorydb/snapshot.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 memorydb
     5  
     6  import (
     7  	"context"
     8  	"reflect"
     9  
    10  	"errors"
    11  	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
    12  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    13  )
    14  
    15  // Provides a MemoryDB Snapshot.
    16  //
    17  // More information about snapshot and restore can be found in the [MemoryDB User Guide](https://docs.aws.amazon.com/memorydb/latest/devguide/snapshots.html).
    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/memorydb"
    28  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    29  //
    30  // )
    31  //
    32  //	func main() {
    33  //		pulumi.Run(func(ctx *pulumi.Context) error {
    34  //			_, err := memorydb.NewSnapshot(ctx, "example", &memorydb.SnapshotArgs{
    35  //				ClusterName: pulumi.Any(exampleAwsMemorydbCluster.Name),
    36  //				Name:        pulumi.String("my-snapshot"),
    37  //			})
    38  //			if err != nil {
    39  //				return err
    40  //			}
    41  //			return nil
    42  //		})
    43  //	}
    44  //
    45  // ```
    46  // <!--End PulumiCodeChooser -->
    47  //
    48  // ## Import
    49  //
    50  // Using `pulumi import`, import a snapshot using the `name`. For example:
    51  //
    52  // ```sh
    53  // $ pulumi import aws:memorydb/snapshot:Snapshot example my-snapshot
    54  // ```
    55  type Snapshot struct {
    56  	pulumi.CustomResourceState
    57  
    58  	// The ARN of the snapshot.
    59  	Arn pulumi.StringOutput `pulumi:"arn"`
    60  	// The configuration of the cluster from which the snapshot was taken.
    61  	ClusterConfigurations SnapshotClusterConfigurationArrayOutput `pulumi:"clusterConfigurations"`
    62  	// Name of the MemoryDB cluster to take a snapshot of.
    63  	ClusterName pulumi.StringOutput `pulumi:"clusterName"`
    64  	// ARN of the KMS key used to encrypt the snapshot at rest.
    65  	KmsKeyArn pulumi.StringPtrOutput `pulumi:"kmsKeyArn"`
    66  	// Name of the snapshot. If omitted, the provider will assign a random, unique name. Conflicts with `namePrefix`.
    67  	Name pulumi.StringOutput `pulumi:"name"`
    68  	// Creates a unique name beginning with the specified prefix. Conflicts with `name`.
    69  	NamePrefix pulumi.StringOutput `pulumi:"namePrefix"`
    70  	// Indicates whether the snapshot is from an automatic backup (`automated`) or was created manually (`manual`).
    71  	Source pulumi.StringOutput `pulumi:"source"`
    72  	// A map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
    73  	Tags pulumi.StringMapOutput `pulumi:"tags"`
    74  	// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
    75  	//
    76  	// Deprecated: Please use `tags` instead.
    77  	TagsAll pulumi.StringMapOutput `pulumi:"tagsAll"`
    78  }
    79  
    80  // NewSnapshot registers a new resource with the given unique name, arguments, and options.
    81  func NewSnapshot(ctx *pulumi.Context,
    82  	name string, args *SnapshotArgs, opts ...pulumi.ResourceOption) (*Snapshot, error) {
    83  	if args == nil {
    84  		return nil, errors.New("missing one or more required arguments")
    85  	}
    86  
    87  	if args.ClusterName == nil {
    88  		return nil, errors.New("invalid value for required argument 'ClusterName'")
    89  	}
    90  	opts = internal.PkgResourceDefaultOpts(opts)
    91  	var resource Snapshot
    92  	err := ctx.RegisterResource("aws:memorydb/snapshot:Snapshot", name, args, &resource, opts...)
    93  	if err != nil {
    94  		return nil, err
    95  	}
    96  	return &resource, nil
    97  }
    98  
    99  // GetSnapshot gets an existing Snapshot resource's state with the given name, ID, and optional
   100  // state properties that are used to uniquely qualify the lookup (nil if not required).
   101  func GetSnapshot(ctx *pulumi.Context,
   102  	name string, id pulumi.IDInput, state *SnapshotState, opts ...pulumi.ResourceOption) (*Snapshot, error) {
   103  	var resource Snapshot
   104  	err := ctx.ReadResource("aws:memorydb/snapshot:Snapshot", name, id, state, &resource, opts...)
   105  	if err != nil {
   106  		return nil, err
   107  	}
   108  	return &resource, nil
   109  }
   110  
   111  // Input properties used for looking up and filtering Snapshot resources.
   112  type snapshotState struct {
   113  	// The ARN of the snapshot.
   114  	Arn *string `pulumi:"arn"`
   115  	// The configuration of the cluster from which the snapshot was taken.
   116  	ClusterConfigurations []SnapshotClusterConfiguration `pulumi:"clusterConfigurations"`
   117  	// Name of the MemoryDB cluster to take a snapshot of.
   118  	ClusterName *string `pulumi:"clusterName"`
   119  	// ARN of the KMS key used to encrypt the snapshot at rest.
   120  	KmsKeyArn *string `pulumi:"kmsKeyArn"`
   121  	// Name of the snapshot. If omitted, the provider will assign a random, unique name. Conflicts with `namePrefix`.
   122  	Name *string `pulumi:"name"`
   123  	// Creates a unique name beginning with the specified prefix. Conflicts with `name`.
   124  	NamePrefix *string `pulumi:"namePrefix"`
   125  	// Indicates whether the snapshot is from an automatic backup (`automated`) or was created manually (`manual`).
   126  	Source *string `pulumi:"source"`
   127  	// A map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   128  	Tags map[string]string `pulumi:"tags"`
   129  	// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   130  	//
   131  	// Deprecated: Please use `tags` instead.
   132  	TagsAll map[string]string `pulumi:"tagsAll"`
   133  }
   134  
   135  type SnapshotState struct {
   136  	// The ARN of the snapshot.
   137  	Arn pulumi.StringPtrInput
   138  	// The configuration of the cluster from which the snapshot was taken.
   139  	ClusterConfigurations SnapshotClusterConfigurationArrayInput
   140  	// Name of the MemoryDB cluster to take a snapshot of.
   141  	ClusterName pulumi.StringPtrInput
   142  	// ARN of the KMS key used to encrypt the snapshot at rest.
   143  	KmsKeyArn pulumi.StringPtrInput
   144  	// Name of the snapshot. If omitted, the provider will assign a random, unique name. Conflicts with `namePrefix`.
   145  	Name pulumi.StringPtrInput
   146  	// Creates a unique name beginning with the specified prefix. Conflicts with `name`.
   147  	NamePrefix pulumi.StringPtrInput
   148  	// Indicates whether the snapshot is from an automatic backup (`automated`) or was created manually (`manual`).
   149  	Source pulumi.StringPtrInput
   150  	// A map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   151  	Tags pulumi.StringMapInput
   152  	// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   153  	//
   154  	// Deprecated: Please use `tags` instead.
   155  	TagsAll pulumi.StringMapInput
   156  }
   157  
   158  func (SnapshotState) ElementType() reflect.Type {
   159  	return reflect.TypeOf((*snapshotState)(nil)).Elem()
   160  }
   161  
   162  type snapshotArgs struct {
   163  	// Name of the MemoryDB cluster to take a snapshot of.
   164  	ClusterName string `pulumi:"clusterName"`
   165  	// ARN of the KMS key used to encrypt the snapshot at rest.
   166  	KmsKeyArn *string `pulumi:"kmsKeyArn"`
   167  	// Name of the snapshot. If omitted, the provider will assign a random, unique name. Conflicts with `namePrefix`.
   168  	Name *string `pulumi:"name"`
   169  	// Creates a unique name beginning with the specified prefix. Conflicts with `name`.
   170  	NamePrefix *string `pulumi:"namePrefix"`
   171  	// A map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   172  	Tags map[string]string `pulumi:"tags"`
   173  }
   174  
   175  // The set of arguments for constructing a Snapshot resource.
   176  type SnapshotArgs struct {
   177  	// Name of the MemoryDB cluster to take a snapshot of.
   178  	ClusterName pulumi.StringInput
   179  	// ARN of the KMS key used to encrypt the snapshot at rest.
   180  	KmsKeyArn pulumi.StringPtrInput
   181  	// Name of the snapshot. If omitted, the provider will assign a random, unique name. Conflicts with `namePrefix`.
   182  	Name pulumi.StringPtrInput
   183  	// Creates a unique name beginning with the specified prefix. Conflicts with `name`.
   184  	NamePrefix pulumi.StringPtrInput
   185  	// A map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   186  	Tags pulumi.StringMapInput
   187  }
   188  
   189  func (SnapshotArgs) ElementType() reflect.Type {
   190  	return reflect.TypeOf((*snapshotArgs)(nil)).Elem()
   191  }
   192  
   193  type SnapshotInput interface {
   194  	pulumi.Input
   195  
   196  	ToSnapshotOutput() SnapshotOutput
   197  	ToSnapshotOutputWithContext(ctx context.Context) SnapshotOutput
   198  }
   199  
   200  func (*Snapshot) ElementType() reflect.Type {
   201  	return reflect.TypeOf((**Snapshot)(nil)).Elem()
   202  }
   203  
   204  func (i *Snapshot) ToSnapshotOutput() SnapshotOutput {
   205  	return i.ToSnapshotOutputWithContext(context.Background())
   206  }
   207  
   208  func (i *Snapshot) ToSnapshotOutputWithContext(ctx context.Context) SnapshotOutput {
   209  	return pulumi.ToOutputWithContext(ctx, i).(SnapshotOutput)
   210  }
   211  
   212  // SnapshotArrayInput is an input type that accepts SnapshotArray and SnapshotArrayOutput values.
   213  // You can construct a concrete instance of `SnapshotArrayInput` via:
   214  //
   215  //	SnapshotArray{ SnapshotArgs{...} }
   216  type SnapshotArrayInput interface {
   217  	pulumi.Input
   218  
   219  	ToSnapshotArrayOutput() SnapshotArrayOutput
   220  	ToSnapshotArrayOutputWithContext(context.Context) SnapshotArrayOutput
   221  }
   222  
   223  type SnapshotArray []SnapshotInput
   224  
   225  func (SnapshotArray) ElementType() reflect.Type {
   226  	return reflect.TypeOf((*[]*Snapshot)(nil)).Elem()
   227  }
   228  
   229  func (i SnapshotArray) ToSnapshotArrayOutput() SnapshotArrayOutput {
   230  	return i.ToSnapshotArrayOutputWithContext(context.Background())
   231  }
   232  
   233  func (i SnapshotArray) ToSnapshotArrayOutputWithContext(ctx context.Context) SnapshotArrayOutput {
   234  	return pulumi.ToOutputWithContext(ctx, i).(SnapshotArrayOutput)
   235  }
   236  
   237  // SnapshotMapInput is an input type that accepts SnapshotMap and SnapshotMapOutput values.
   238  // You can construct a concrete instance of `SnapshotMapInput` via:
   239  //
   240  //	SnapshotMap{ "key": SnapshotArgs{...} }
   241  type SnapshotMapInput interface {
   242  	pulumi.Input
   243  
   244  	ToSnapshotMapOutput() SnapshotMapOutput
   245  	ToSnapshotMapOutputWithContext(context.Context) SnapshotMapOutput
   246  }
   247  
   248  type SnapshotMap map[string]SnapshotInput
   249  
   250  func (SnapshotMap) ElementType() reflect.Type {
   251  	return reflect.TypeOf((*map[string]*Snapshot)(nil)).Elem()
   252  }
   253  
   254  func (i SnapshotMap) ToSnapshotMapOutput() SnapshotMapOutput {
   255  	return i.ToSnapshotMapOutputWithContext(context.Background())
   256  }
   257  
   258  func (i SnapshotMap) ToSnapshotMapOutputWithContext(ctx context.Context) SnapshotMapOutput {
   259  	return pulumi.ToOutputWithContext(ctx, i).(SnapshotMapOutput)
   260  }
   261  
   262  type SnapshotOutput struct{ *pulumi.OutputState }
   263  
   264  func (SnapshotOutput) ElementType() reflect.Type {
   265  	return reflect.TypeOf((**Snapshot)(nil)).Elem()
   266  }
   267  
   268  func (o SnapshotOutput) ToSnapshotOutput() SnapshotOutput {
   269  	return o
   270  }
   271  
   272  func (o SnapshotOutput) ToSnapshotOutputWithContext(ctx context.Context) SnapshotOutput {
   273  	return o
   274  }
   275  
   276  // The ARN of the snapshot.
   277  func (o SnapshotOutput) Arn() pulumi.StringOutput {
   278  	return o.ApplyT(func(v *Snapshot) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput)
   279  }
   280  
   281  // The configuration of the cluster from which the snapshot was taken.
   282  func (o SnapshotOutput) ClusterConfigurations() SnapshotClusterConfigurationArrayOutput {
   283  	return o.ApplyT(func(v *Snapshot) SnapshotClusterConfigurationArrayOutput { return v.ClusterConfigurations }).(SnapshotClusterConfigurationArrayOutput)
   284  }
   285  
   286  // Name of the MemoryDB cluster to take a snapshot of.
   287  func (o SnapshotOutput) ClusterName() pulumi.StringOutput {
   288  	return o.ApplyT(func(v *Snapshot) pulumi.StringOutput { return v.ClusterName }).(pulumi.StringOutput)
   289  }
   290  
   291  // ARN of the KMS key used to encrypt the snapshot at rest.
   292  func (o SnapshotOutput) KmsKeyArn() pulumi.StringPtrOutput {
   293  	return o.ApplyT(func(v *Snapshot) pulumi.StringPtrOutput { return v.KmsKeyArn }).(pulumi.StringPtrOutput)
   294  }
   295  
   296  // Name of the snapshot. If omitted, the provider will assign a random, unique name. Conflicts with `namePrefix`.
   297  func (o SnapshotOutput) Name() pulumi.StringOutput {
   298  	return o.ApplyT(func(v *Snapshot) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
   299  }
   300  
   301  // Creates a unique name beginning with the specified prefix. Conflicts with `name`.
   302  func (o SnapshotOutput) NamePrefix() pulumi.StringOutput {
   303  	return o.ApplyT(func(v *Snapshot) pulumi.StringOutput { return v.NamePrefix }).(pulumi.StringOutput)
   304  }
   305  
   306  // Indicates whether the snapshot is from an automatic backup (`automated`) or was created manually (`manual`).
   307  func (o SnapshotOutput) Source() pulumi.StringOutput {
   308  	return o.ApplyT(func(v *Snapshot) pulumi.StringOutput { return v.Source }).(pulumi.StringOutput)
   309  }
   310  
   311  // A map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   312  func (o SnapshotOutput) Tags() pulumi.StringMapOutput {
   313  	return o.ApplyT(func(v *Snapshot) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)
   314  }
   315  
   316  // A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   317  //
   318  // Deprecated: Please use `tags` instead.
   319  func (o SnapshotOutput) TagsAll() pulumi.StringMapOutput {
   320  	return o.ApplyT(func(v *Snapshot) pulumi.StringMapOutput { return v.TagsAll }).(pulumi.StringMapOutput)
   321  }
   322  
   323  type SnapshotArrayOutput struct{ *pulumi.OutputState }
   324  
   325  func (SnapshotArrayOutput) ElementType() reflect.Type {
   326  	return reflect.TypeOf((*[]*Snapshot)(nil)).Elem()
   327  }
   328  
   329  func (o SnapshotArrayOutput) ToSnapshotArrayOutput() SnapshotArrayOutput {
   330  	return o
   331  }
   332  
   333  func (o SnapshotArrayOutput) ToSnapshotArrayOutputWithContext(ctx context.Context) SnapshotArrayOutput {
   334  	return o
   335  }
   336  
   337  func (o SnapshotArrayOutput) Index(i pulumi.IntInput) SnapshotOutput {
   338  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Snapshot {
   339  		return vs[0].([]*Snapshot)[vs[1].(int)]
   340  	}).(SnapshotOutput)
   341  }
   342  
   343  type SnapshotMapOutput struct{ *pulumi.OutputState }
   344  
   345  func (SnapshotMapOutput) ElementType() reflect.Type {
   346  	return reflect.TypeOf((*map[string]*Snapshot)(nil)).Elem()
   347  }
   348  
   349  func (o SnapshotMapOutput) ToSnapshotMapOutput() SnapshotMapOutput {
   350  	return o
   351  }
   352  
   353  func (o SnapshotMapOutput) ToSnapshotMapOutputWithContext(ctx context.Context) SnapshotMapOutput {
   354  	return o
   355  }
   356  
   357  func (o SnapshotMapOutput) MapIndex(k pulumi.StringInput) SnapshotOutput {
   358  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Snapshot {
   359  		return vs[0].(map[string]*Snapshot)[vs[1].(string)]
   360  	}).(SnapshotOutput)
   361  }
   362  
   363  func init() {
   364  	pulumi.RegisterInputType(reflect.TypeOf((*SnapshotInput)(nil)).Elem(), &Snapshot{})
   365  	pulumi.RegisterInputType(reflect.TypeOf((*SnapshotArrayInput)(nil)).Elem(), SnapshotArray{})
   366  	pulumi.RegisterInputType(reflect.TypeOf((*SnapshotMapInput)(nil)).Elem(), SnapshotMap{})
   367  	pulumi.RegisterOutputType(SnapshotOutput{})
   368  	pulumi.RegisterOutputType(SnapshotArrayOutput{})
   369  	pulumi.RegisterOutputType(SnapshotMapOutput{})
   370  }