github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/cognito/getUserPools.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  	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
    11  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    12  )
    13  
    14  // Use this data source to get a list of cognito user pools.
    15  //
    16  // ## Example Usage
    17  //
    18  // <!--Start PulumiCodeChooser -->
    19  // ```go
    20  // package main
    21  //
    22  // import (
    23  //
    24  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/apigateway"
    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  //			selected, err := apigateway.LookupRestApi(ctx, &apigateway.LookupRestApiArgs{
    33  //				Name: apiGatewayName,
    34  //			}, nil)
    35  //			if err != nil {
    36  //				return err
    37  //			}
    38  //			selectedGetUserPools, err := cognito.GetUserPools(ctx, &cognito.GetUserPoolsArgs{
    39  //				Name: cognitoUserPoolName,
    40  //			}, nil)
    41  //			if err != nil {
    42  //				return err
    43  //			}
    44  //			_, err = apigateway.NewAuthorizer(ctx, "cognito", &apigateway.AuthorizerArgs{
    45  //				Name:         pulumi.String("cognito"),
    46  //				Type:         pulumi.String("COGNITO_USER_POOLS"),
    47  //				RestApi:      pulumi.String(selected.Id),
    48  //				ProviderArns: interface{}(selectedGetUserPools.Arns),
    49  //			})
    50  //			if err != nil {
    51  //				return err
    52  //			}
    53  //			return nil
    54  //		})
    55  //	}
    56  //
    57  // ```
    58  // <!--End PulumiCodeChooser -->
    59  func GetUserPools(ctx *pulumi.Context, args *GetUserPoolsArgs, opts ...pulumi.InvokeOption) (*GetUserPoolsResult, error) {
    60  	opts = internal.PkgInvokeDefaultOpts(opts)
    61  	var rv GetUserPoolsResult
    62  	err := ctx.Invoke("aws:cognito/getUserPools:getUserPools", args, &rv, opts...)
    63  	if err != nil {
    64  		return nil, err
    65  	}
    66  	return &rv, nil
    67  }
    68  
    69  // A collection of arguments for invoking getUserPools.
    70  type GetUserPoolsArgs struct {
    71  	// Name of the cognito user pools. Name is not a unique attribute for cognito user pool, so multiple pools might be returned with given name. If the pool name is expected to be unique, you can reference the pool id via ```tolist(data.aws_cognito_user_pools.selected.ids)[0]```
    72  	Name string `pulumi:"name"`
    73  }
    74  
    75  // A collection of values returned by getUserPools.
    76  type GetUserPoolsResult struct {
    77  	// Set of cognito user pool Amazon Resource Names (ARNs).
    78  	Arns []string `pulumi:"arns"`
    79  	// The provider-assigned unique ID for this managed resource.
    80  	Id string `pulumi:"id"`
    81  	// Set of cognito user pool ids.
    82  	Ids  []string `pulumi:"ids"`
    83  	Name string   `pulumi:"name"`
    84  }
    85  
    86  func GetUserPoolsOutput(ctx *pulumi.Context, args GetUserPoolsOutputArgs, opts ...pulumi.InvokeOption) GetUserPoolsResultOutput {
    87  	return pulumi.ToOutputWithContext(context.Background(), args).
    88  		ApplyT(func(v interface{}) (GetUserPoolsResult, error) {
    89  			args := v.(GetUserPoolsArgs)
    90  			r, err := GetUserPools(ctx, &args, opts...)
    91  			var s GetUserPoolsResult
    92  			if r != nil {
    93  				s = *r
    94  			}
    95  			return s, err
    96  		}).(GetUserPoolsResultOutput)
    97  }
    98  
    99  // A collection of arguments for invoking getUserPools.
   100  type GetUserPoolsOutputArgs struct {
   101  	// Name of the cognito user pools. Name is not a unique attribute for cognito user pool, so multiple pools might be returned with given name. If the pool name is expected to be unique, you can reference the pool id via ```tolist(data.aws_cognito_user_pools.selected.ids)[0]```
   102  	Name pulumi.StringInput `pulumi:"name"`
   103  }
   104  
   105  func (GetUserPoolsOutputArgs) ElementType() reflect.Type {
   106  	return reflect.TypeOf((*GetUserPoolsArgs)(nil)).Elem()
   107  }
   108  
   109  // A collection of values returned by getUserPools.
   110  type GetUserPoolsResultOutput struct{ *pulumi.OutputState }
   111  
   112  func (GetUserPoolsResultOutput) ElementType() reflect.Type {
   113  	return reflect.TypeOf((*GetUserPoolsResult)(nil)).Elem()
   114  }
   115  
   116  func (o GetUserPoolsResultOutput) ToGetUserPoolsResultOutput() GetUserPoolsResultOutput {
   117  	return o
   118  }
   119  
   120  func (o GetUserPoolsResultOutput) ToGetUserPoolsResultOutputWithContext(ctx context.Context) GetUserPoolsResultOutput {
   121  	return o
   122  }
   123  
   124  // Set of cognito user pool Amazon Resource Names (ARNs).
   125  func (o GetUserPoolsResultOutput) Arns() pulumi.StringArrayOutput {
   126  	return o.ApplyT(func(v GetUserPoolsResult) []string { return v.Arns }).(pulumi.StringArrayOutput)
   127  }
   128  
   129  // The provider-assigned unique ID for this managed resource.
   130  func (o GetUserPoolsResultOutput) Id() pulumi.StringOutput {
   131  	return o.ApplyT(func(v GetUserPoolsResult) string { return v.Id }).(pulumi.StringOutput)
   132  }
   133  
   134  // Set of cognito user pool ids.
   135  func (o GetUserPoolsResultOutput) Ids() pulumi.StringArrayOutput {
   136  	return o.ApplyT(func(v GetUserPoolsResult) []string { return v.Ids }).(pulumi.StringArrayOutput)
   137  }
   138  
   139  func (o GetUserPoolsResultOutput) Name() pulumi.StringOutput {
   140  	return o.ApplyT(func(v GetUserPoolsResult) string { return v.Name }).(pulumi.StringOutput)
   141  }
   142  
   143  func init() {
   144  	pulumi.RegisterOutputType(GetUserPoolsResultOutput{})
   145  }