nitrictech / nitric

Nitric is a multi-language framework for cloud applications with infrastructure from code.
https://nitric.io
Apache License 2.0
1.25k stars 52 forks source link

Support Custom URLS #391

Closed raksiv closed 1 year ago

raksiv commented 1 year ago

Developers would like to be able to configure custom urls for apis instead of using the auto generated addresses.

tjholm commented 1 year ago

Currently looking at implementing this at the providers, starting with the AWS provider. Because URLs will be expected to differ between environments this will be stack level configuration.

Proposal for AWS configuration:

name: my-aws-stack
provider: nitric/aws@0.30.0
region: ap-southeast-2

# Add a key for configuring apis
apis:
   # Target an API by its nitric name
   my-api-name:
      # provide a domain to be used for the api
      domain: test.example.com

Current assumptions for AWS is that the certificate for the domain will already be managed in ACM with a managed zone in route 53. Domains will be discovered by searching for the domain using the provided name to locate a valid certificate.

JimLundin commented 1 year ago

I am sure this will be a great addition!

If I may make a suggestion. I really like the way that sst does custom API domains, only expecting a hosted zone for the root domain and letting the certificate be managed by the stack docs. Although I suspect that you are already familiar with sst and how they manage these things so feel free to disregard if that is the case.

Also +1 for making it easy to change domain name based on env.

jyecusch commented 1 year ago

Hey @JimLundin thanks for the feedback! We'll look at adding the automated certificate management in another release, I think that's a great suggestion to make it easier to use. We'll likely release this proposed solution from @tjholm soon, let us know if you think we're missing anything else here.

tjholm commented 1 year ago

I've got an initial working implementation here: https://github.com/nitrictech/nitric/pull/468

Will definetely add more automation to this as we go, I think the cert automation make heaps of sense, can do this if we do the zone lookup first, this should also be compatible with the existing configuration. Requiring a hosted zone to exist in Route53 makes the most sense when deploying to AWS, running the automation under this assumption also simplifies things quite a bit :).

tjholm commented 1 year ago

Actually went ahead and automated the certificate creation in: https://github.com/nitrictech/nitric/pull/468 as it does simplify things quite a bit when we can assume that the parent domain is managed in route53.

tjholm commented 1 year ago

This is now available v0.30.0-rc.4 of the AWS provider for testing and feedback.

tjholm commented 1 year ago

Release in v0.30.0 AWS provider