hey guys, using a custom domain and having some is...
# help
k
hey guys, using a custom domain and having some issues. // Create the API this.api = new sst.Api(this, "Api", { customDomain: scope.stage === "prod" ? "example.com" : undefined, ... // Show the API endpoint in the output this.addOutputs({ ApiEndpoint: this.api.customDomainUrl || this.api.url, }); I can see the hosted zone in route 53 and it looks fine, but i get this error running npx sst deploy --stage prod [Error at /prod-Example-api/Api] Found zones: [] for dns:com, privateZone:undefined, vpcId:undefined, but wanted exactly 1 zone Found errors It seems you are configuring custom domains for you URL. And SST is not able to find the hosted zone "com" in your AWS Route 53 account. Please double check and make sure the zone exists, or pass in a different zone. Any ideas? 🙂
a
Should work like this, I have the same setup and it works. There is probably an issue with your hosted zone setup in AWS, maybe check what the "Test Record" functionality spits out
k
this?
a
Just to make sure, you don't really have "example.com" in the config file, right?
k
haha i have my domain there 🙂
a
hmmm, the tool result looks fine I guess
k
yeah... the account has full admin so dont think its permission related
a
would probably be a different message
is it a public hosted zone?
mine says Type: Public
k
Type Public hosted zone
pointing at aws ns (awsdns)
i have a NS and SOA record
do i need to create any record for the .com ? like www. or something? 🙂
a
I have an A record for api.mydomain.com, which is also what I use in SST config
k
that sounds like something
which sst config is that?
a
the one you pasted in OP
are you 100% sure that you didn't add the hosted zone in a different aws account than what SST uses?
because otherwise I'm out of ideas
k
i think i will explore the arecord and sst config you mentioned - it sounds like something
a
you seem to have an A record for your domain that you are also using in the SST config, so I guess it should work
nah that's just what you already have
k
how did your a record for api.mydomain.com create? does npx sst deploy --stage prod create that or do you have to do that manually the first time?
a
I think I did it manually
k
hmm
im guessing you must have used a static ip too to point the record at? 🙂
a
maybe delete and rewrite the line with scope.stage in your SST config, it's weird that it's trying to find the hosted zone "com" and not your actual domain...maybe there is a weird invisible character in there that breaks it
hmmmm, actually that mask for the A record looks unfamiliar...let me look up how I might have done it
k
ok sure thanks
a
I think I didn't create it manually after all, I'm pretty sure I followed this: https://serverless-stack.com/chapters/custom-domains-in-serverless-apis.html
k
i think i got it
a
what was it?
k
scope.stage === "prod" ? "example.com" doesnt work it has to be like this scope.stage === "prod" ? "api.example.com" which makes sense for an api gateway
a
hmmm, that does sound a bit like a bug, though, like it always assumes a subdomain and then just strips the string before the dot to find the hosted zone
k
i remember something to do with i forget what its called but the "domain bit segments" It wouldnt make sense to deploy my API to the place of my website too though
a
yeah, I guess it's not very common to host an api at "example.com"
k
thanks alot though, it was your api.myexample that gave me the clue, i was originally following that document but got caught up in creating stages for my urls for test and dev too
i was like oh i need dev.my.com and test.my.com and prod would be my.com
a
haha, I know the feeling, lots of new stuff to do, can easily get lost
k
hehe
a
if test.api.my.com doesn't work, you could try test-api.my.com or something
I'm not saying it won't work, but it could be a similar behaviour
k
will do. now i just need to figure out how i point my frontend bit to my.com 😄
oh it uses customdomain too?
a
you make a FrontendStack and use sst.ReactStaticSite for example
k
yeah followed that, but its how you point that to your .com
a
Not sure how you do it with other frameworks, there might be other sst. constructs for that
k
i think it might be the customDomain bit again but in the frontend stack. lets see fingers crossed 🙂
a
k
ah nice one
close! just cant get past this cname problem on the react frontend bit lol
prod-OxyDjinn-frontend | CREATE_FAILED | AWS:CloudFront:Distribution | ReactSiteRedirectRedirectDistributionCFDistribution985B2C47 | Resource handler returned message: "Invalid request provided: One or more of the CNAMEs you provided are already associated with a different resource. (Service: CloudFront, Status Code: 409, Request ID: 3a21b379-3afc-4f33-a9c1-195991ffd3ce)" (RequestToken: bff0e9bf-ac31-bbce-5769-3f5f3f040bad, HandlerErrorCode: InvalidRequest)
f
@Kristian Lake @Adrian Schweizer hey guys thanks for digging into this one. I just tried it on my end, and I can confirm the hosted zone look up is a bug.
Currently the
Api
construct assumes the domain always had a subdomain.
k
thanks Frank
f
Let me follow up on the
AWS::CloudFront::Distribution
issue in the thread below.