Skip to content
GitHubXDiscord

UserPoolGroup

The UserPoolGroup resource lets you manage AWS Cognito UserPoolGroups to organize users and control their access to resources.

Create a basic user pool group with required properties and a common optional property:

import AWS from "alchemy/aws/control";
const userPoolGroup = await AWS.Cognito.UserPoolGroup("myUserPoolGroup", {
UserPoolId: "us-west-2_aBcDeFgHi",
GroupName: "Admins",
Description: "Administrators group with full access"
});

Configure a user pool group with a specific role and precedence:

const advancedUserPoolGroup = await AWS.Cognito.UserPoolGroup("adminUserPoolGroup", {
UserPoolId: "us-west-2_aBcDeFgHi",
GroupName: "SuperAdmins",
Description: "Super Administrators with elevated privileges",
RoleArn: "arn:aws:iam::123456789012:role/Cognito_SuperAdmin_Role",
Precedence: 1
});

If you want to adopt an existing user pool group instead of failing when it already exists, you can set the adopt property:

const adoptedUserPoolGroup = await AWS.Cognito.UserPoolGroup("existingUserPoolGroup", {
UserPoolId: "us-west-2_aBcDeFgHi",
GroupName: "ExistingGroup",
adopt: true // Adopts the existing resource
});

Demonstrate managing group members by using the RoleArn property to assign permissions:

const groupWithRole = await AWS.Cognito.UserPoolGroup("roleAssignedGroup", {
UserPoolId: "us-west-2_aBcDeFgHi",
GroupName: "Editors",
Description: "Editors group for content management",
RoleArn: "arn:aws:iam::123456789012:role/Cognito_Editor_Role"
});