Skip to content
GitHubXDiscord

UserPoolDomain

The UserPoolDomain resource allows you to manage AWS Cognito UserPoolDomains for your user pools, enabling custom authentication flow and user experience.

Create a basic UserPoolDomain with required properties:

import AWS from "alchemy/aws/control";
const userPoolDomain = await AWS.Cognito.UserPoolDomain("myUserPoolDomain", {
UserPoolId: "us-west-2_aBcDeFgHi",
Domain: "mycustomdomain",
ManagedLoginVersion: 1 // Optional, specifies the version of managed login
});

Set up a UserPoolDomain with a custom domain configuration for enhanced branding:

const customDomainUserPool = await AWS.Cognito.UserPoolDomain("customDomainUserPool", {
UserPoolId: "us-east-1_jKlMnOpQr",
Domain: "mybrandeddomain",
CustomDomainConfig: {
CertificateArn: "arn:aws:acm:us-east-1:123456789012:certificate/abcd1234-efgh-5678-ijkl-123456789012"
}
});

Configure a UserPoolDomain to adopt an existing resource if it already exists:

const adoptUserPoolDomain = await AWS.Cognito.UserPoolDomain("adoptUserPoolDomain", {
UserPoolId: "us-west-2_xYzAbC",
Domain: "existingdomain",
adopt: true // Set to true to adopt existing resource
});

Create multiple UserPoolDomains for different environments, such as development and production:

const devUserPoolDomain = await AWS.Cognito.UserPoolDomain("devUserPoolDomain", {
UserPoolId: "us-west-2_devPoolId",
Domain: "dev.mycustomdomain"
});
const prodUserPoolDomain = await AWS.Cognito.UserPoolDomain("prodUserPoolDomain", {
UserPoolId: "us-west-2_prodPoolId",
Domain: "mycustomdomain"
});