-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request - support custom domain in aws_cognito_user_pool_domain #5026
Comments
@eigilsagafos have you found any way to do this pragmatically (without using the AWS Console)? I have not been able to find the functionality exposed in any of their APIs or via the CLI. Would be awesome to see this as a functionality of terraform. |
@ajb3ck The AWS documentation is not updated as far as I know, but I inspected the traffic from the web dashboard and the only difference is that you pass the arn for the certificate. |
Just wanted to leave a note as the AWS Go SDK and Cognito API's have been updated to support this functionality. Would anyone be kind enough to pick up this effort? |
Support for a new |
This has been released in version 1.42.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
When creating a custom Cognito domain, the CloudFront distribution's DNS domain name is needed to create an alias record in Route 53. Looking at the docs, though, it doesn't appear that there is a data source for a Does anyone know if the domain name can be retrieved using the ARN in the output of this resource? For example, will the |
I stumbled upon the same problem as @myedibleenso. It would be great to have the configuration of the |
I was able to get my Cognito custom auth domain registered in Route53 with the following:
|
Thanks, @skehlet. Hardcoding the |
@mastertinner Just for my own understanding, why can't you hardcode the zone id for CloudFront? Is there a case where the |
Thanks, @skehlet. Based on the link you shared, it looks like CloudFront's Zone ID is always Curious to hear what others think of this proposal... |
@skehlet, sorry I didn't properly read the link you added. In that case, hardcoding the |
@skehlet, sorry for bothering you again. I stumbled upon another problem. When creating the two resources, there seems to be a circular dependency: resource "aws_route53_record" "auth" {
zone_id = "${aws_route53_zone.main.id}"
name = "auth"
type = "A"
alias {
name = "${aws_cognito_user_pool_domain.main.cloudfront_distribution_arn}"
zone_id = "Z2FDTNDATAQYW2" // See https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-route53-aliastarget.html
evaluate_target_health = true
}
}
resource "aws_cognito_user_pool_domain" "main" {
domain = "auth${var.resource_suffix}.${substr(aws_route53_zone.main.name, 0, length(aws_route53_zone.main.name) - 1)}"
certificate_arn = "${aws_acm_certificate_validation.cert.certificate_arn}"
user_pool_id = "${aws_cognito_user_pool.main.id}"
} If specified like that, Terraform will try to create the |
@mastertinner No worries, I think you're almost there, the issue is the parent domain ( I put a not-a-fully-working-app but hopefully good enough PoC up on github which creates the custom domain. Let me know if it helps. One thing relevant to what you pointed out, I had to add a |
I have the same problem as @mastertinner . It seems like my And yes I do have an A record for my base domain. |
Well, after struggling for a long time trying to setup a cognito user pool using custom domain I came to the conclusion that this feature is incomplete. Because of the nature of how AWS handle the custom domain creation, |
I have a working example here. Can you compare it to what you have? My custom cognito domain for the example is |
Hi @skehlet, thanks for your reply. I'm afraid I still didn't manage to fix the problem. Actually, my source code is quite similar to yours and I can't figure out the reason it doesn't work. Do you mind to take a look into my source code and the output log? Maybe a second pair of eyes would be great to figure out what is happening... https://gist.github.com/miere/4f2c7c253216f771e8dc63b9c6ae88b3 |
Hi @miere, I didn't finish looking through everything, but I saw your log (thank you for including!) and you ctrl-c'd after 17min, is this the problem you're seeing? When I was trying it, it really does take 30-45 minutes to finish. |
Unfortunately, 45 is a lot of time. I wonder how it would behave when I have to update my log in page, or need to change the Cognito's Pool configuration. Would my users face issues due to stale configuration? I'm not sure if I would have such a long maintenance window to apply these changes.
Not really, but let me share my thoughts with you:
I'll put a little more effort into this. Maybe, despite of my skepticism, I should wait more time to get it done. |
@skehlet As you've stated before, it took time (almost one hour) but it changed its status from CREATING to ACTIVE and therefore was able to assign a subdomain to it. I've also simulated a few changes on my User Pool and most of them were quite quick. That said, it is obvious that I was wrong about this issue being unfinished. Despite of that I'd like to leave a few suggestions in order to improve the developer experience whilst using this particular resource:
|
Hey @miere I'm glad you got it working! I think those are some valid points and would help people in the future. Related, there is one other big issue with Cognito custom domains for me, and that's the current hard limit of 4 custom domains per AWS account. I was originally planning on having one for each customer, but between that and the long time to provision, I have to figure out something else. AWS support told me to look into using API Gateway to reverse proxy Cognito's login page, which would avoid this limit, and might be faster to deploy too. Sounds unpleasant but doable. I haven't looked into it yet. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Community Note
Description
Custom domain support was launced by AWS in June 2018 but not supported by Terraform. There is a new arn param for a certificate and if there is a certificate provided then the domain param will be the full domain. Right now validateCognitoUserPoolDomain function won't accept that.
New or Affected Resource(s)
Potential Terraform Configuration
References
The text was updated successfully, but these errors were encountered: