github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/elasticache/user.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 elasticache
     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 an ElastiCache user resource.
    16  //
    17  // > **Note:** All arguments including the username and passwords will be stored in the raw state as plain-text.
    18  // ## Example Usage
    19  //
    20  // <!--Start PulumiCodeChooser -->
    21  // ```go
    22  // package main
    23  //
    24  // import (
    25  //
    26  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/elasticache"
    27  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    28  //
    29  // )
    30  //
    31  //	func main() {
    32  //		pulumi.Run(func(ctx *pulumi.Context) error {
    33  //			_, err := elasticache.NewUser(ctx, "test", &elasticache.UserArgs{
    34  //				UserId:       pulumi.String("testUserId"),
    35  //				UserName:     pulumi.String("testUserName"),
    36  //				AccessString: pulumi.String("on ~app::* -@all +@read +@hash +@bitmap +@geo -setbit -bitfield -hset -hsetnx -hmset -hincrby -hincrbyfloat -hdel -bitop -geoadd -georadius -georadiusbymember"),
    37  //				Engine:       pulumi.String("REDIS"),
    38  //				Passwords: pulumi.StringArray{
    39  //					pulumi.String("password123456789"),
    40  //				},
    41  //			})
    42  //			if err != nil {
    43  //				return err
    44  //			}
    45  //			return nil
    46  //		})
    47  //	}
    48  //
    49  // ```
    50  // <!--End PulumiCodeChooser -->
    51  //
    52  // <!--Start PulumiCodeChooser -->
    53  // ```go
    54  // package main
    55  //
    56  // import (
    57  //
    58  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/elasticache"
    59  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    60  //
    61  // )
    62  //
    63  //	func main() {
    64  //		pulumi.Run(func(ctx *pulumi.Context) error {
    65  //			_, err := elasticache.NewUser(ctx, "test", &elasticache.UserArgs{
    66  //				UserId:       pulumi.String("testUserId"),
    67  //				UserName:     pulumi.String("testUserName"),
    68  //				AccessString: pulumi.String("on ~* +@all"),
    69  //				Engine:       pulumi.String("REDIS"),
    70  //				AuthenticationMode: &elasticache.UserAuthenticationModeArgs{
    71  //					Type: pulumi.String("iam"),
    72  //				},
    73  //			})
    74  //			if err != nil {
    75  //				return err
    76  //			}
    77  //			return nil
    78  //		})
    79  //	}
    80  //
    81  // ```
    82  // <!--End PulumiCodeChooser -->
    83  //
    84  // <!--Start PulumiCodeChooser -->
    85  // ```go
    86  // package main
    87  //
    88  // import (
    89  //
    90  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/elasticache"
    91  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    92  //
    93  // )
    94  //
    95  //	func main() {
    96  //		pulumi.Run(func(ctx *pulumi.Context) error {
    97  //			_, err := elasticache.NewUser(ctx, "test", &elasticache.UserArgs{
    98  //				UserId:       pulumi.String("testUserId"),
    99  //				UserName:     pulumi.String("testUserName"),
   100  //				AccessString: pulumi.String("on ~* +@all"),
   101  //				Engine:       pulumi.String("REDIS"),
   102  //				AuthenticationMode: &elasticache.UserAuthenticationModeArgs{
   103  //					Type: pulumi.String("password"),
   104  //					Passwords: pulumi.StringArray{
   105  //						pulumi.String("password1"),
   106  //						pulumi.String("password2"),
   107  //					},
   108  //				},
   109  //			})
   110  //			if err != nil {
   111  //				return err
   112  //			}
   113  //			return nil
   114  //		})
   115  //	}
   116  //
   117  // ```
   118  // <!--End PulumiCodeChooser -->
   119  //
   120  // ## Import
   121  //
   122  // Using `pulumi import`, import ElastiCache users using the `user_id`. For example:
   123  //
   124  // ```sh
   125  // $ pulumi import aws:elasticache/user:User my_user userId1
   126  // ```
   127  type User struct {
   128  	pulumi.CustomResourceState
   129  
   130  	// Access permissions string used for this user. See [Specifying Permissions Using an Access String](https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/Clusters.RBAC.html#Access-string) for more details.
   131  	AccessString pulumi.StringOutput `pulumi:"accessString"`
   132  	// The ARN of the created ElastiCache User.
   133  	Arn pulumi.StringOutput `pulumi:"arn"`
   134  	// Denotes the user's authentication properties. Detailed below.
   135  	AuthenticationMode UserAuthenticationModeOutput `pulumi:"authenticationMode"`
   136  	// The current supported value is `REDIS`.
   137  	Engine pulumi.StringOutput `pulumi:"engine"`
   138  	// Indicates a password is not required for this user.
   139  	NoPasswordRequired pulumi.BoolPtrOutput `pulumi:"noPasswordRequired"`
   140  	// Passwords used for this user. You can create up to two passwords for each user.
   141  	Passwords pulumi.StringArrayOutput `pulumi:"passwords"`
   142  	// A list of tags to be added to this resource. A tag is a key-value pair.
   143  	Tags pulumi.StringMapOutput `pulumi:"tags"`
   144  	// Deprecated: Please use `tags` instead.
   145  	TagsAll pulumi.StringMapOutput `pulumi:"tagsAll"`
   146  	// The ID of the user.
   147  	UserId pulumi.StringOutput `pulumi:"userId"`
   148  	// The username of the user.
   149  	//
   150  	// The following arguments are optional:
   151  	UserName pulumi.StringOutput `pulumi:"userName"`
   152  }
   153  
   154  // NewUser registers a new resource with the given unique name, arguments, and options.
   155  func NewUser(ctx *pulumi.Context,
   156  	name string, args *UserArgs, opts ...pulumi.ResourceOption) (*User, error) {
   157  	if args == nil {
   158  		return nil, errors.New("missing one or more required arguments")
   159  	}
   160  
   161  	if args.AccessString == nil {
   162  		return nil, errors.New("invalid value for required argument 'AccessString'")
   163  	}
   164  	if args.Engine == nil {
   165  		return nil, errors.New("invalid value for required argument 'Engine'")
   166  	}
   167  	if args.UserId == nil {
   168  		return nil, errors.New("invalid value for required argument 'UserId'")
   169  	}
   170  	if args.UserName == nil {
   171  		return nil, errors.New("invalid value for required argument 'UserName'")
   172  	}
   173  	if args.Passwords != nil {
   174  		args.Passwords = pulumi.ToSecret(args.Passwords).(pulumi.StringArrayInput)
   175  	}
   176  	secrets := pulumi.AdditionalSecretOutputs([]string{
   177  		"passwords",
   178  	})
   179  	opts = append(opts, secrets)
   180  	opts = internal.PkgResourceDefaultOpts(opts)
   181  	var resource User
   182  	err := ctx.RegisterResource("aws:elasticache/user:User", name, args, &resource, opts...)
   183  	if err != nil {
   184  		return nil, err
   185  	}
   186  	return &resource, nil
   187  }
   188  
   189  // GetUser gets an existing User resource's state with the given name, ID, and optional
   190  // state properties that are used to uniquely qualify the lookup (nil if not required).
   191  func GetUser(ctx *pulumi.Context,
   192  	name string, id pulumi.IDInput, state *UserState, opts ...pulumi.ResourceOption) (*User, error) {
   193  	var resource User
   194  	err := ctx.ReadResource("aws:elasticache/user:User", name, id, state, &resource, opts...)
   195  	if err != nil {
   196  		return nil, err
   197  	}
   198  	return &resource, nil
   199  }
   200  
   201  // Input properties used for looking up and filtering User resources.
   202  type userState struct {
   203  	// Access permissions string used for this user. See [Specifying Permissions Using an Access String](https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/Clusters.RBAC.html#Access-string) for more details.
   204  	AccessString *string `pulumi:"accessString"`
   205  	// The ARN of the created ElastiCache User.
   206  	Arn *string `pulumi:"arn"`
   207  	// Denotes the user's authentication properties. Detailed below.
   208  	AuthenticationMode *UserAuthenticationMode `pulumi:"authenticationMode"`
   209  	// The current supported value is `REDIS`.
   210  	Engine *string `pulumi:"engine"`
   211  	// Indicates a password is not required for this user.
   212  	NoPasswordRequired *bool `pulumi:"noPasswordRequired"`
   213  	// Passwords used for this user. You can create up to two passwords for each user.
   214  	Passwords []string `pulumi:"passwords"`
   215  	// A list of tags to be added to this resource. A tag is a key-value pair.
   216  	Tags map[string]string `pulumi:"tags"`
   217  	// Deprecated: Please use `tags` instead.
   218  	TagsAll map[string]string `pulumi:"tagsAll"`
   219  	// The ID of the user.
   220  	UserId *string `pulumi:"userId"`
   221  	// The username of the user.
   222  	//
   223  	// The following arguments are optional:
   224  	UserName *string `pulumi:"userName"`
   225  }
   226  
   227  type UserState struct {
   228  	// Access permissions string used for this user. See [Specifying Permissions Using an Access String](https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/Clusters.RBAC.html#Access-string) for more details.
   229  	AccessString pulumi.StringPtrInput
   230  	// The ARN of the created ElastiCache User.
   231  	Arn pulumi.StringPtrInput
   232  	// Denotes the user's authentication properties. Detailed below.
   233  	AuthenticationMode UserAuthenticationModePtrInput
   234  	// The current supported value is `REDIS`.
   235  	Engine pulumi.StringPtrInput
   236  	// Indicates a password is not required for this user.
   237  	NoPasswordRequired pulumi.BoolPtrInput
   238  	// Passwords used for this user. You can create up to two passwords for each user.
   239  	Passwords pulumi.StringArrayInput
   240  	// A list of tags to be added to this resource. A tag is a key-value pair.
   241  	Tags pulumi.StringMapInput
   242  	// Deprecated: Please use `tags` instead.
   243  	TagsAll pulumi.StringMapInput
   244  	// The ID of the user.
   245  	UserId pulumi.StringPtrInput
   246  	// The username of the user.
   247  	//
   248  	// The following arguments are optional:
   249  	UserName pulumi.StringPtrInput
   250  }
   251  
   252  func (UserState) ElementType() reflect.Type {
   253  	return reflect.TypeOf((*userState)(nil)).Elem()
   254  }
   255  
   256  type userArgs struct {
   257  	// Access permissions string used for this user. See [Specifying Permissions Using an Access String](https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/Clusters.RBAC.html#Access-string) for more details.
   258  	AccessString string `pulumi:"accessString"`
   259  	// Denotes the user's authentication properties. Detailed below.
   260  	AuthenticationMode *UserAuthenticationMode `pulumi:"authenticationMode"`
   261  	// The current supported value is `REDIS`.
   262  	Engine string `pulumi:"engine"`
   263  	// Indicates a password is not required for this user.
   264  	NoPasswordRequired *bool `pulumi:"noPasswordRequired"`
   265  	// Passwords used for this user. You can create up to two passwords for each user.
   266  	Passwords []string `pulumi:"passwords"`
   267  	// A list of tags to be added to this resource. A tag is a key-value pair.
   268  	Tags map[string]string `pulumi:"tags"`
   269  	// The ID of the user.
   270  	UserId string `pulumi:"userId"`
   271  	// The username of the user.
   272  	//
   273  	// The following arguments are optional:
   274  	UserName string `pulumi:"userName"`
   275  }
   276  
   277  // The set of arguments for constructing a User resource.
   278  type UserArgs struct {
   279  	// Access permissions string used for this user. See [Specifying Permissions Using an Access String](https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/Clusters.RBAC.html#Access-string) for more details.
   280  	AccessString pulumi.StringInput
   281  	// Denotes the user's authentication properties. Detailed below.
   282  	AuthenticationMode UserAuthenticationModePtrInput
   283  	// The current supported value is `REDIS`.
   284  	Engine pulumi.StringInput
   285  	// Indicates a password is not required for this user.
   286  	NoPasswordRequired pulumi.BoolPtrInput
   287  	// Passwords used for this user. You can create up to two passwords for each user.
   288  	Passwords pulumi.StringArrayInput
   289  	// A list of tags to be added to this resource. A tag is a key-value pair.
   290  	Tags pulumi.StringMapInput
   291  	// The ID of the user.
   292  	UserId pulumi.StringInput
   293  	// The username of the user.
   294  	//
   295  	// The following arguments are optional:
   296  	UserName pulumi.StringInput
   297  }
   298  
   299  func (UserArgs) ElementType() reflect.Type {
   300  	return reflect.TypeOf((*userArgs)(nil)).Elem()
   301  }
   302  
   303  type UserInput interface {
   304  	pulumi.Input
   305  
   306  	ToUserOutput() UserOutput
   307  	ToUserOutputWithContext(ctx context.Context) UserOutput
   308  }
   309  
   310  func (*User) ElementType() reflect.Type {
   311  	return reflect.TypeOf((**User)(nil)).Elem()
   312  }
   313  
   314  func (i *User) ToUserOutput() UserOutput {
   315  	return i.ToUserOutputWithContext(context.Background())
   316  }
   317  
   318  func (i *User) ToUserOutputWithContext(ctx context.Context) UserOutput {
   319  	return pulumi.ToOutputWithContext(ctx, i).(UserOutput)
   320  }
   321  
   322  // UserArrayInput is an input type that accepts UserArray and UserArrayOutput values.
   323  // You can construct a concrete instance of `UserArrayInput` via:
   324  //
   325  //	UserArray{ UserArgs{...} }
   326  type UserArrayInput interface {
   327  	pulumi.Input
   328  
   329  	ToUserArrayOutput() UserArrayOutput
   330  	ToUserArrayOutputWithContext(context.Context) UserArrayOutput
   331  }
   332  
   333  type UserArray []UserInput
   334  
   335  func (UserArray) ElementType() reflect.Type {
   336  	return reflect.TypeOf((*[]*User)(nil)).Elem()
   337  }
   338  
   339  func (i UserArray) ToUserArrayOutput() UserArrayOutput {
   340  	return i.ToUserArrayOutputWithContext(context.Background())
   341  }
   342  
   343  func (i UserArray) ToUserArrayOutputWithContext(ctx context.Context) UserArrayOutput {
   344  	return pulumi.ToOutputWithContext(ctx, i).(UserArrayOutput)
   345  }
   346  
   347  // UserMapInput is an input type that accepts UserMap and UserMapOutput values.
   348  // You can construct a concrete instance of `UserMapInput` via:
   349  //
   350  //	UserMap{ "key": UserArgs{...} }
   351  type UserMapInput interface {
   352  	pulumi.Input
   353  
   354  	ToUserMapOutput() UserMapOutput
   355  	ToUserMapOutputWithContext(context.Context) UserMapOutput
   356  }
   357  
   358  type UserMap map[string]UserInput
   359  
   360  func (UserMap) ElementType() reflect.Type {
   361  	return reflect.TypeOf((*map[string]*User)(nil)).Elem()
   362  }
   363  
   364  func (i UserMap) ToUserMapOutput() UserMapOutput {
   365  	return i.ToUserMapOutputWithContext(context.Background())
   366  }
   367  
   368  func (i UserMap) ToUserMapOutputWithContext(ctx context.Context) UserMapOutput {
   369  	return pulumi.ToOutputWithContext(ctx, i).(UserMapOutput)
   370  }
   371  
   372  type UserOutput struct{ *pulumi.OutputState }
   373  
   374  func (UserOutput) ElementType() reflect.Type {
   375  	return reflect.TypeOf((**User)(nil)).Elem()
   376  }
   377  
   378  func (o UserOutput) ToUserOutput() UserOutput {
   379  	return o
   380  }
   381  
   382  func (o UserOutput) ToUserOutputWithContext(ctx context.Context) UserOutput {
   383  	return o
   384  }
   385  
   386  // Access permissions string used for this user. See [Specifying Permissions Using an Access String](https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/Clusters.RBAC.html#Access-string) for more details.
   387  func (o UserOutput) AccessString() pulumi.StringOutput {
   388  	return o.ApplyT(func(v *User) pulumi.StringOutput { return v.AccessString }).(pulumi.StringOutput)
   389  }
   390  
   391  // The ARN of the created ElastiCache User.
   392  func (o UserOutput) Arn() pulumi.StringOutput {
   393  	return o.ApplyT(func(v *User) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput)
   394  }
   395  
   396  // Denotes the user's authentication properties. Detailed below.
   397  func (o UserOutput) AuthenticationMode() UserAuthenticationModeOutput {
   398  	return o.ApplyT(func(v *User) UserAuthenticationModeOutput { return v.AuthenticationMode }).(UserAuthenticationModeOutput)
   399  }
   400  
   401  // The current supported value is `REDIS`.
   402  func (o UserOutput) Engine() pulumi.StringOutput {
   403  	return o.ApplyT(func(v *User) pulumi.StringOutput { return v.Engine }).(pulumi.StringOutput)
   404  }
   405  
   406  // Indicates a password is not required for this user.
   407  func (o UserOutput) NoPasswordRequired() pulumi.BoolPtrOutput {
   408  	return o.ApplyT(func(v *User) pulumi.BoolPtrOutput { return v.NoPasswordRequired }).(pulumi.BoolPtrOutput)
   409  }
   410  
   411  // Passwords used for this user. You can create up to two passwords for each user.
   412  func (o UserOutput) Passwords() pulumi.StringArrayOutput {
   413  	return o.ApplyT(func(v *User) pulumi.StringArrayOutput { return v.Passwords }).(pulumi.StringArrayOutput)
   414  }
   415  
   416  // A list of tags to be added to this resource. A tag is a key-value pair.
   417  func (o UserOutput) Tags() pulumi.StringMapOutput {
   418  	return o.ApplyT(func(v *User) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)
   419  }
   420  
   421  // Deprecated: Please use `tags` instead.
   422  func (o UserOutput) TagsAll() pulumi.StringMapOutput {
   423  	return o.ApplyT(func(v *User) pulumi.StringMapOutput { return v.TagsAll }).(pulumi.StringMapOutput)
   424  }
   425  
   426  // The ID of the user.
   427  func (o UserOutput) UserId() pulumi.StringOutput {
   428  	return o.ApplyT(func(v *User) pulumi.StringOutput { return v.UserId }).(pulumi.StringOutput)
   429  }
   430  
   431  // The username of the user.
   432  //
   433  // The following arguments are optional:
   434  func (o UserOutput) UserName() pulumi.StringOutput {
   435  	return o.ApplyT(func(v *User) pulumi.StringOutput { return v.UserName }).(pulumi.StringOutput)
   436  }
   437  
   438  type UserArrayOutput struct{ *pulumi.OutputState }
   439  
   440  func (UserArrayOutput) ElementType() reflect.Type {
   441  	return reflect.TypeOf((*[]*User)(nil)).Elem()
   442  }
   443  
   444  func (o UserArrayOutput) ToUserArrayOutput() UserArrayOutput {
   445  	return o
   446  }
   447  
   448  func (o UserArrayOutput) ToUserArrayOutputWithContext(ctx context.Context) UserArrayOutput {
   449  	return o
   450  }
   451  
   452  func (o UserArrayOutput) Index(i pulumi.IntInput) UserOutput {
   453  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *User {
   454  		return vs[0].([]*User)[vs[1].(int)]
   455  	}).(UserOutput)
   456  }
   457  
   458  type UserMapOutput struct{ *pulumi.OutputState }
   459  
   460  func (UserMapOutput) ElementType() reflect.Type {
   461  	return reflect.TypeOf((*map[string]*User)(nil)).Elem()
   462  }
   463  
   464  func (o UserMapOutput) ToUserMapOutput() UserMapOutput {
   465  	return o
   466  }
   467  
   468  func (o UserMapOutput) ToUserMapOutputWithContext(ctx context.Context) UserMapOutput {
   469  	return o
   470  }
   471  
   472  func (o UserMapOutput) MapIndex(k pulumi.StringInput) UserOutput {
   473  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *User {
   474  		return vs[0].(map[string]*User)[vs[1].(string)]
   475  	}).(UserOutput)
   476  }
   477  
   478  func init() {
   479  	pulumi.RegisterInputType(reflect.TypeOf((*UserInput)(nil)).Elem(), &User{})
   480  	pulumi.RegisterInputType(reflect.TypeOf((*UserArrayInput)(nil)).Elem(), UserArray{})
   481  	pulumi.RegisterInputType(reflect.TypeOf((*UserMapInput)(nil)).Elem(), UserMap{})
   482  	pulumi.RegisterOutputType(UserOutput{})
   483  	pulumi.RegisterOutputType(UserArrayOutput{})
   484  	pulumi.RegisterOutputType(UserMapOutput{})
   485  }