class UserPoolDomain (construct)
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.Cognito.UserPoolDomain |
Java | software.amazon.awscdk.services.cognito.UserPoolDomain |
Python | aws_cdk.aws_cognito.UserPoolDomain |
TypeScript (source) | @aws-cdk/aws-cognito » UserPoolDomain |
Implements
IConstruct
, IConstruct
, IDependable
, IResource
, IUser
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
User
Pool Domain Props
Construct Props
Name | Type | Description |
---|---|---|
user | IUser | The user pool to which this domain should be associated. |
cognito | Cognito | Associate a cognito prefix domain with your user pool Either customDomain or cognitoDomain must be specified. |
custom | Custom | Associate a custom domain with your user pool Either customDomain or cognitoDomain must be specified. |
userPool
Type:
IUser
The user pool to which this domain should be associated.
cognitoDomain?
Type:
Cognito
(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.
customDomain?
Type:
Custom
(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.
Properties
Name | Type | Description |
---|---|---|
cloud | string | The domain name of the CloudFront distribution associated with the user pool domain. |
domain | string | The domain that was specified to be created. |
env | Resource | The environment this resource belongs to. |
node | Construct | The construct tree node associated with this construct. |
stack | Stack | The 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:
Resource
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:
Construct
The construct tree node associated with this construct.
stack
Type:
Stack
The stack in which this resource is defined.
Methods
Name | Description |
---|---|
apply | Apply the given removal policy to this resource. |
base | The URL to the hosted UI associated with this domain. |
sign | The URL to the sign in page in this domain using a specific UserPoolClient. |
to | Returns a string representation of this construct. |
static from | Import a UserPoolDomain given its domain name. |
RemovalPolicy(policy)
applypublic applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
Removal
Policy
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
).
Url(options?)
basepublic baseUrl(options?: BaseUrlOptions): string
Parameters
- options
Base
— options to customize baseUrl.Url Options
Returns
string
The URL to the hosted UI associated with this domain.
InUrl(client, options)
signpublic signInUrl(client: UserPoolClient, options: SignInUrlOptions): string
Parameters
- client
User
— [disable-awslint:ref-via-interface] the user pool client that the UI will use to interact with the UserPool.Pool Client - options
Sign
— options to customize signInUrl.In Url Options
Returns
string
The URL to the sign in page in this domain using a specific UserPoolClient.
String()
topublic toString(): string
Returns
string
Returns a string representation of this construct.
DomainName(scope, id, userPoolDomainName)
static frompublic static fromDomainName(scope: Construct, id: string, userPoolDomainName: string): IUserPoolDomain
Parameters
- scope
Construct
- id
string
- userPoolDomainName
string
Returns
Import a UserPoolDomain given its domain name.