UserPoolDomain L2 construct
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
});
userpool = cognito.UserPool(self, "UserPool")
client = userpool.add_client("Client",
# ...
o_auth=cognito.OAuthSettings(
flows=cognito.OAuthFlows(
implicit_code_grant=True
),
callback_urls=["https://myapp.com/home", "https://myapp.com/users"
]
)
)
domain = userpool.add_domain("Domain")
sign_in_url = domain.sign_in_url(client,
redirect_uri="https://myapp.com/home"
)
UserPool userpool = UserPool.Builder.create(this, "UserPool").build();
UserPoolClient client = userpool.addClient("Client", UserPoolClientOptions.builder()
// ...
.oAuth(OAuthSettings.builder()
.flows(OAuthFlows.builder()
.implicitCodeGrant(true)
.build())
.callbackUrls(List.of("https://myapp.com/home", "https://myapp.com/users"))
.build())
.build());
UserPoolDomain domain = userpool.addDomain("Domain", UserPoolDomainOptions.builder().build());
String signInUrl = domain.signInUrl(client, SignInUrlOptions.builder()
.redirectUri("https://myapp.com/home")
.build());
// Install: dotnet add package Amazon.CDK.Lib
var userpool = new UserPool(this, "UserPool", new UserPoolProps { });
var client = userpool.AddClient("Client", new UserPoolClientOptions {
// ...
OAuth = new OAuthSettings {
Flows = new OAuthFlows {
ImplicitCodeGrant = true
},
CallbackUrls = new [] { "https://myapp.com/home", "https://myapp.com/users" }
}
});
var domain = userpool.AddDomain("Domain", new UserPoolDomainOptions { });
var signInUrl = domain.SignInUrl(client, new SignInUrlOptions {
RedirectUri = "https://myapp.com/home"
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
userpool := cognito.NewUserPool(this, jsii.String("UserPool"), &UserPoolProps{
})
client := userpool.addClient(jsii.String("Client"), &UserPoolClientOptions{
// ...
OAuth: &OAuthSettings{
Flows: &OAuthFlows{
ImplicitCodeGrant: jsii.Boolean(true),
},
CallbackUrls: []*string{
jsii.String("https://myapp.com/home"),
jsii.String("https://myapp.com/users"),
},
},
})
domain := userpool.addDomain(jsii.String("Domain"), &UserPoolDomainOptions{
})
signInUrl := domain.SignInUrl(client, &SignInUrlOptions{
RedirectUri: jsii.String("https://myapp.com/home"),
})
Initializer
new UserPoolDomain(scope: Construct, id: string, props: UserPoolDomainProps)
UserPoolDomain(scope: Construct, id: str, props: UserPoolDomainProps)
new UserPoolDomain(Construct scope, String id, UserPoolDomainProps props)
new UserPoolDomain(Construct scope, string id, UserPoolDomainProps props)
NewUserPoolDomain(Scope Construct, Id *string, Props UserPoolDomainProps)
Construct Props
cognitoDomainCognitoDomainOptionscognito_domainCognitoDomainOptionscognitoDomainCognitoDomainOptionsCognitoDomainCognitoDomainOptionsCognitoDomainCognitoDomainOptions= not set if `customDomain` is spe…#default
Default: not set if customDomain is specified, otherwise, throws an error.
customDomainCustomDomainOptionscustom_domainCustomDomainOptionscustomDomainCustomDomainOptionsCustomDomainCustomDomainOptionsCustomDomainCustomDomainOptions= not set if `cognitoDomain` is sp…#default
Default: not set if cognitoDomain is specified, otherwise, throws an error.
managedLoginVersionManagedLoginVersionmanaged_login_versionManagedLoginVersionmanagedLoginVersionManagedLoginVersionManagedLoginVersionManagedLoginVersionManagedLoginVersionManagedLoginVersion= undefined - Cognito default sett…#This choice applies to all app clients that host services at the domain.
default
Default: undefined - Cognito default setting is ManagedLoginVersion.CLASSIC_HOSTED_UI
userPoolIUserPoolRefuser_poolIUserPoolRefuserPoolIUserPoolRefUserPoolIUserPoolRefUserPoolIUserPoolRefrequired#Properties
cloudFrontDomainNamestringcloud_front_domain_namestrcloudFrontDomainNameStringCloudFrontDomainNamestringCloudFrontDomainName*stringrequireddeprecated#This method creates a custom resource internally to get the CloudFront domain name.
cloudFrontEndpointstringcloud_front_endpointstrcloudFrontEndpointStringCloudFrontEndpointstringCloudFrontEndpoint*stringrequired#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.
envResourceEnvironmentenvResourceEnvironmentenvResourceEnvironmentEnvResourceEnvironmentEnvResourceEnvironmentrequired#notes
For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.
For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.
PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#userPoolDomainRefUserPoolDomainReferenceuser_pool_domain_refUserPoolDomainReferenceuserPoolDomainRefUserPoolDomainReferenceUserPoolDomainRefUserPoolDomainReferenceUserPoolDomainRefUserPoolDomainReferencerequired#Methods
applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#notes · 1 parameter
When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.
Parameters
strengthstrengthstrengthstrengthStrength— - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#notes
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?: BaseUrlOptions): stringdef base_url(self, options: typing.Optional[BaseUrlOptions] = None) -> strpublic String baseUrl(BaseUrlOptions options)public string BaseUrl(BaseUrlOptions? options = null)func BaseUrl(Options BaseUrlOptions) *string#1 parameter
Parameters
optionsoptionsoptionsoptionsOptions— options to customize baseUrl.
fromDomainName(scope: Construct, id: string, userPoolDomainName: string): IUserPoolDomain@staticmethod def from_domain_name(scope: Construct, id: str, user_pool_domain_name: str) -> IUserPoolDomainpublic static IUserPoolDomain fromDomainName(Construct scope, String id, String userPoolDomainName)public static IUserPoolDomain FromDomainName(Construct scope, string id, string userPoolDomainName)func FromDomainName(Scope Construct, Id *string, UserPoolDomainName *string) IUserPoolDomainstatic#isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#notes · 1 parameter · returns
Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.
Parameters
xxxxX— Any object.
Returns: true if x is an object created from a class which extends Construct.
isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#signInUrl(client: UserPoolClient, options: SignInUrlOptions): stringdef sign_in_url(self, client: UserPoolClient, options: SignInUrlOptions) -> strpublic String signInUrl(UserPoolClient client, SignInUrlOptions options)public string SignInUrl(UserPoolClient client, SignInUrlOptions options)func SignInUrl(Client UserPoolClient, Options SignInUrlOptions) *string#2 parameters
Parameters
clientclientclientclientClient— [disable-awslint:ref-via-interface] the user pool client that the UI will use to interact with the UserPool.optionsoptionsoptionsoptionsOptions— options to customize signInUrl.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.