Hi Team I need some help in configuring the base ...
# help
s
Hi Team I need some help in configuring the base URL/Custom domain for multiple stacks. We are creating multiple APIs using different stacks in a mono-repo solution and wanted to use a single base URL for all these stacks. in my case the domain is maintained by another parent account which we don't have access. For different environments (dev/qa), we have manually created certificate and custom domain(sub domain like dev-api-parentdomain.com) and manually requested to add the CName records and API gateway domain details in route53 parent account. So it will be bit difficult for me to create the custom domain as part of SST. So, When I am trying to add multiple APIS to custom domain in AWS console, I am getting the below error. Please let me know what is the best way to come across this issue. and is there a way we can do the multiple API mappings in the SST with existing custom domain. Note: With single API, this is working fine but when I am trying to add second one its throwing this issue and all these are HTTP end points.
f
Hey @Supriya N I’m sensing two things you are asking
How to configure Api’s custom domain when the root domain is in another AWS account?
The best way is to delegate the subdomain to the child account. Here are the step https://serverless-stack.com/chapters/share-route-53-domains-across-aws-accounts.html#delegate-domains-across-aws-accounts This way, u don’t have to manually create the certificate and Route 53 records.
How to map multiple Apis to the same domain?
In ur screenshot, the
Path
field is empty for both APIs. When it’s empty, you are mapping to the
/
root path. You need to provide a root path for each Api.
s
Thank you @Frank. one quick question is, as we don't have access to the parent domain account, it still needs manual intervention to add the sub domain NS records to Parent domain account like we did for certificate validation. So the the hosted zone/delegated domain creation still be a manual task right? Could you please share me some code examples if we can do this through SST.
@Frank I wanted to share the custom domain across multiple stacks, if I add the code like the below it throwing error saying that this already exists in other stack. Could you please tell me the best way to achieve this. If it is a mono repo solution, creating custom domain in stack1 needs to be used by stack2, stack 3 etc. customDomain: { domainName: "api.domain.com", hostedZone: "domain.com", path: "v1", }
f
Hey @Supriya N, you can pass stack 1's
api.cdk.domainName
to stack 2 and stack 3. Like this example https://docs.serverless-stack.com/constructs/Api#mapping-multiple-apis-to-the-same-domain
s
@Frank do we need to define any dependency between stacks, all my stacks are defined in index.ts like this and need to access the custom domain created in Stack1 in other stacks. Could you please suggest on this. new Stack1(app, "cp-stack"); new Stack2(app, "cp1-stack"); new Stack3(app, "cp2-stack");
I tried pass the api in the second stack and trying to read in another API as api.cdk.domainName which is giving me this error. new stack2(app, "loc-stack",{ api: stack1.api }); Cannot destructure property 'api' of 'props' as it is undefined.
@Frank could you please suggest on this