@@ -44,6 +44,7 @@ export interface CognitoProps {
4444 readonly cognitoCertificate : ICertificate
4545 readonly hostedZone : IHostedZone
4646 readonly useLocalhostCallback : boolean
47+ readonly useCustomCognitoDomain : boolean
4748}
4849
4950/**
@@ -64,25 +65,35 @@ export class Cognito extends Construct {
6465 removalPolicy : RemovalPolicy . DESTROY
6566 } )
6667
67- const userPoolDomain = new UserPoolDomain ( this , "UserPoolDomain" , {
68- userPool,
69- customDomain : {
70- domainName : props . fullCognitoDomain ,
71- certificate : props . cognitoCertificate
72- }
73- } )
68+ let userPoolDomain : UserPoolDomain
69+ if ( props . useCustomCognitoDomain ) {
70+ userPoolDomain = new UserPoolDomain ( this , "UserPoolDomain" , {
71+ userPool,
72+ customDomain : {
73+ domainName : props . fullCognitoDomain ,
74+ certificate : props . cognitoCertificate
75+ }
76+ } )
7477
75- new ARecord ( this , "UserPoolCloudFrontAliasIpv4Record" , {
76- zone : props . hostedZone ,
77- recordName : props . shortCognitoDomain ,
78- target : RecordTarget . fromAlias ( new UserPoolDomainTarget ( userPoolDomain ) )
79- } )
78+ new ARecord ( this , "UserPoolCloudFrontAliasIpv4Record" , {
79+ zone : props . hostedZone ,
80+ recordName : props . shortCognitoDomain ,
81+ target : RecordTarget . fromAlias ( new UserPoolDomainTarget ( userPoolDomain ) )
82+ } )
8083
81- new AaaaRecord ( this , "UserPoolCloudFrontAliasIpv6Record" , {
82- zone : props . hostedZone ,
83- recordName : props . shortCognitoDomain ,
84- target : RecordTarget . fromAlias ( new UserPoolDomainTarget ( userPoolDomain ) )
85- } )
84+ new AaaaRecord ( this , "UserPoolCloudFrontAliasIpv6Record" , {
85+ zone : props . hostedZone ,
86+ recordName : props . shortCognitoDomain ,
87+ target : RecordTarget . fromAlias ( new UserPoolDomainTarget ( userPoolDomain ) )
88+ } )
89+ } else {
90+ userPoolDomain = new UserPoolDomain ( this , "UserPoolDomain" , {
91+ userPool,
92+ cognitoDomain : {
93+ domainPrefix : props . shortCognitoDomain
94+ }
95+ } )
96+ }
8697
8798 // these are the endpoints that are added to user pool identity provider
8899 // note we override the token endpoint to point back to our custom token
0 commit comments