Is it possible to configure multiple custom domain...
# help
a
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
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
No they are different TLDs.. I basically need to wildcard three different TLDs and point to the same cfDistribution
t
You might have an easier time generating 3 different staticsites pointing to the same directory
a
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
ah you're doing things throuhg cdk directly there
you can try
Copy code
new sst.StaticSite(this, "Site", {
  customDomain: { alternateNames: [...], certificate: <cert> }
})
a
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
if you specify just alternate names it won't manage dns records
the cfn distribution just needs to know what they are
a
domainName is a required property of customDomain on StaticSite
t
ah I see