Hello guys, is it available some example code how ...
# sst
g
Hello guys, is it available some example code how to set a custom domain on SST? (api gateway custom domain)
f
sst.Api
construct uses HTTP API behind the scene. Try this: • create an ACM Certificate with DNS validation - https://docs.aws.amazon.com/cdk/api/latest/docs/aws-certificatemanager-readme.html#dns-validation • create an API Gateway DomainName - https://docs.aws.amazon.com/cdk/api/latest/docs/aws-apigatewayv2-readme.html#custom-domain
g
thanks Frank I'll try it
f
Np. Btw, is ur domain’s DNS on Route53?
g
yes it is
I have already an hosted zone, I fill get it and use it to create acm and domain
f
Yup. That’s good. On the first deployment, acm needs to verify the domain, it will take a bit longer.
d
hey @gio, not sure if you were able to solve this but is it possible for you to post your solution to this? Maybe even better, in the issue: https://github.com/serverless-stack/serverless-stack/issues/130
Trying to do the same thing but I've been stuck for awhile now. 😬 🙏
f
@David Marquez is your domain hosted on Route53?
d
Yup!
I'm currently guessing/reading the docs as to where I should set the domain in here. I already have the zone, cert, and domain setup.
Copy code
const api = new sst.Api(this, "Api", {
  routes: {
    "GET /": "src/webhook.hello",
    "POST /": "src/webhook.handler",
  },
});
f
@David Marquez Sorry, I was away from my mac.
I’m actually working on the PR right now to support custom domain for
sst.Api
.
Since ur domain is hosted on Route53, you will be able to do something like
Copy code
const api = new sst.Api(this, "Api", {
  domain: '<http://api.mydomain.com|api.mydomain.com>',
  routes: {
    "GET /": "src/webhook.hello",
    "POST /": "src/webhook.handler",
  },
});
I will try to cut a release tomorrow. Would that work for you timeline wise?
d
Wow, works for me @Frank. Thank you! 🙏
f
@gio @David Marquez Just release v0.9.7 with custom domain support for Api construct. Some examples here - https://docs.serverless-stack.com/constructs/Api#configuring-a-custom-domain To upgrade:
Copy code
$ npm install --save --save-exact @serverless-stack/cli@0.9.7 @serverless-stack/resources@0.9.7
g
Thanks @Frank, it was a must have feature 🎉
d
btw thank you so much @Frank for this! we're up and running now thanks to this and thanks to your work! 🙂