Comments (9)
@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.
So I started looking at this, and started breaking apart the Route53 / ACM Certificate creation "stuff" from NextjsDistribution
, but realized two things:
- 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. - 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.
@kevin-mitchell, if it's legit from an AWS experience then I think we should allow it.
from cdk-nextjs.
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.
Splitting into 2 constructs sounds good to me because of the interdependency issue. Let me think on the naming.
from cdk-nextjs.
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.
Hey @kevin-mitchell,
could you try out #174 that does the work I outlined above?
from cdk-nextjs.
@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.
No worries, @kevin-mitchell! Thank you :)
from cdk-nextjs.
Related Issues (20)
- S3 cache directory should be shared between ssg/build time cache and isr/handler cache HOT 3
- Refactor open-next e2e tests to be compatible with Multi Site HOT 4
- Refactor Props Passing By Removing `NextjsBase`
- Add Default Security Headers
- error: ValidationException: 1 validation error detected: Value null at 'tableName' failed to satisfy constraint: Member must not be null HOT 8
- 403 on previous assets during deployment HOT 4
- Issue with deploying stacks with --exclusive flag
- Page with getStaticProps gets an invalid url error HOT 6
- Consider using native `node:crypto` to sign requests in sign-fn-url HOT 1
- Windows - Bundling fails due to wrong shell usage HOT 1
- CustomCDKBucketDeployment lambda - Exited with SIGKILL 9 HOT 8
- Cannot find package 'next' imported from /var/task/index.mjs" HOT 19
- bug: cdk destroy fails when open-next build is not present HOT 2
- Feature Request: Support GovCloud By Providing Option to Replace CloudFront with Api Gateway
- Upgrade to open-next v3
- Fix: Usage with PNPM on Windows
- Docs: Update README and examples/
- Skip creation of A and AAAA Records HOT 5
- When deploying the Distribution the CachePolicy creation returns 400 Bad request HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cdk-nextjs.