github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/cognito/userGroup.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  // Provides a Cognito User Group resource.
    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-aws/sdk/v6/go/aws/iam"
    27  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    28  //
    29  // )
    30  //
    31  //	func main() {
    32  //		pulumi.Run(func(ctx *pulumi.Context) error {
    33  //			main, err := cognito.NewUserPool(ctx, "main", &cognito.UserPoolArgs{
    34  //				Name: pulumi.String("identity pool"),
    35  //			})
    36  //			if err != nil {
    37  //				return err
    38  //			}
    39  //			groupRole, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
    40  //				Statements: []iam.GetPolicyDocumentStatement{
    41  //					{
    42  //						Effect: pulumi.StringRef("Allow"),
    43  //						Principals: []iam.GetPolicyDocumentStatementPrincipal{
    44  //							{
    45  //								Type: "Federated",
    46  //								Identifiers: []string{
    47  //									"cognito-identity.amazonaws.com",
    48  //								},
    49  //							},
    50  //						},
    51  //						Actions: []string{
    52  //							"sts:AssumeRoleWithWebIdentity",
    53  //						},
    54  //						Conditions: []iam.GetPolicyDocumentStatementCondition{
    55  //							{
    56  //								Test:     "StringEquals",
    57  //								Variable: "cognito-identity.amazonaws.com:aud",
    58  //								Values: []string{
    59  //									"us-east-1:12345678-dead-beef-cafe-123456790ab",
    60  //								},
    61  //							},
    62  //							{
    63  //								Test:     "ForAnyValue:StringLike",
    64  //								Variable: "cognito-identity.amazonaws.com:amr",
    65  //								Values: []string{
    66  //									"authenticated",
    67  //								},
    68  //							},
    69  //						},
    70  //					},
    71  //				},
    72  //			}, nil)
    73  //			if err != nil {
    74  //				return err
    75  //			}
    76  //			groupRoleRole, err := iam.NewRole(ctx, "group_role", &iam.RoleArgs{
    77  //				Name:             pulumi.String("user-group-role"),
    78  //				AssumeRolePolicy: pulumi.String(groupRole.Json),
    79  //			})
    80  //			if err != nil {
    81  //				return err
    82  //			}
    83  //			_, err = cognito.NewUserGroup(ctx, "main", &cognito.UserGroupArgs{
    84  //				Name:        pulumi.String("user-group"),
    85  //				UserPoolId:  main.ID(),
    86  //				Description: pulumi.String("Managed by Pulumi"),
    87  //				Precedence:  pulumi.Int(42),
    88  //				RoleArn:     groupRoleRole.Arn,
    89  //			})
    90  //			if err != nil {
    91  //				return err
    92  //			}
    93  //			return nil
    94  //		})
    95  //	}
    96  //
    97  // ```
    98  // <!--End PulumiCodeChooser -->
    99  //
   100  // ## Import
   101  //
   102  // Using `pulumi import`, import Cognito User Groups using the `user_pool_id`/`name` attributes concatenated. For example:
   103  //
   104  // ```sh
   105  // $ pulumi import aws:cognito/userGroup:UserGroup group us-east-1_vG78M4goG/user-group
   106  // ```
   107  type UserGroup struct {
   108  	pulumi.CustomResourceState
   109  
   110  	// The description of the user group.
   111  	Description pulumi.StringPtrOutput `pulumi:"description"`
   112  	// The name of the user group.
   113  	Name pulumi.StringOutput `pulumi:"name"`
   114  	// The precedence of the user group.
   115  	Precedence pulumi.IntPtrOutput `pulumi:"precedence"`
   116  	// The ARN of the IAM role to be associated with the user group.
   117  	RoleArn pulumi.StringPtrOutput `pulumi:"roleArn"`
   118  	// The user pool ID.
   119  	UserPoolId pulumi.StringOutput `pulumi:"userPoolId"`
   120  }
   121  
   122  // NewUserGroup registers a new resource with the given unique name, arguments, and options.
   123  func NewUserGroup(ctx *pulumi.Context,
   124  	name string, args *UserGroupArgs, opts ...pulumi.ResourceOption) (*UserGroup, error) {
   125  	if args == nil {
   126  		return nil, errors.New("missing one or more required arguments")
   127  	}
   128  
   129  	if args.UserPoolId == nil {
   130  		return nil, errors.New("invalid value for required argument 'UserPoolId'")
   131  	}
   132  	opts = internal.PkgResourceDefaultOpts(opts)
   133  	var resource UserGroup
   134  	err := ctx.RegisterResource("aws:cognito/userGroup:UserGroup", name, args, &resource, opts...)
   135  	if err != nil {
   136  		return nil, err
   137  	}
   138  	return &resource, nil
   139  }
   140  
   141  // GetUserGroup gets an existing UserGroup resource's state with the given name, ID, and optional
   142  // state properties that are used to uniquely qualify the lookup (nil if not required).
   143  func GetUserGroup(ctx *pulumi.Context,
   144  	name string, id pulumi.IDInput, state *UserGroupState, opts ...pulumi.ResourceOption) (*UserGroup, error) {
   145  	var resource UserGroup
   146  	err := ctx.ReadResource("aws:cognito/userGroup:UserGroup", name, id, state, &resource, opts...)
   147  	if err != nil {
   148  		return nil, err
   149  	}
   150  	return &resource, nil
   151  }
   152  
   153  // Input properties used for looking up and filtering UserGroup resources.
   154  type userGroupState struct {
   155  	// The description of the user group.
   156  	Description *string `pulumi:"description"`
   157  	// The name of the user group.
   158  	Name *string `pulumi:"name"`
   159  	// The precedence of the user group.
   160  	Precedence *int `pulumi:"precedence"`
   161  	// The ARN of the IAM role to be associated with the user group.
   162  	RoleArn *string `pulumi:"roleArn"`
   163  	// The user pool ID.
   164  	UserPoolId *string `pulumi:"userPoolId"`
   165  }
   166  
   167  type UserGroupState struct {
   168  	// The description of the user group.
   169  	Description pulumi.StringPtrInput
   170  	// The name of the user group.
   171  	Name pulumi.StringPtrInput
   172  	// The precedence of the user group.
   173  	Precedence pulumi.IntPtrInput
   174  	// The ARN of the IAM role to be associated with the user group.
   175  	RoleArn pulumi.StringPtrInput
   176  	// The user pool ID.
   177  	UserPoolId pulumi.StringPtrInput
   178  }
   179  
   180  func (UserGroupState) ElementType() reflect.Type {
   181  	return reflect.TypeOf((*userGroupState)(nil)).Elem()
   182  }
   183  
   184  type userGroupArgs struct {
   185  	// The description of the user group.
   186  	Description *string `pulumi:"description"`
   187  	// The name of the user group.
   188  	Name *string `pulumi:"name"`
   189  	// The precedence of the user group.
   190  	Precedence *int `pulumi:"precedence"`
   191  	// The ARN of the IAM role to be associated with the user group.
   192  	RoleArn *string `pulumi:"roleArn"`
   193  	// The user pool ID.
   194  	UserPoolId string `pulumi:"userPoolId"`
   195  }
   196  
   197  // The set of arguments for constructing a UserGroup resource.
   198  type UserGroupArgs struct {
   199  	// The description of the user group.
   200  	Description pulumi.StringPtrInput
   201  	// The name of the user group.
   202  	Name pulumi.StringPtrInput
   203  	// The precedence of the user group.
   204  	Precedence pulumi.IntPtrInput
   205  	// The ARN of the IAM role to be associated with the user group.
   206  	RoleArn pulumi.StringPtrInput
   207  	// The user pool ID.
   208  	UserPoolId pulumi.StringInput
   209  }
   210  
   211  func (UserGroupArgs) ElementType() reflect.Type {
   212  	return reflect.TypeOf((*userGroupArgs)(nil)).Elem()
   213  }
   214  
   215  type UserGroupInput interface {
   216  	pulumi.Input
   217  
   218  	ToUserGroupOutput() UserGroupOutput
   219  	ToUserGroupOutputWithContext(ctx context.Context) UserGroupOutput
   220  }
   221  
   222  func (*UserGroup) ElementType() reflect.Type {
   223  	return reflect.TypeOf((**UserGroup)(nil)).Elem()
   224  }
   225  
   226  func (i *UserGroup) ToUserGroupOutput() UserGroupOutput {
   227  	return i.ToUserGroupOutputWithContext(context.Background())
   228  }
   229  
   230  func (i *UserGroup) ToUserGroupOutputWithContext(ctx context.Context) UserGroupOutput {
   231  	return pulumi.ToOutputWithContext(ctx, i).(UserGroupOutput)
   232  }
   233  
   234  // UserGroupArrayInput is an input type that accepts UserGroupArray and UserGroupArrayOutput values.
   235  // You can construct a concrete instance of `UserGroupArrayInput` via:
   236  //
   237  //	UserGroupArray{ UserGroupArgs{...} }
   238  type UserGroupArrayInput interface {
   239  	pulumi.Input
   240  
   241  	ToUserGroupArrayOutput() UserGroupArrayOutput
   242  	ToUserGroupArrayOutputWithContext(context.Context) UserGroupArrayOutput
   243  }
   244  
   245  type UserGroupArray []UserGroupInput
   246  
   247  func (UserGroupArray) ElementType() reflect.Type {
   248  	return reflect.TypeOf((*[]*UserGroup)(nil)).Elem()
   249  }
   250  
   251  func (i UserGroupArray) ToUserGroupArrayOutput() UserGroupArrayOutput {
   252  	return i.ToUserGroupArrayOutputWithContext(context.Background())
   253  }
   254  
   255  func (i UserGroupArray) ToUserGroupArrayOutputWithContext(ctx context.Context) UserGroupArrayOutput {
   256  	return pulumi.ToOutputWithContext(ctx, i).(UserGroupArrayOutput)
   257  }
   258  
   259  // UserGroupMapInput is an input type that accepts UserGroupMap and UserGroupMapOutput values.
   260  // You can construct a concrete instance of `UserGroupMapInput` via:
   261  //
   262  //	UserGroupMap{ "key": UserGroupArgs{...} }
   263  type UserGroupMapInput interface {
   264  	pulumi.Input
   265  
   266  	ToUserGroupMapOutput() UserGroupMapOutput
   267  	ToUserGroupMapOutputWithContext(context.Context) UserGroupMapOutput
   268  }
   269  
   270  type UserGroupMap map[string]UserGroupInput
   271  
   272  func (UserGroupMap) ElementType() reflect.Type {
   273  	return reflect.TypeOf((*map[string]*UserGroup)(nil)).Elem()
   274  }
   275  
   276  func (i UserGroupMap) ToUserGroupMapOutput() UserGroupMapOutput {
   277  	return i.ToUserGroupMapOutputWithContext(context.Background())
   278  }
   279  
   280  func (i UserGroupMap) ToUserGroupMapOutputWithContext(ctx context.Context) UserGroupMapOutput {
   281  	return pulumi.ToOutputWithContext(ctx, i).(UserGroupMapOutput)
   282  }
   283  
   284  type UserGroupOutput struct{ *pulumi.OutputState }
   285  
   286  func (UserGroupOutput) ElementType() reflect.Type {
   287  	return reflect.TypeOf((**UserGroup)(nil)).Elem()
   288  }
   289  
   290  func (o UserGroupOutput) ToUserGroupOutput() UserGroupOutput {
   291  	return o
   292  }
   293  
   294  func (o UserGroupOutput) ToUserGroupOutputWithContext(ctx context.Context) UserGroupOutput {
   295  	return o
   296  }
   297  
   298  // The description of the user group.
   299  func (o UserGroupOutput) Description() pulumi.StringPtrOutput {
   300  	return o.ApplyT(func(v *UserGroup) pulumi.StringPtrOutput { return v.Description }).(pulumi.StringPtrOutput)
   301  }
   302  
   303  // The name of the user group.
   304  func (o UserGroupOutput) Name() pulumi.StringOutput {
   305  	return o.ApplyT(func(v *UserGroup) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
   306  }
   307  
   308  // The precedence of the user group.
   309  func (o UserGroupOutput) Precedence() pulumi.IntPtrOutput {
   310  	return o.ApplyT(func(v *UserGroup) pulumi.IntPtrOutput { return v.Precedence }).(pulumi.IntPtrOutput)
   311  }
   312  
   313  // The ARN of the IAM role to be associated with the user group.
   314  func (o UserGroupOutput) RoleArn() pulumi.StringPtrOutput {
   315  	return o.ApplyT(func(v *UserGroup) pulumi.StringPtrOutput { return v.RoleArn }).(pulumi.StringPtrOutput)
   316  }
   317  
   318  // The user pool ID.
   319  func (o UserGroupOutput) UserPoolId() pulumi.StringOutput {
   320  	return o.ApplyT(func(v *UserGroup) pulumi.StringOutput { return v.UserPoolId }).(pulumi.StringOutput)
   321  }
   322  
   323  type UserGroupArrayOutput struct{ *pulumi.OutputState }
   324  
   325  func (UserGroupArrayOutput) ElementType() reflect.Type {
   326  	return reflect.TypeOf((*[]*UserGroup)(nil)).Elem()
   327  }
   328  
   329  func (o UserGroupArrayOutput) ToUserGroupArrayOutput() UserGroupArrayOutput {
   330  	return o
   331  }
   332  
   333  func (o UserGroupArrayOutput) ToUserGroupArrayOutputWithContext(ctx context.Context) UserGroupArrayOutput {
   334  	return o
   335  }
   336  
   337  func (o UserGroupArrayOutput) Index(i pulumi.IntInput) UserGroupOutput {
   338  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *UserGroup {
   339  		return vs[0].([]*UserGroup)[vs[1].(int)]
   340  	}).(UserGroupOutput)
   341  }
   342  
   343  type UserGroupMapOutput struct{ *pulumi.OutputState }
   344  
   345  func (UserGroupMapOutput) ElementType() reflect.Type {
   346  	return reflect.TypeOf((*map[string]*UserGroup)(nil)).Elem()
   347  }
   348  
   349  func (o UserGroupMapOutput) ToUserGroupMapOutput() UserGroupMapOutput {
   350  	return o
   351  }
   352  
   353  func (o UserGroupMapOutput) ToUserGroupMapOutputWithContext(ctx context.Context) UserGroupMapOutput {
   354  	return o
   355  }
   356  
   357  func (o UserGroupMapOutput) MapIndex(k pulumi.StringInput) UserGroupOutput {
   358  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *UserGroup {
   359  		return vs[0].(map[string]*UserGroup)[vs[1].(string)]
   360  	}).(UserGroupOutput)
   361  }
   362  
   363  func init() {
   364  	pulumi.RegisterInputType(reflect.TypeOf((*UserGroupInput)(nil)).Elem(), &UserGroup{})
   365  	pulumi.RegisterInputType(reflect.TypeOf((*UserGroupArrayInput)(nil)).Elem(), UserGroupArray{})
   366  	pulumi.RegisterInputType(reflect.TypeOf((*UserGroupMapInput)(nil)).Elem(), UserGroupMap{})
   367  	pulumi.RegisterOutputType(UserGroupOutput{})
   368  	pulumi.RegisterOutputType(UserGroupArrayOutput{})
   369  	pulumi.RegisterOutputType(UserGroupMapOutput{})
   370  }