GetUserPools

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

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var selectedRestApi = Output.Create(Aws.ApiGateway.GetRestApi.InvokeAsync(new Aws.ApiGateway.GetRestApiArgs
        {
            Name = @var.Api_gateway_name,
        }));
        var selectedUserPools = Output.Create(Aws.Cognito.GetUserPools.InvokeAsync(new Aws.Cognito.GetUserPoolsArgs
        {
            Name = @var.Cognito_user_pool_name,
        }));
        var cognito = new Aws.ApiGateway.Authorizer("cognito", new Aws.ApiGateway.AuthorizerArgs
        {
            ProviderArns = selectedUserPools.Apply(selectedUserPools => selectedUserPools.Arns),
            RestApi = selectedRestApi.Apply(selectedRestApi => selectedRestApi.Id),
            Type = "COGNITO_USER_POOLS",
        });
    }

}
package main

import (
    "github.com/pulumi/pulumi-aws/sdk/v2/go/aws/apigateway"
    "github.com/pulumi/pulumi-aws/sdk/v2/go/aws/cognito"
    "github.com/pulumi/pulumi/sdk/v2/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{
            ProviderArns: toPulumiStringArray(selectedUserPools.Arns),
            RestApi:      pulumi.String(selectedRestApi.Id),
            Type:         pulumi.String("COGNITO_USER_POOLS"),
        })
        if err != nil {
            return err
        }
        return nil
    })
}
func toPulumiStringArray(arr []string) pulumi.StringArray {
    var pulumiArr pulumi.StringArray
    for _, v := range arr {
        pulumiArr = append(pulumiArr, pulumi.String(v))
    }
    return pulumiArr
}
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",
    provider_arns=selected_user_pools.arns,
    rest_api=selected_rest_api.id,
    type="COGNITO_USER_POOLS")
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const selectedRestApi = pulumi.output(aws.apigateway.getRestApi({
    name: var_api_gateway_name,
}, { async: true }));
const selectedUserPools = pulumi.output(aws.cognito.getUserPools({
    name: var_cognito_user_pool_name,
}, { async: true }));
const cognito = new aws.apigateway.Authorizer("cognito", {
    providerArns: selectedUserPools.arns,
    restApi: selectedRestApi.id,
    type: "COGNITO_USER_POOLS",
});

Using GetUserPools

function getUserPools(args: GetUserPoolsArgs, opts?: InvokeOptions): Promise<GetUserPoolsResult>
function  get_user_pools(name=None, opts=None)
func GetUserPools(ctx *Context, args *GetUserPoolsArgs, opts ...InvokeOption) (*GetUserPoolsResult, error)
public static class GetUserPools {
    public static Task<GetUserPoolsResult> InvokeAsync(GetUserPoolsArgs args, InvokeOptions? opts = null)
}

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.

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.

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.

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.

GetUserPools Result

The following output properties are available:

Arns List<string>
Id string

The provider-assigned unique ID for this managed resource.

Ids List<string>

The list of cognito user pool ids.

Name string
Arns []string
Id string

The provider-assigned unique ID for this managed resource.

Ids []string

The list of cognito user pool ids.

Name string
arns string[]
id string

The provider-assigned unique ID for this managed resource.

ids string[]

The list of cognito user pool ids.

name string
arns List[str]
id str

The provider-assigned unique ID for this managed resource.

ids List[str]

The list of cognito user pool ids.

name str

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.