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
fix(serverless-component): when adding primary domain name to CloudFront distribution aliases, don't replace other aliases #658
fix(serverless-component): when adding primary domain name to CloudFront distribution aliases, don't replace other aliases #658
Conversation
…ont distribution aliases, don't replace other aliases
… CloudFront distribution aliases, don't replace other aliases (serverless-nextjs#658)" This reverts commit 4428d5c.
… CloudFront distribution aliases, don't replace other aliases (serverless-nextjs#658)" This reverts commit 4428d5c.
@dpowell actually now that I think about it I think this may have conflicts by appending to existing aliases, if managing using Otherwise if we don't want to use |
Planning to revert this change in next couple days to original behavior which should be more correct, @dpowell please do let me know if you have any issues or concerns. |
The push for the domain’s alias could be conditional on !contains, perhaps. It wasn’t clear to me that domain was optional, so I’ve been using domain for my “primary” (even though not using Route53 or ACM for it) and aliases for additional. Perhaps I just read too much into that and we could clarify in a docs setting about aliases to use only one or the other. |
Things work fine for me if I use only aliases, so if you'd prefer to require one or the other I think it's safe to revert this, add a validation and perhaps some documentation. If you'd prefer to support a mix I can work up a patch that safely adds aliases and domains if not already present in the distribution config. Should every deploy "true up" the list of aliases in the distribution with the domain+aliases from the serverless.yml, reverting any manual changes done directly to the distribution? Or just ensure that the current domain and aliases records are present, and if you want to change a previously configured-by-serverless alias you'd have to remove it manually? |
@dpowell, yeah, I think the component should manage and override all aliases if either It would be simpler to keep them separate in my opinion. Though I do realize some people may want the additional aliases - in that case, it's probably better to manage the domain outside of this component and then specify In a future release, we are hoping we can simplify much of this custom deployment logic by exploring proper IaC like CDK or CDK for Terraform. As good as Serverless framework is for Serverless functions, it's not as good as managing complex infra configurations as proper IaC tools. Plus, we've already mostly imported many of the packages (aws-cloudfront, domain) and updated custom logic for deploying ourselves. @danielcondemarin let me know if you have any thoughts on which you prefer. |
@dpowell created this to revert to original behavior: #731. Will do some more manual testing myself since there's no existing tests (another issue is open for adding domain tests) and will update docs in another commit. If you can, please pull and build this branch and see if it works well for you still. Thanks! |
@dphang Personally I think we should aim to "update" distribution settings rather than "overriding" whenever possible. This is particularly beneficial to those reusing the same distribution for next.js deployments and other APIs that may require different CNAMES etc. Hence why I raised #477 a while back. You're right though, it adds complexity and makes it more difficult to maintain. I think for now we should go with what you suggested and review it once we redo how deployments work in future. |
I missed this in ea180e6, where the domain alias being added to the distribution would overwrite aliases that were added when we create the distribution. Append the domain alias(es) to the list instead of creating a new Aliases.Items to preserve those.
There don't seem to be any tests for this component, so I manually verified running the built component locally. If I overlooked a test suite that should be updated, let me know.