Hi, any idea how to add a custom domain to cognito...
# help
r
Hi, any idea how to add a custom domain to cognito user pool ? If there is an example, it would be best.
r
Thanks @manitej, is there any example of
Copy code
userPool.addDomain("customDomain", {
      customDomain: {
        domainName: '<http://auth.example.com|auth.example.com>',
        certificate: ...      },
    });
m
You've the certificate ARN and wanna use it here?
r
I don't, so I have to create one, seems also need to create A record, and the A record should point to my NextjsSite, so seems pretty complicated 😞
m
Do you have an external domain or from route 53?
r
route 53
f
Hey @ray, I don’t have an example at hand, but what you had there looks right
1. import cert
Copy code
const certificateArn = 'arn:aws:acm:us-east-1:123456789012:certificate/11-3336f1-44483d-adc7-9cd375c5169d';
const domainCert = certificatemanager.Certificate.fromCertificateArn(this, 'domainCert', certificateArn);
2. configure domain
Copy code
pool.addDomain('CustomDomain', {
  customDomain: {
    domainName: '<http://user.myapp.com|user.myapp.com>',
    certificate: domainCert,
  },
});
3. create a route 53 record
Copy code
new route53.ARecord(this, 'AliasRecord', {
  zone,
  target: route53.RecordTarget.fromAlias(new targets.UserPoolDomainTarget(domain)),
});
Just wrote these on the fly, might have some typo here and there