Try AWS Native preview for resources not in the classic version.
AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi
aws.cognito.getUserPools
Explore with Pulumi AI
Try AWS Native preview for resources not in the classic version.
AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi
Use this data source to get a list of cognito user pools.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const selected = aws.apigateway.getRestApi({
name: apiGatewayName,
});
const selectedGetUserPools = aws.cognito.getUserPools({
name: cognitoUserPoolName,
});
const cognito = new aws.apigateway.Authorizer("cognito", {
name: "cognito",
type: "COGNITO_USER_POOLS",
restApi: selected.then(selected => selected.id),
providerArns: selectedGetUserPools.then(selectedGetUserPools => selectedGetUserPools.arns),
});
import pulumi
import pulumi_aws as aws
selected = aws.apigateway.get_rest_api(name=api_gateway_name)
selected_get_user_pools = aws.cognito.get_user_pools(name=cognito_user_pool_name)
cognito = aws.apigateway.Authorizer("cognito",
name="cognito",
type="COGNITO_USER_POOLS",
rest_api=selected.id,
provider_arns=selected_get_user_pools.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 {
selected, err := apigateway.LookupRestApi(ctx, &apigateway.LookupRestApiArgs{
Name: apiGatewayName,
}, nil)
if err != nil {
return err
}
selectedGetUserPools, err := cognito.GetUserPools(ctx, &cognito.GetUserPoolsArgs{
Name: cognitoUserPoolName,
}, nil)
if err != nil {
return err
}
_, err = apigateway.NewAuthorizer(ctx, "cognito", &apigateway.AuthorizerArgs{
Name: pulumi.String("cognito"),
Type: pulumi.String("COGNITO_USER_POOLS"),
RestApi: pulumi.String(selected.Id),
ProviderArns: interface{}(selectedGetUserPools.Arns),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var selected = Aws.ApiGateway.GetRestApi.Invoke(new()
{
Name = apiGatewayName,
});
var selectedGetUserPools = Aws.Cognito.GetUserPools.Invoke(new()
{
Name = cognitoUserPoolName,
});
var cognito = new Aws.ApiGateway.Authorizer("cognito", new()
{
Name = "cognito",
Type = "COGNITO_USER_POOLS",
RestApi = selected.Apply(getRestApiResult => getRestApiResult.Id),
ProviderArns = selectedGetUserPools.Apply(getUserPoolsResult => getUserPoolsResult.Arns),
});
});
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 selected = ApigatewayFunctions.getRestApi(GetRestApiArgs.builder()
.name(apiGatewayName)
.build());
final var selectedGetUserPools = CognitoFunctions.getUserPools(GetUserPoolsArgs.builder()
.name(cognitoUserPoolName)
.build());
var cognito = new Authorizer("cognito", AuthorizerArgs.builder()
.name("cognito")
.type("COGNITO_USER_POOLS")
.restApi(selected.applyValue(getRestApiResult -> getRestApiResult.id()))
.providerArns(selectedGetUserPools.applyValue(getUserPoolsResult -> getUserPoolsResult.arns()))
.build());
}
}
resources:
cognito:
type: aws:apigateway:Authorizer
properties:
name: cognito
type: COGNITO_USER_POOLS
restApi: ${selected.id}
providerArns: ${selectedGetUserPools.arns}
variables:
selected:
fn::invoke:
Function: aws:apigateway:getRestApi
Arguments:
name: ${apiGatewayName}
selectedGetUserPools:
fn::invoke:
Function: aws:cognito:getUserPools
Arguments:
name: ${cognitoUserPoolName}
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:
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
aws
Terraform Provider.
Try AWS Native preview for resources not in the classic version.
AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi