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

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.UserGroup

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

    Provides a Cognito User Group resource.

    Example Usage

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var mainUserPool = new Aws.Cognito.UserPool("mainUserPool");
    
        var groupRolePolicyDocument = Aws.Iam.GetPolicyDocument.Invoke(new()
        {
            Statements = new[]
            {
                new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
                {
                    Effect = "Allow",
                    Principals = new[]
                    {
                        new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
                        {
                            Type = "Federated",
                            Identifiers = new[]
                            {
                                "cognito-identity.amazonaws.com",
                            },
                        },
                    },
                    Actions = new[]
                    {
                        "sts:AssumeRoleWithWebIdentity",
                    },
                    Conditions = new[]
                    {
                        new Aws.Iam.Inputs.GetPolicyDocumentStatementConditionInputArgs
                        {
                            Test = "StringEquals",
                            Variable = "cognito-identity.amazonaws.com:aud",
                            Values = new[]
                            {
                                "us-east-1:12345678-dead-beef-cafe-123456790ab",
                            },
                        },
                        new Aws.Iam.Inputs.GetPolicyDocumentStatementConditionInputArgs
                        {
                            Test = "ForAnyValue:StringLike",
                            Variable = "cognito-identity.amazonaws.com:amr",
                            Values = new[]
                            {
                                "authenticated",
                            },
                        },
                    },
                },
            },
        });
    
        var groupRoleRole = new Aws.Iam.Role("groupRoleRole", new()
        {
            AssumeRolePolicy = groupRolePolicyDocument.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
        });
    
        var mainUserGroup = new Aws.Cognito.UserGroup("mainUserGroup", new()
        {
            UserPoolId = mainUserPool.Id,
            Description = "Managed by Pulumi",
            Precedence = 42,
            RoleArn = groupRoleRole.Arn,
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cognito"
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		mainUserPool, err := cognito.NewUserPool(ctx, "mainUserPool", nil)
    		if err != nil {
    			return err
    		}
    		groupRolePolicyDocument, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
    			Statements: []iam.GetPolicyDocumentStatement{
    				{
    					Effect: pulumi.StringRef("Allow"),
    					Principals: []iam.GetPolicyDocumentStatementPrincipal{
    						{
    							Type: "Federated",
    							Identifiers: []string{
    								"cognito-identity.amazonaws.com",
    							},
    						},
    					},
    					Actions: []string{
    						"sts:AssumeRoleWithWebIdentity",
    					},
    					Conditions: []iam.GetPolicyDocumentStatementCondition{
    						{
    							Test:     "StringEquals",
    							Variable: "cognito-identity.amazonaws.com:aud",
    							Values: []string{
    								"us-east-1:12345678-dead-beef-cafe-123456790ab",
    							},
    						},
    						{
    							Test:     "ForAnyValue:StringLike",
    							Variable: "cognito-identity.amazonaws.com:amr",
    							Values: []string{
    								"authenticated",
    							},
    						},
    					},
    				},
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		groupRoleRole, err := iam.NewRole(ctx, "groupRoleRole", &iam.RoleArgs{
    			AssumeRolePolicy: *pulumi.String(groupRolePolicyDocument.Json),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = cognito.NewUserGroup(ctx, "mainUserGroup", &cognito.UserGroupArgs{
    			UserPoolId:  mainUserPool.ID(),
    			Description: pulumi.String("Managed by Pulumi"),
    			Precedence:  pulumi.Int(42),
    			RoleArn:     groupRoleRole.Arn,
    		})
    		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.cognito.UserPool;
    import com.pulumi.aws.iam.IamFunctions;
    import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
    import com.pulumi.aws.iam.Role;
    import com.pulumi.aws.iam.RoleArgs;
    import com.pulumi.aws.cognito.UserGroup;
    import com.pulumi.aws.cognito.UserGroupArgs;
    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) {
            var mainUserPool = new UserPool("mainUserPool");
    
            final var groupRolePolicyDocument = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
                .statements(GetPolicyDocumentStatementArgs.builder()
                    .effect("Allow")
                    .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
                        .type("Federated")
                        .identifiers("cognito-identity.amazonaws.com")
                        .build())
                    .actions("sts:AssumeRoleWithWebIdentity")
                    .conditions(                
                        GetPolicyDocumentStatementConditionArgs.builder()
                            .test("StringEquals")
                            .variable("cognito-identity.amazonaws.com:aud")
                            .values("us-east-1:12345678-dead-beef-cafe-123456790ab")
                            .build(),
                        GetPolicyDocumentStatementConditionArgs.builder()
                            .test("ForAnyValue:StringLike")
                            .variable("cognito-identity.amazonaws.com:amr")
                            .values("authenticated")
                            .build())
                    .build())
                .build());
    
            var groupRoleRole = new Role("groupRoleRole", RoleArgs.builder()        
                .assumeRolePolicy(groupRolePolicyDocument.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult.json()))
                .build());
    
            var mainUserGroup = new UserGroup("mainUserGroup", UserGroupArgs.builder()        
                .userPoolId(mainUserPool.id())
                .description("Managed by Pulumi")
                .precedence(42)
                .roleArn(groupRoleRole.arn())
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_aws as aws
    
    main_user_pool = aws.cognito.UserPool("mainUserPool")
    group_role_policy_document = aws.iam.get_policy_document(statements=[aws.iam.GetPolicyDocumentStatementArgs(
        effect="Allow",
        principals=[aws.iam.GetPolicyDocumentStatementPrincipalArgs(
            type="Federated",
            identifiers=["cognito-identity.amazonaws.com"],
        )],
        actions=["sts:AssumeRoleWithWebIdentity"],
        conditions=[
            aws.iam.GetPolicyDocumentStatementConditionArgs(
                test="StringEquals",
                variable="cognito-identity.amazonaws.com:aud",
                values=["us-east-1:12345678-dead-beef-cafe-123456790ab"],
            ),
            aws.iam.GetPolicyDocumentStatementConditionArgs(
                test="ForAnyValue:StringLike",
                variable="cognito-identity.amazonaws.com:amr",
                values=["authenticated"],
            ),
        ],
    )])
    group_role_role = aws.iam.Role("groupRoleRole", assume_role_policy=group_role_policy_document.json)
    main_user_group = aws.cognito.UserGroup("mainUserGroup",
        user_pool_id=main_user_pool.id,
        description="Managed by Pulumi",
        precedence=42,
        role_arn=group_role_role.arn)
    
    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const mainUserPool = new aws.cognito.UserPool("mainUserPool", {});
    const groupRolePolicyDocument = aws.iam.getPolicyDocument({
        statements: [{
            effect: "Allow",
            principals: [{
                type: "Federated",
                identifiers: ["cognito-identity.amazonaws.com"],
            }],
            actions: ["sts:AssumeRoleWithWebIdentity"],
            conditions: [
                {
                    test: "StringEquals",
                    variable: "cognito-identity.amazonaws.com:aud",
                    values: ["us-east-1:12345678-dead-beef-cafe-123456790ab"],
                },
                {
                    test: "ForAnyValue:StringLike",
                    variable: "cognito-identity.amazonaws.com:amr",
                    values: ["authenticated"],
                },
            ],
        }],
    });
    const groupRoleRole = new aws.iam.Role("groupRoleRole", {assumeRolePolicy: groupRolePolicyDocument.then(groupRolePolicyDocument => groupRolePolicyDocument.json)});
    const mainUserGroup = new aws.cognito.UserGroup("mainUserGroup", {
        userPoolId: mainUserPool.id,
        description: "Managed by Pulumi",
        precedence: 42,
        roleArn: groupRoleRole.arn,
    });
    
    resources:
      mainUserPool:
        type: aws:cognito:UserPool
      groupRoleRole:
        type: aws:iam:Role
        properties:
          assumeRolePolicy: ${groupRolePolicyDocument.json}
      mainUserGroup:
        type: aws:cognito:UserGroup
        properties:
          userPoolId: ${mainUserPool.id}
          description: Managed by Pulumi
          precedence: 42
          roleArn: ${groupRoleRole.arn}
    variables:
      groupRolePolicyDocument:
        fn::invoke:
          Function: aws:iam:getPolicyDocument
          Arguments:
            statements:
              - effect: Allow
                principals:
                  - type: Federated
                    identifiers:
                      - cognito-identity.amazonaws.com
                actions:
                  - sts:AssumeRoleWithWebIdentity
                conditions:
                  - test: StringEquals
                    variable: cognito-identity.amazonaws.com:aud
                    values:
                      - us-east-1:12345678-dead-beef-cafe-123456790ab
                  - test: ForAnyValue:StringLike
                    variable: cognito-identity.amazonaws.com:amr
                    values:
                      - authenticated
    

    Create UserGroup Resource

    new UserGroup(name: string, args: UserGroupArgs, opts?: CustomResourceOptions);
    @overload
    def UserGroup(resource_name: str,
                  opts: Optional[ResourceOptions] = None,
                  description: Optional[str] = None,
                  name: Optional[str] = None,
                  precedence: Optional[int] = None,
                  role_arn: Optional[str] = None,
                  user_pool_id: Optional[str] = None)
    @overload
    def UserGroup(resource_name: str,
                  args: UserGroupArgs,
                  opts: Optional[ResourceOptions] = None)
    func NewUserGroup(ctx *Context, name string, args UserGroupArgs, opts ...ResourceOption) (*UserGroup, error)
    public UserGroup(string name, UserGroupArgs args, CustomResourceOptions? opts = null)
    public UserGroup(String name, UserGroupArgs args)
    public UserGroup(String name, UserGroupArgs args, CustomResourceOptions options)
    
    type: aws:cognito:UserGroup
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    name string
    The unique name of the resource.
    args UserGroupArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args UserGroupArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args UserGroupArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args UserGroupArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args UserGroupArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    UserGroup Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    The UserGroup resource accepts the following input properties:

    UserPoolId string

    The user pool ID.

    Description string

    The description of the user group.

    Name string

    The name of the user group.

    Precedence int

    The precedence of the user group.

    RoleArn string

    The ARN of the IAM role to be associated with the user group.

    UserPoolId string

    The user pool ID.

    Description string

    The description of the user group.

    Name string

    The name of the user group.

    Precedence int

    The precedence of the user group.

    RoleArn string

    The ARN of the IAM role to be associated with the user group.

    userPoolId String

    The user pool ID.

    description String

    The description of the user group.

    name String

    The name of the user group.

    precedence Integer

    The precedence of the user group.

    roleArn String

    The ARN of the IAM role to be associated with the user group.

    userPoolId string

    The user pool ID.

    description string

    The description of the user group.

    name string

    The name of the user group.

    precedence number

    The precedence of the user group.

    roleArn string

    The ARN of the IAM role to be associated with the user group.

    user_pool_id str

    The user pool ID.

    description str

    The description of the user group.

    name str

    The name of the user group.

    precedence int

    The precedence of the user group.

    role_arn str

    The ARN of the IAM role to be associated with the user group.

    userPoolId String

    The user pool ID.

    description String

    The description of the user group.

    name String

    The name of the user group.

    precedence Number

    The precedence of the user group.

    roleArn String

    The ARN of the IAM role to be associated with the user group.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the UserGroup resource produces the following output properties:

    Id string

    The provider-assigned unique ID for this managed resource.

    Id string

    The provider-assigned unique ID for this managed resource.

    id String

    The provider-assigned unique ID for this managed resource.

    id string

    The provider-assigned unique ID for this managed resource.

    id str

    The provider-assigned unique ID for this managed resource.

    id String

    The provider-assigned unique ID for this managed resource.

    Look up Existing UserGroup Resource

    Get an existing UserGroup resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: UserGroupState, opts?: CustomResourceOptions): UserGroup
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            description: Optional[str] = None,
            name: Optional[str] = None,
            precedence: Optional[int] = None,
            role_arn: Optional[str] = None,
            user_pool_id: Optional[str] = None) -> UserGroup
    func GetUserGroup(ctx *Context, name string, id IDInput, state *UserGroupState, opts ...ResourceOption) (*UserGroup, error)
    public static UserGroup Get(string name, Input<string> id, UserGroupState? state, CustomResourceOptions? opts = null)
    public static UserGroup get(String name, Output<String> id, UserGroupState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    Description string

    The description of the user group.

    Name string

    The name of the user group.

    Precedence int

    The precedence of the user group.

    RoleArn string

    The ARN of the IAM role to be associated with the user group.

    UserPoolId string

    The user pool ID.

    Description string

    The description of the user group.

    Name string

    The name of the user group.

    Precedence int

    The precedence of the user group.

    RoleArn string

    The ARN of the IAM role to be associated with the user group.

    UserPoolId string

    The user pool ID.

    description String

    The description of the user group.

    name String

    The name of the user group.

    precedence Integer

    The precedence of the user group.

    roleArn String

    The ARN of the IAM role to be associated with the user group.

    userPoolId String

    The user pool ID.

    description string

    The description of the user group.

    name string

    The name of the user group.

    precedence number

    The precedence of the user group.

    roleArn string

    The ARN of the IAM role to be associated with the user group.

    userPoolId string

    The user pool ID.

    description str

    The description of the user group.

    name str

    The name of the user group.

    precedence int

    The precedence of the user group.

    role_arn str

    The ARN of the IAM role to be associated with the user group.

    user_pool_id str

    The user pool ID.

    description String

    The description of the user group.

    name String

    The name of the user group.

    precedence Number

    The precedence of the user group.

    roleArn String

    The ARN of the IAM role to be associated with the user group.

    userPoolId String

    The user pool ID.

    Import

    Using pulumi import, import Cognito User Groups using the user_pool_id/name attributes concatenated. For example:

     $ pulumi import aws:cognito/userGroup:UserGroup group us-east-1_vG78M4goG/user-group
    

    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