aws-cdk-lib.aws_cognito.UserPoolDomain

class UserPoolDomain (construct)

LanguageType name
.NETAmazon.CDK.AWS.Cognito.UserPoolDomain
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awscognito#UserPoolDomain
Javasoftware.amazon.awscdk.services.cognito.UserPoolDomain
Pythonaws_cdk.aws_cognito.UserPoolDomain
TypeScript (source)aws-cdk-lib » aws_cognito » UserPoolDomain

Implements IConstruct, IDependable, IResource, IUserPoolDomain

Define a user pool domain.

Example

const userpool = new cognito.UserPool(this, 'UserPool', {
  // ...
});
const client = userpool.addClient('Client', {
  // ...
  oAuth: {
    flows: {
      implicitCodeGrant: true,
    },
    callbackUrls: [
      'https://myapp.com/home',
      'https://myapp.com/users',
    ],
  },
});
const domain = userpool.addDomain('Domain', {
  // ...
});
const signInUrl = domain.signInUrl(client, {
  redirectUri: 'https://myapp.com/home', // must be a URL configured under 'callbackUrls' with the client
});

Initializer

new UserPoolDomain(scope: Construct, id: string, props: UserPoolDomainProps)

Parameters

  • scope Construct
  • id string
  • props UserPoolDomainProps

Construct Props

NameTypeDescription
userPoolIUserPoolThe user pool to which this domain should be associated.
cognitoDomain?CognitoDomainOptionsAssociate a cognito prefix domain with your user pool Either customDomain or cognitoDomain must be specified.
customDomain?CustomDomainOptionsAssociate a custom domain with your user pool Either customDomain or cognitoDomain must be specified.

userPool

Type: IUserPool

The user pool to which this domain should be associated.


cognitoDomain?

Type: CognitoDomainOptions (optional, default: not set if customDomain is specified, otherwise, throws an error.)

Associate a cognito prefix domain with your user pool Either customDomain or cognitoDomain must be specified.

See also: https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-assign-domain-prefix.html


customDomain?

Type: CustomDomainOptions (optional, default: not set if cognitoDomain is specified, otherwise, throws an error.)

Associate a custom domain with your user pool Either customDomain or cognitoDomain must be specified.

See also: https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-add-custom-domain.html

Properties

NameTypeDescription
cloudFrontDomainNamestringThe domain name of the CloudFront distribution associated with the user pool domain.
domainNamestringThe domain that was specified to be created.
envResourceEnvironmentThe environment this resource belongs to.
nodeNodeThe tree node.
stackStackThe stack in which this resource is defined.

cloudFrontDomainName

Type: string

The domain name of the CloudFront distribution associated with the user pool domain.


domainName

Type: string

The domain that was specified to be created.

If customDomain was selected, this holds the full domain name that was specified. If the cognitoDomain was used, it contains the prefix to the Cognito hosted domain.


env

Type: ResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.


node

Type: Node

The tree node.


stack

Type: Stack

The stack in which this resource is defined.

Methods

NameDescription
applyRemovalPolicy(policy)Apply the given removal policy to this resource.
baseUrl(options?)The URL to the hosted UI associated with this domain.
signInUrl(client, options)The URL to the sign in page in this domain using a specific UserPoolClient.
toString()Returns a string representation of this construct.
static fromDomainName(scope, id, userPoolDomainName)Import a UserPoolDomain given its domain name.

applyRemovalPolicy(policy)

public applyRemovalPolicy(policy: RemovalPolicy): void

Parameters

  • policy RemovalPolicy

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).


baseUrl(options?)

public baseUrl(options?: BaseUrlOptions): string

Parameters

  • options BaseUrlOptions — options to customize baseUrl.

Returns

  • string

The URL to the hosted UI associated with this domain.


signInUrl(client, options)

public signInUrl(client: UserPoolClient, options: SignInUrlOptions): string

Parameters

  • client UserPoolClient — [disable-awslint:ref-via-interface] the user pool client that the UI will use to interact with the UserPool.
  • options SignInUrlOptions — options to customize signInUrl.

Returns

  • string

The URL to the sign in page in this domain using a specific UserPoolClient.


toString()

public toString(): string

Returns

  • string

Returns a string representation of this construct.


static fromDomainName(scope, id, userPoolDomainName)

public static fromDomainName(scope: Construct, id: string, userPoolDomainName: string): IUserPoolDomain

Parameters

  • scope Construct
  • id string
  • userPoolDomainName string

Returns

  • IUserPoolDomain

Import a UserPoolDomain given its domain name.