Giter Site home page Giter Site logo

Comments (9)

kevin-mitchell avatar kevin-mitchell commented on June 3, 2024 1

@bestickley It's legit in terms of what I'm doing now, but I don't know if that means it's a common use case or frankly a "good" way of achieving my goal.

That said, I do think it's perfectly legitimate to want to allow this package to control the CloudFront Distribution but nothing in the Route53 / Certificate Manager side of things.

I might put together a small PR tomorrow (JST). I think I might have to add another configuration option though to BaseSiteDomainProps, which is perhaps not ideal - I'll take a look at least.

Thank you as always for your thoughts and time!

from cdk-nextjs.

kevin-mitchell avatar kevin-mitchell commented on June 3, 2024 1

So I started looking at this, and started breaking apart the Route53 / ACM Certificate creation "stuff" from NextjsDistribution, but realized two things:

  1. The isExternalDomain option, while not entirely obvious in my case (because the domain and certificate very much are on AWS, and the certificate itself is in the same account as I'm deploying NextJs to) resolves my issue as it basically just avoids doing anything requiring a hosted zone. So for now my issue is resolved by setting this.
  2. I do still think refactoring NextjsDistribution makes sense because it's doing quite a bit (as you pointed out @bestickley re: single responsibility principle), but there is a bit of a chicken and egg issue between the Distribution and the routes. You basically need to create the certificate and hosted zone first (hosted zone is required to be able to automatically do DNS validation of the certificate), then the distribution, THEN the actual Route53 DNS entries to hook up CloudFront.

This is fine i think, but I guess a follow up question is do you have any issue creating TWO new Constructs, something like (naming things is so hard :( )

NextjsDomain - validates inputs, if needed creates Hosted Zone and Certificate

and

NextjsRoute - adds the Route53 routes for the distribution, creates the redirects

I'm not sure if there is a better way to do this in terms of organizing the constructs.

from cdk-nextjs.

bestickley avatar bestickley commented on June 3, 2024

@kevin-mitchell, if it's legit from an AWS experience then I think we should allow it.

from cdk-nextjs.

bestickley avatar bestickley commented on June 3, 2024

Your use-case is not un-common. We should support this multi-account setup. I've thought before that domain/certificate logic should live outside NextjsDistribution for the sake of single responsibility principle. So if you think that makes sense I'd be open to a PR that adds a NextjsDomain that's more flexible and builds off the current solution and enables your use case.

Specifically, I'd like to see the methods: validateCustomDomainSettings, lookupHostedZone, createCertificate, and createRoute53Records moved outside NextjsDistribution into something like NextjsDomain. Additionally acm.DnsValidatedCertificate is deprecated which we're using so it would be good to "use Certificate instead" as it states in deprecation TSDoc.

from cdk-nextjs.

bestickley avatar bestickley commented on June 3, 2024

Splitting into 2 constructs sounds good to me because of the interdependency issue. Let me think on the naming.

from cdk-nextjs.

bestickley avatar bestickley commented on June 3, 2024

Or alternatively you could expose a public method addDnsRecords on a single construct, NextjsDomain, that accepts the CloudFront distribution? Something like this in top level Nextjs construct:

const nextjsDomain = new NextjsDomai(...);
const nextjsDistribution = new NextjsDistribution(...);
nextjsDomain.addDnsRecords(nextjsDistribution);

from cdk-nextjs.

bestickley avatar bestickley commented on June 3, 2024

Hey @kevin-mitchell,
could you try out #174 that does the work I outlined above?

from cdk-nextjs.

kevin-mitchell avatar kevin-mitchell commented on June 3, 2024

@bestickley I'll take a look this weekend if I can. I'm really sorry I didn't finish this, I actually started (just pushed a branch here: main...kevin-mitchell:cdk-nextjs:158-refactor-domain) but have been busy elsewhere the last two weeks.

I'll follow up ASAP.

from cdk-nextjs.

bestickley avatar bestickley commented on June 3, 2024

No worries, @kevin-mitchell! Thank you :)

from cdk-nextjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.