github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/cognito/userInGroup.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 cognito
     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  // Adds the specified user to the specified group.
    16  //
    17  // ## Example Usage
    18  //
    19  // <!--Start PulumiCodeChooser -->
    20  // ```go
    21  // package main
    22  //
    23  // import (
    24  //
    25  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cognito"
    26  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    27  //
    28  // )
    29  //
    30  //	func main() {
    31  //		pulumi.Run(func(ctx *pulumi.Context) error {
    32  //			example, err := cognito.NewUserPool(ctx, "example", &cognito.UserPoolArgs{
    33  //				Name: pulumi.String("example"),
    34  //				PasswordPolicy: &cognito.UserPoolPasswordPolicyArgs{
    35  //					TemporaryPasswordValidityDays: pulumi.Int(7),
    36  //					MinimumLength:                 pulumi.Int(6),
    37  //					RequireUppercase:              pulumi.Bool(false),
    38  //					RequireSymbols:                pulumi.Bool(false),
    39  //					RequireNumbers:                pulumi.Bool(false),
    40  //				},
    41  //			})
    42  //			if err != nil {
    43  //				return err
    44  //			}
    45  //			exampleUser, err := cognito.NewUser(ctx, "example", &cognito.UserArgs{
    46  //				UserPoolId: example.ID(),
    47  //				Username:   pulumi.String("example"),
    48  //			})
    49  //			if err != nil {
    50  //				return err
    51  //			}
    52  //			exampleUserGroup, err := cognito.NewUserGroup(ctx, "example", &cognito.UserGroupArgs{
    53  //				UserPoolId: example.ID(),
    54  //				Name:       pulumi.String("example"),
    55  //			})
    56  //			if err != nil {
    57  //				return err
    58  //			}
    59  //			_, err = cognito.NewUserInGroup(ctx, "example", &cognito.UserInGroupArgs{
    60  //				UserPoolId: example.ID(),
    61  //				GroupName:  exampleUserGroup.Name,
    62  //				Username:   exampleUser.Username,
    63  //			})
    64  //			if err != nil {
    65  //				return err
    66  //			}
    67  //			return nil
    68  //		})
    69  //	}
    70  //
    71  // ```
    72  // <!--End PulumiCodeChooser -->
    73  type UserInGroup struct {
    74  	pulumi.CustomResourceState
    75  
    76  	// The name of the group to which the user is to be added.
    77  	GroupName pulumi.StringOutput `pulumi:"groupName"`
    78  	// The user pool ID of the user and group.
    79  	UserPoolId pulumi.StringOutput `pulumi:"userPoolId"`
    80  	// The username of the user to be added to the group.
    81  	Username pulumi.StringOutput `pulumi:"username"`
    82  }
    83  
    84  // NewUserInGroup registers a new resource with the given unique name, arguments, and options.
    85  func NewUserInGroup(ctx *pulumi.Context,
    86  	name string, args *UserInGroupArgs, opts ...pulumi.ResourceOption) (*UserInGroup, error) {
    87  	if args == nil {
    88  		return nil, errors.New("missing one or more required arguments")
    89  	}
    90  
    91  	if args.GroupName == nil {
    92  		return nil, errors.New("invalid value for required argument 'GroupName'")
    93  	}
    94  	if args.UserPoolId == nil {
    95  		return nil, errors.New("invalid value for required argument 'UserPoolId'")
    96  	}
    97  	if args.Username == nil {
    98  		return nil, errors.New("invalid value for required argument 'Username'")
    99  	}
   100  	opts = internal.PkgResourceDefaultOpts(opts)
   101  	var resource UserInGroup
   102  	err := ctx.RegisterResource("aws:cognito/userInGroup:UserInGroup", name, args, &resource, opts...)
   103  	if err != nil {
   104  		return nil, err
   105  	}
   106  	return &resource, nil
   107  }
   108  
   109  // GetUserInGroup gets an existing UserInGroup resource's state with the given name, ID, and optional
   110  // state properties that are used to uniquely qualify the lookup (nil if not required).
   111  func GetUserInGroup(ctx *pulumi.Context,
   112  	name string, id pulumi.IDInput, state *UserInGroupState, opts ...pulumi.ResourceOption) (*UserInGroup, error) {
   113  	var resource UserInGroup
   114  	err := ctx.ReadResource("aws:cognito/userInGroup:UserInGroup", name, id, state, &resource, opts...)
   115  	if err != nil {
   116  		return nil, err
   117  	}
   118  	return &resource, nil
   119  }
   120  
   121  // Input properties used for looking up and filtering UserInGroup resources.
   122  type userInGroupState struct {
   123  	// The name of the group to which the user is to be added.
   124  	GroupName *string `pulumi:"groupName"`
   125  	// The user pool ID of the user and group.
   126  	UserPoolId *string `pulumi:"userPoolId"`
   127  	// The username of the user to be added to the group.
   128  	Username *string `pulumi:"username"`
   129  }
   130  
   131  type UserInGroupState struct {
   132  	// The name of the group to which the user is to be added.
   133  	GroupName pulumi.StringPtrInput
   134  	// The user pool ID of the user and group.
   135  	UserPoolId pulumi.StringPtrInput
   136  	// The username of the user to be added to the group.
   137  	Username pulumi.StringPtrInput
   138  }
   139  
   140  func (UserInGroupState) ElementType() reflect.Type {
   141  	return reflect.TypeOf((*userInGroupState)(nil)).Elem()
   142  }
   143  
   144  type userInGroupArgs struct {
   145  	// The name of the group to which the user is to be added.
   146  	GroupName string `pulumi:"groupName"`
   147  	// The user pool ID of the user and group.
   148  	UserPoolId string `pulumi:"userPoolId"`
   149  	// The username of the user to be added to the group.
   150  	Username string `pulumi:"username"`
   151  }
   152  
   153  // The set of arguments for constructing a UserInGroup resource.
   154  type UserInGroupArgs struct {
   155  	// The name of the group to which the user is to be added.
   156  	GroupName pulumi.StringInput
   157  	// The user pool ID of the user and group.
   158  	UserPoolId pulumi.StringInput
   159  	// The username of the user to be added to the group.
   160  	Username pulumi.StringInput
   161  }
   162  
   163  func (UserInGroupArgs) ElementType() reflect.Type {
   164  	return reflect.TypeOf((*userInGroupArgs)(nil)).Elem()
   165  }
   166  
   167  type UserInGroupInput interface {
   168  	pulumi.Input
   169  
   170  	ToUserInGroupOutput() UserInGroupOutput
   171  	ToUserInGroupOutputWithContext(ctx context.Context) UserInGroupOutput
   172  }
   173  
   174  func (*UserInGroup) ElementType() reflect.Type {
   175  	return reflect.TypeOf((**UserInGroup)(nil)).Elem()
   176  }
   177  
   178  func (i *UserInGroup) ToUserInGroupOutput() UserInGroupOutput {
   179  	return i.ToUserInGroupOutputWithContext(context.Background())
   180  }
   181  
   182  func (i *UserInGroup) ToUserInGroupOutputWithContext(ctx context.Context) UserInGroupOutput {
   183  	return pulumi.ToOutputWithContext(ctx, i).(UserInGroupOutput)
   184  }
   185  
   186  // UserInGroupArrayInput is an input type that accepts UserInGroupArray and UserInGroupArrayOutput values.
   187  // You can construct a concrete instance of `UserInGroupArrayInput` via:
   188  //
   189  //	UserInGroupArray{ UserInGroupArgs{...} }
   190  type UserInGroupArrayInput interface {
   191  	pulumi.Input
   192  
   193  	ToUserInGroupArrayOutput() UserInGroupArrayOutput
   194  	ToUserInGroupArrayOutputWithContext(context.Context) UserInGroupArrayOutput
   195  }
   196  
   197  type UserInGroupArray []UserInGroupInput
   198  
   199  func (UserInGroupArray) ElementType() reflect.Type {
   200  	return reflect.TypeOf((*[]*UserInGroup)(nil)).Elem()
   201  }
   202  
   203  func (i UserInGroupArray) ToUserInGroupArrayOutput() UserInGroupArrayOutput {
   204  	return i.ToUserInGroupArrayOutputWithContext(context.Background())
   205  }
   206  
   207  func (i UserInGroupArray) ToUserInGroupArrayOutputWithContext(ctx context.Context) UserInGroupArrayOutput {
   208  	return pulumi.ToOutputWithContext(ctx, i).(UserInGroupArrayOutput)
   209  }
   210  
   211  // UserInGroupMapInput is an input type that accepts UserInGroupMap and UserInGroupMapOutput values.
   212  // You can construct a concrete instance of `UserInGroupMapInput` via:
   213  //
   214  //	UserInGroupMap{ "key": UserInGroupArgs{...} }
   215  type UserInGroupMapInput interface {
   216  	pulumi.Input
   217  
   218  	ToUserInGroupMapOutput() UserInGroupMapOutput
   219  	ToUserInGroupMapOutputWithContext(context.Context) UserInGroupMapOutput
   220  }
   221  
   222  type UserInGroupMap map[string]UserInGroupInput
   223  
   224  func (UserInGroupMap) ElementType() reflect.Type {
   225  	return reflect.TypeOf((*map[string]*UserInGroup)(nil)).Elem()
   226  }
   227  
   228  func (i UserInGroupMap) ToUserInGroupMapOutput() UserInGroupMapOutput {
   229  	return i.ToUserInGroupMapOutputWithContext(context.Background())
   230  }
   231  
   232  func (i UserInGroupMap) ToUserInGroupMapOutputWithContext(ctx context.Context) UserInGroupMapOutput {
   233  	return pulumi.ToOutputWithContext(ctx, i).(UserInGroupMapOutput)
   234  }
   235  
   236  type UserInGroupOutput struct{ *pulumi.OutputState }
   237  
   238  func (UserInGroupOutput) ElementType() reflect.Type {
   239  	return reflect.TypeOf((**UserInGroup)(nil)).Elem()
   240  }
   241  
   242  func (o UserInGroupOutput) ToUserInGroupOutput() UserInGroupOutput {
   243  	return o
   244  }
   245  
   246  func (o UserInGroupOutput) ToUserInGroupOutputWithContext(ctx context.Context) UserInGroupOutput {
   247  	return o
   248  }
   249  
   250  // The name of the group to which the user is to be added.
   251  func (o UserInGroupOutput) GroupName() pulumi.StringOutput {
   252  	return o.ApplyT(func(v *UserInGroup) pulumi.StringOutput { return v.GroupName }).(pulumi.StringOutput)
   253  }
   254  
   255  // The user pool ID of the user and group.
   256  func (o UserInGroupOutput) UserPoolId() pulumi.StringOutput {
   257  	return o.ApplyT(func(v *UserInGroup) pulumi.StringOutput { return v.UserPoolId }).(pulumi.StringOutput)
   258  }
   259  
   260  // The username of the user to be added to the group.
   261  func (o UserInGroupOutput) Username() pulumi.StringOutput {
   262  	return o.ApplyT(func(v *UserInGroup) pulumi.StringOutput { return v.Username }).(pulumi.StringOutput)
   263  }
   264  
   265  type UserInGroupArrayOutput struct{ *pulumi.OutputState }
   266  
   267  func (UserInGroupArrayOutput) ElementType() reflect.Type {
   268  	return reflect.TypeOf((*[]*UserInGroup)(nil)).Elem()
   269  }
   270  
   271  func (o UserInGroupArrayOutput) ToUserInGroupArrayOutput() UserInGroupArrayOutput {
   272  	return o
   273  }
   274  
   275  func (o UserInGroupArrayOutput) ToUserInGroupArrayOutputWithContext(ctx context.Context) UserInGroupArrayOutput {
   276  	return o
   277  }
   278  
   279  func (o UserInGroupArrayOutput) Index(i pulumi.IntInput) UserInGroupOutput {
   280  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *UserInGroup {
   281  		return vs[0].([]*UserInGroup)[vs[1].(int)]
   282  	}).(UserInGroupOutput)
   283  }
   284  
   285  type UserInGroupMapOutput struct{ *pulumi.OutputState }
   286  
   287  func (UserInGroupMapOutput) ElementType() reflect.Type {
   288  	return reflect.TypeOf((*map[string]*UserInGroup)(nil)).Elem()
   289  }
   290  
   291  func (o UserInGroupMapOutput) ToUserInGroupMapOutput() UserInGroupMapOutput {
   292  	return o
   293  }
   294  
   295  func (o UserInGroupMapOutput) ToUserInGroupMapOutputWithContext(ctx context.Context) UserInGroupMapOutput {
   296  	return o
   297  }
   298  
   299  func (o UserInGroupMapOutput) MapIndex(k pulumi.StringInput) UserInGroupOutput {
   300  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *UserInGroup {
   301  		return vs[0].(map[string]*UserInGroup)[vs[1].(string)]
   302  	}).(UserInGroupOutput)
   303  }
   304  
   305  func init() {
   306  	pulumi.RegisterInputType(reflect.TypeOf((*UserInGroupInput)(nil)).Elem(), &UserInGroup{})
   307  	pulumi.RegisterInputType(reflect.TypeOf((*UserInGroupArrayInput)(nil)).Elem(), UserInGroupArray{})
   308  	pulumi.RegisterInputType(reflect.TypeOf((*UserInGroupMapInput)(nil)).Elem(), UserInGroupMap{})
   309  	pulumi.RegisterOutputType(UserInGroupOutput{})
   310  	pulumi.RegisterOutputType(UserInGroupArrayOutput{})
   311  	pulumi.RegisterOutputType(UserInGroupMapOutput{})
   312  }