github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/elasticache/userGroupAssociation.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  // Associate an existing ElastiCache user and an existing user group.
    16  //
    17  // > **NOTE:** The provider will detect changes in the `elasticache.UserGroup` since `elasticache.UserGroupAssociation` changes the user IDs associated with the user group. You can ignore these changes with the `ignoreChanges` option as shown in the example.
    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/elasticache"
    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 := elasticache.NewUser(ctx, "default", &elasticache.UserArgs{
    35  //				UserId:       pulumi.String("defaultUserID"),
    36  //				UserName:     pulumi.String("default"),
    37  //				AccessString: pulumi.String("on ~app::* -@all +@read +@hash +@bitmap +@geo -setbit -bitfield -hset -hsetnx -hmset -hincrby -hincrbyfloat -hdel -bitop -geoadd -georadius -georadiusbymember"),
    38  //				Engine:       pulumi.String("REDIS"),
    39  //				Passwords: pulumi.StringArray{
    40  //					pulumi.String("password123456789"),
    41  //				},
    42  //			})
    43  //			if err != nil {
    44  //				return err
    45  //			}
    46  //			example, err := elasticache.NewUserGroup(ctx, "example", &elasticache.UserGroupArgs{
    47  //				Engine:      pulumi.String("REDIS"),
    48  //				UserGroupId: pulumi.String("userGroupId"),
    49  //				UserIds: pulumi.StringArray{
    50  //					_default.UserId,
    51  //				},
    52  //			})
    53  //			if err != nil {
    54  //				return err
    55  //			}
    56  //			exampleUser, err := elasticache.NewUser(ctx, "example", &elasticache.UserArgs{
    57  //				UserId:       pulumi.String("exampleUserID"),
    58  //				UserName:     pulumi.String("exampleuser"),
    59  //				AccessString: pulumi.String("on ~app::* -@all +@read +@hash +@bitmap +@geo -setbit -bitfield -hset -hsetnx -hmset -hincrby -hincrbyfloat -hdel -bitop -geoadd -georadius -georadiusbymember"),
    60  //				Engine:       pulumi.String("REDIS"),
    61  //				Passwords: pulumi.StringArray{
    62  //					pulumi.String("password123456789"),
    63  //				},
    64  //			})
    65  //			if err != nil {
    66  //				return err
    67  //			}
    68  //			_, err = elasticache.NewUserGroupAssociation(ctx, "example", &elasticache.UserGroupAssociationArgs{
    69  //				UserGroupId: example.UserGroupId,
    70  //				UserId:      exampleUser.UserId,
    71  //			})
    72  //			if err != nil {
    73  //				return err
    74  //			}
    75  //			return nil
    76  //		})
    77  //	}
    78  //
    79  // ```
    80  // <!--End PulumiCodeChooser -->
    81  //
    82  // ## Import
    83  //
    84  // Using `pulumi import`, import ElastiCache user group associations using the `user_group_id` and `user_id`. For example:
    85  //
    86  // ```sh
    87  // $ pulumi import aws:elasticache/userGroupAssociation:UserGroupAssociation example userGoupId1,userId
    88  // ```
    89  type UserGroupAssociation struct {
    90  	pulumi.CustomResourceState
    91  
    92  	// ID of the user group.
    93  	UserGroupId pulumi.StringOutput `pulumi:"userGroupId"`
    94  	// ID of the user to associated with the user group.
    95  	UserId pulumi.StringOutput `pulumi:"userId"`
    96  }
    97  
    98  // NewUserGroupAssociation registers a new resource with the given unique name, arguments, and options.
    99  func NewUserGroupAssociation(ctx *pulumi.Context,
   100  	name string, args *UserGroupAssociationArgs, opts ...pulumi.ResourceOption) (*UserGroupAssociation, error) {
   101  	if args == nil {
   102  		return nil, errors.New("missing one or more required arguments")
   103  	}
   104  
   105  	if args.UserGroupId == nil {
   106  		return nil, errors.New("invalid value for required argument 'UserGroupId'")
   107  	}
   108  	if args.UserId == nil {
   109  		return nil, errors.New("invalid value for required argument 'UserId'")
   110  	}
   111  	opts = internal.PkgResourceDefaultOpts(opts)
   112  	var resource UserGroupAssociation
   113  	err := ctx.RegisterResource("aws:elasticache/userGroupAssociation:UserGroupAssociation", name, args, &resource, opts...)
   114  	if err != nil {
   115  		return nil, err
   116  	}
   117  	return &resource, nil
   118  }
   119  
   120  // GetUserGroupAssociation gets an existing UserGroupAssociation resource's state with the given name, ID, and optional
   121  // state properties that are used to uniquely qualify the lookup (nil if not required).
   122  func GetUserGroupAssociation(ctx *pulumi.Context,
   123  	name string, id pulumi.IDInput, state *UserGroupAssociationState, opts ...pulumi.ResourceOption) (*UserGroupAssociation, error) {
   124  	var resource UserGroupAssociation
   125  	err := ctx.ReadResource("aws:elasticache/userGroupAssociation:UserGroupAssociation", name, id, state, &resource, opts...)
   126  	if err != nil {
   127  		return nil, err
   128  	}
   129  	return &resource, nil
   130  }
   131  
   132  // Input properties used for looking up and filtering UserGroupAssociation resources.
   133  type userGroupAssociationState struct {
   134  	// ID of the user group.
   135  	UserGroupId *string `pulumi:"userGroupId"`
   136  	// ID of the user to associated with the user group.
   137  	UserId *string `pulumi:"userId"`
   138  }
   139  
   140  type UserGroupAssociationState struct {
   141  	// ID of the user group.
   142  	UserGroupId pulumi.StringPtrInput
   143  	// ID of the user to associated with the user group.
   144  	UserId pulumi.StringPtrInput
   145  }
   146  
   147  func (UserGroupAssociationState) ElementType() reflect.Type {
   148  	return reflect.TypeOf((*userGroupAssociationState)(nil)).Elem()
   149  }
   150  
   151  type userGroupAssociationArgs struct {
   152  	// ID of the user group.
   153  	UserGroupId string `pulumi:"userGroupId"`
   154  	// ID of the user to associated with the user group.
   155  	UserId string `pulumi:"userId"`
   156  }
   157  
   158  // The set of arguments for constructing a UserGroupAssociation resource.
   159  type UserGroupAssociationArgs struct {
   160  	// ID of the user group.
   161  	UserGroupId pulumi.StringInput
   162  	// ID of the user to associated with the user group.
   163  	UserId pulumi.StringInput
   164  }
   165  
   166  func (UserGroupAssociationArgs) ElementType() reflect.Type {
   167  	return reflect.TypeOf((*userGroupAssociationArgs)(nil)).Elem()
   168  }
   169  
   170  type UserGroupAssociationInput interface {
   171  	pulumi.Input
   172  
   173  	ToUserGroupAssociationOutput() UserGroupAssociationOutput
   174  	ToUserGroupAssociationOutputWithContext(ctx context.Context) UserGroupAssociationOutput
   175  }
   176  
   177  func (*UserGroupAssociation) ElementType() reflect.Type {
   178  	return reflect.TypeOf((**UserGroupAssociation)(nil)).Elem()
   179  }
   180  
   181  func (i *UserGroupAssociation) ToUserGroupAssociationOutput() UserGroupAssociationOutput {
   182  	return i.ToUserGroupAssociationOutputWithContext(context.Background())
   183  }
   184  
   185  func (i *UserGroupAssociation) ToUserGroupAssociationOutputWithContext(ctx context.Context) UserGroupAssociationOutput {
   186  	return pulumi.ToOutputWithContext(ctx, i).(UserGroupAssociationOutput)
   187  }
   188  
   189  // UserGroupAssociationArrayInput is an input type that accepts UserGroupAssociationArray and UserGroupAssociationArrayOutput values.
   190  // You can construct a concrete instance of `UserGroupAssociationArrayInput` via:
   191  //
   192  //	UserGroupAssociationArray{ UserGroupAssociationArgs{...} }
   193  type UserGroupAssociationArrayInput interface {
   194  	pulumi.Input
   195  
   196  	ToUserGroupAssociationArrayOutput() UserGroupAssociationArrayOutput
   197  	ToUserGroupAssociationArrayOutputWithContext(context.Context) UserGroupAssociationArrayOutput
   198  }
   199  
   200  type UserGroupAssociationArray []UserGroupAssociationInput
   201  
   202  func (UserGroupAssociationArray) ElementType() reflect.Type {
   203  	return reflect.TypeOf((*[]*UserGroupAssociation)(nil)).Elem()
   204  }
   205  
   206  func (i UserGroupAssociationArray) ToUserGroupAssociationArrayOutput() UserGroupAssociationArrayOutput {
   207  	return i.ToUserGroupAssociationArrayOutputWithContext(context.Background())
   208  }
   209  
   210  func (i UserGroupAssociationArray) ToUserGroupAssociationArrayOutputWithContext(ctx context.Context) UserGroupAssociationArrayOutput {
   211  	return pulumi.ToOutputWithContext(ctx, i).(UserGroupAssociationArrayOutput)
   212  }
   213  
   214  // UserGroupAssociationMapInput is an input type that accepts UserGroupAssociationMap and UserGroupAssociationMapOutput values.
   215  // You can construct a concrete instance of `UserGroupAssociationMapInput` via:
   216  //
   217  //	UserGroupAssociationMap{ "key": UserGroupAssociationArgs{...} }
   218  type UserGroupAssociationMapInput interface {
   219  	pulumi.Input
   220  
   221  	ToUserGroupAssociationMapOutput() UserGroupAssociationMapOutput
   222  	ToUserGroupAssociationMapOutputWithContext(context.Context) UserGroupAssociationMapOutput
   223  }
   224  
   225  type UserGroupAssociationMap map[string]UserGroupAssociationInput
   226  
   227  func (UserGroupAssociationMap) ElementType() reflect.Type {
   228  	return reflect.TypeOf((*map[string]*UserGroupAssociation)(nil)).Elem()
   229  }
   230  
   231  func (i UserGroupAssociationMap) ToUserGroupAssociationMapOutput() UserGroupAssociationMapOutput {
   232  	return i.ToUserGroupAssociationMapOutputWithContext(context.Background())
   233  }
   234  
   235  func (i UserGroupAssociationMap) ToUserGroupAssociationMapOutputWithContext(ctx context.Context) UserGroupAssociationMapOutput {
   236  	return pulumi.ToOutputWithContext(ctx, i).(UserGroupAssociationMapOutput)
   237  }
   238  
   239  type UserGroupAssociationOutput struct{ *pulumi.OutputState }
   240  
   241  func (UserGroupAssociationOutput) ElementType() reflect.Type {
   242  	return reflect.TypeOf((**UserGroupAssociation)(nil)).Elem()
   243  }
   244  
   245  func (o UserGroupAssociationOutput) ToUserGroupAssociationOutput() UserGroupAssociationOutput {
   246  	return o
   247  }
   248  
   249  func (o UserGroupAssociationOutput) ToUserGroupAssociationOutputWithContext(ctx context.Context) UserGroupAssociationOutput {
   250  	return o
   251  }
   252  
   253  // ID of the user group.
   254  func (o UserGroupAssociationOutput) UserGroupId() pulumi.StringOutput {
   255  	return o.ApplyT(func(v *UserGroupAssociation) pulumi.StringOutput { return v.UserGroupId }).(pulumi.StringOutput)
   256  }
   257  
   258  // ID of the user to associated with the user group.
   259  func (o UserGroupAssociationOutput) UserId() pulumi.StringOutput {
   260  	return o.ApplyT(func(v *UserGroupAssociation) pulumi.StringOutput { return v.UserId }).(pulumi.StringOutput)
   261  }
   262  
   263  type UserGroupAssociationArrayOutput struct{ *pulumi.OutputState }
   264  
   265  func (UserGroupAssociationArrayOutput) ElementType() reflect.Type {
   266  	return reflect.TypeOf((*[]*UserGroupAssociation)(nil)).Elem()
   267  }
   268  
   269  func (o UserGroupAssociationArrayOutput) ToUserGroupAssociationArrayOutput() UserGroupAssociationArrayOutput {
   270  	return o
   271  }
   272  
   273  func (o UserGroupAssociationArrayOutput) ToUserGroupAssociationArrayOutputWithContext(ctx context.Context) UserGroupAssociationArrayOutput {
   274  	return o
   275  }
   276  
   277  func (o UserGroupAssociationArrayOutput) Index(i pulumi.IntInput) UserGroupAssociationOutput {
   278  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *UserGroupAssociation {
   279  		return vs[0].([]*UserGroupAssociation)[vs[1].(int)]
   280  	}).(UserGroupAssociationOutput)
   281  }
   282  
   283  type UserGroupAssociationMapOutput struct{ *pulumi.OutputState }
   284  
   285  func (UserGroupAssociationMapOutput) ElementType() reflect.Type {
   286  	return reflect.TypeOf((*map[string]*UserGroupAssociation)(nil)).Elem()
   287  }
   288  
   289  func (o UserGroupAssociationMapOutput) ToUserGroupAssociationMapOutput() UserGroupAssociationMapOutput {
   290  	return o
   291  }
   292  
   293  func (o UserGroupAssociationMapOutput) ToUserGroupAssociationMapOutputWithContext(ctx context.Context) UserGroupAssociationMapOutput {
   294  	return o
   295  }
   296  
   297  func (o UserGroupAssociationMapOutput) MapIndex(k pulumi.StringInput) UserGroupAssociationOutput {
   298  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *UserGroupAssociation {
   299  		return vs[0].(map[string]*UserGroupAssociation)[vs[1].(string)]
   300  	}).(UserGroupAssociationOutput)
   301  }
   302  
   303  func init() {
   304  	pulumi.RegisterInputType(reflect.TypeOf((*UserGroupAssociationInput)(nil)).Elem(), &UserGroupAssociation{})
   305  	pulumi.RegisterInputType(reflect.TypeOf((*UserGroupAssociationArrayInput)(nil)).Elem(), UserGroupAssociationArray{})
   306  	pulumi.RegisterInputType(reflect.TypeOf((*UserGroupAssociationMapInput)(nil)).Elem(), UserGroupAssociationMap{})
   307  	pulumi.RegisterOutputType(UserGroupAssociationOutput{})
   308  	pulumi.RegisterOutputType(UserGroupAssociationArrayOutput{})
   309  	pulumi.RegisterOutputType(UserGroupAssociationMapOutput{})
   310  }