Closed manzinger closed 7 months ago
@manzinger, what version are you using? could you also provide the code of the instantiation of the construct?
"cdk-nextjs-standalone": "^4.0.0-beta.17",
@manzinger, see here for the TSDoc that states that NextjsDomain
requires a Route53 hosted zone to have been created within the same AWS account. You should add a conditional check in your CDK code to only pass domainProps
when the hosted zone is in the same AWS account. Can you do that? Does that make sense to you?
I'm open to updating NextjsDomain
but I don't think it makes sense here. If you don't have NextjsDomain
create A or AAAA records then what is it's value? For scenarios where the hosted zone lives in another account, I think you should "eject" from this construct. Do you agree?
cc: @kevin-mitchell
@manzinger for my more complicated DNS needs (e.g. hosted zone I don't have control over to make records in) I just opt to skip the management within the Nextjs construct entirely. You can add the DNS records outside of the context of the Nextjs construct and then just pass the domain names (and certificate!) into the Nextjs Distribution configuration (these need to be set on the CF Distribution).
Personally I found this easier to manage in my head. To be honest I actually do this step (adding the A/AAAA name records) manually for production because it's something that rarely (never really) changes so it's not a huge lift. Then I use a domain name delegation record to "slice off" a subdomain for my lower environments.
Sorry this is probably not that useful / you probably are already aware you could do this, but this is how I avoid any issues with hosted zones in different accounts.
@manzinger, I'm going to close this issue as I think we've outlined above a way forward. If you think this is still an issue, please re-open. Thank you!
I have 2 Domains to deploy. One is in the same Account, the other one managed by DevOps via C-Name to the second one.
NextJs Construct is crashing because of Creating A Records in the wrong hosted Zone.
Solution 1:
Solution 2: