1. Packages
  2. AWS Classic
  3. API Docs
  4. cognito
  5. getUserPools

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.13.1 published on Tuesday, Dec 5, 2023 by Pulumi

aws.cognito.getUserPools

Explore with Pulumi AI

aws logo

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.13.1 published on Tuesday, Dec 5, 2023 by Pulumi

    Use this data source to get a list of cognito user pools.

    Example Usage

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var selectedRestApi = Aws.ApiGateway.GetRestApi.Invoke(new()
        {
            Name = @var.Api_gateway_name,
        });
    
        var selectedUserPools = Aws.Cognito.GetUserPools.Invoke(new()
        {
            Name = @var.Cognito_user_pool_name,
        });
    
        var cognito = new Aws.ApiGateway.Authorizer("cognito", new()
        {
            Type = "COGNITO_USER_POOLS",
            RestApi = selectedRestApi.Apply(getRestApiResult => getRestApiResult.Id),
            ProviderArns = selectedUserPools.Apply(getUserPoolsResult => getUserPoolsResult.Arns),
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/apigateway"
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cognito"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		selectedRestApi, err := apigateway.LookupRestApi(ctx, &apigateway.LookupRestApiArgs{
    			Name: _var.Api_gateway_name,
    		}, nil)
    		if err != nil {
    			return err
    		}
    		selectedUserPools, err := cognito.GetUserPools(ctx, &cognito.GetUserPoolsArgs{
    			Name: _var.Cognito_user_pool_name,
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = apigateway.NewAuthorizer(ctx, "cognito", &apigateway.AuthorizerArgs{
    			Type:         pulumi.String("COGNITO_USER_POOLS"),
    			RestApi:      *pulumi.String(selectedRestApi.Id),
    			ProviderArns: interface{}(selectedUserPools.Arns),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.apigateway.ApigatewayFunctions;
    import com.pulumi.aws.apigateway.inputs.GetRestApiArgs;
    import com.pulumi.aws.cognito.CognitoFunctions;
    import com.pulumi.aws.cognito.inputs.GetUserPoolsArgs;
    import com.pulumi.aws.apigateway.Authorizer;
    import com.pulumi.aws.apigateway.AuthorizerArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            final var selectedRestApi = ApigatewayFunctions.getRestApi(GetRestApiArgs.builder()
                .name(var_.api_gateway_name())
                .build());
    
            final var selectedUserPools = CognitoFunctions.getUserPools(GetUserPoolsArgs.builder()
                .name(var_.cognito_user_pool_name())
                .build());
    
            var cognito = new Authorizer("cognito", AuthorizerArgs.builder()        
                .type("COGNITO_USER_POOLS")
                .restApi(selectedRestApi.applyValue(getRestApiResult -> getRestApiResult.id()))
                .providerArns(selectedUserPools.applyValue(getUserPoolsResult -> getUserPoolsResult.arns()))
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_aws as aws
    
    selected_rest_api = aws.apigateway.get_rest_api(name=var["api_gateway_name"])
    selected_user_pools = aws.cognito.get_user_pools(name=var["cognito_user_pool_name"])
    cognito = aws.apigateway.Authorizer("cognito",
        type="COGNITO_USER_POOLS",
        rest_api=selected_rest_api.id,
        provider_arns=selected_user_pools.arns)
    
    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const selectedRestApi = aws.apigateway.getRestApi({
        name: _var.api_gateway_name,
    });
    const selectedUserPools = aws.cognito.getUserPools({
        name: _var.cognito_user_pool_name,
    });
    const cognito = new aws.apigateway.Authorizer("cognito", {
        type: "COGNITO_USER_POOLS",
        restApi: selectedRestApi.then(selectedRestApi => selectedRestApi.id),
        providerArns: selectedUserPools.then(selectedUserPools => selectedUserPools.arns),
    });
    
    resources:
      cognito:
        type: aws:apigateway:Authorizer
        properties:
          type: COGNITO_USER_POOLS
          restApi: ${selectedRestApi.id}
          providerArns: ${selectedUserPools.arns}
    variables:
      selectedRestApi:
        fn::invoke:
          Function: aws:apigateway:getRestApi
          Arguments:
            name: ${var.api_gateway_name}
      selectedUserPools:
        fn::invoke:
          Function: aws:cognito:getUserPools
          Arguments:
            name: ${var.cognito_user_pool_name}
    

    Using getUserPools

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getUserPools(args: GetUserPoolsArgs, opts?: InvokeOptions): Promise<GetUserPoolsResult>
    function getUserPoolsOutput(args: GetUserPoolsOutputArgs, opts?: InvokeOptions): Output<GetUserPoolsResult>
    def get_user_pools(name: Optional[str] = None,
                       opts: Optional[InvokeOptions] = None) -> GetUserPoolsResult
    def get_user_pools_output(name: Optional[pulumi.Input[str]] = None,
                       opts: Optional[InvokeOptions] = None) -> Output[GetUserPoolsResult]
    func GetUserPools(ctx *Context, args *GetUserPoolsArgs, opts ...InvokeOption) (*GetUserPoolsResult, error)
    func GetUserPoolsOutput(ctx *Context, args *GetUserPoolsOutputArgs, opts ...InvokeOption) GetUserPoolsResultOutput

    > Note: This function is named GetUserPools in the Go SDK.

    public static class GetUserPools 
    {
        public static Task<GetUserPoolsResult> InvokeAsync(GetUserPoolsArgs args, InvokeOptions? opts = null)
        public static Output<GetUserPoolsResult> Invoke(GetUserPoolsInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetUserPoolsResult> getUserPools(GetUserPoolsArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: aws:cognito/getUserPools:getUserPools
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Name string

    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]

    Name string

    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]

    name String

    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]

    name string

    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]

    name str

    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]

    name String

    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]

    getUserPools Result

    The following output properties are available:

    Arns List<string>

    Set of cognito user pool Amazon Resource Names (ARNs).

    Id string

    The provider-assigned unique ID for this managed resource.

    Ids List<string>

    Set of cognito user pool ids.

    Name string
    Arns []string

    Set of cognito user pool Amazon Resource Names (ARNs).

    Id string

    The provider-assigned unique ID for this managed resource.

    Ids []string

    Set of cognito user pool ids.

    Name string
    arns List<String>

    Set of cognito user pool Amazon Resource Names (ARNs).

    id String

    The provider-assigned unique ID for this managed resource.

    ids List<String>

    Set of cognito user pool ids.

    name String
    arns string[]

    Set of cognito user pool Amazon Resource Names (ARNs).

    id string

    The provider-assigned unique ID for this managed resource.

    ids string[]

    Set of cognito user pool ids.

    name string
    arns Sequence[str]

    Set of cognito user pool Amazon Resource Names (ARNs).

    id str

    The provider-assigned unique ID for this managed resource.

    ids Sequence[str]

    Set of cognito user pool ids.

    name str
    arns List<String>

    Set of cognito user pool Amazon Resource Names (ARNs).

    id String

    The provider-assigned unique ID for this managed resource.

    ids List<String>

    Set of cognito user pool ids.

    name String

    Package Details

    Repository
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes

    This Pulumi package is based on the aws Terraform Provider.

    aws logo

    Try AWS Native preview for resources not in the classic version.

    AWS Classic v6.13.1 published on Tuesday, Dec 5, 2023 by Pulumi