https://serverless-stack.com/ logo
#help
Title
# help
a

Austin

03/21/2022, 7:33 PM
Is it possible to configure multiple custom domains on the
sst.StaticSite
construct? I’m using it to build a multi-purpose reverse proxy/redirect engine for several of our domains. StaticSite provides some convenience I would like to leverage, but I also need the CloudFront distribution to allow multiple custom domains. When I configure it directly on the
cfDistribution
I get an error telling me to use
customDomain
on the
sst.StaticSite
but this doesn’t appear to allow multiple domains. Any suggestions?
t

thdxr

03/21/2022, 7:35 PM
are all the domains under the same root domain?
if yes you can use a wildcard
if not you can still do it but it's tricky. You'll have to create your own certificate for all the domains and then you can specify them all under
alternatNames
and pass in the cert you created
a

Austin

03/21/2022, 7:36 PM
No they are different TLDs.. I basically need to wildcard three different TLDs and point to the same cfDistribution
t

thdxr

03/21/2022, 7:36 PM
You might have an easier time generating 3 different staticsites pointing to the same directory
a

Austin

03/21/2022, 7:38 PM
I am creating the cert for all 3, but I’m not seeing a property for alternate names on the StaticSite construct directly. This is giving me an error:
Error: Do not configure the "cfDistribution.certificate". Use the "customDomain" to configure the StaticSite domain certificate.
I’m wondering if there is just a way I can override/ignore this error. Is there a specific reason this limitation is here?
t

thdxr

03/21/2022, 7:40 PM
ah you're doing things throuhg cdk directly there
you can try
Copy code
new sst.StaticSite(this, "Site", {
  customDomain: { alternateNames: [...], certificate: <cert> }
})
a

Austin

03/22/2022, 3:08 PM
Yeah I specifically don’t want the SST project to be managing the actual DNS records, which I think putting the configuration on StaticSite will do. Sounds like my options are either 3 static sites or don’t use StaticSite and configure everything directly with CDK
t

thdxr

03/22/2022, 3:53 PM
if you specify just alternate names it won't manage dns records
the cfn distribution just needs to know what they are
a

Austin

03/22/2022, 3:58 PM
domainName is a required property of customDomain on StaticSite
t

thdxr

03/22/2022, 4:07 PM
ah I see
3 Views