I am trying to set up different, custom domains in serverless with serverless-domain-manager
plugin.
I've followed this tutorial: https://serverless.com/blog/serverless-api-gateway-domain/
but the example doesn't show how to set up more than one custom domain.
In my serverless.yml
file I have:
plugins:
- serverless-domain-manager
custom:
customDomain:
basePath: ''
domainName: MY_DOMAIN_HERE
stage: dev
createRoute53Record: true
How can I add another domain? For example, for prod
stage?
Even though serverless.yml doesn't support conditional logic, it is possible to simulate conditions.
In serverless.yml
add:
custom:
domain:
dev: MY_DEV_DOMAIN
prod: MY_PROD_DOMAIN
customDomain:
basePath: ''
domainName: ${self:custom.domain.${opt:stage}}
stage: ${opt:stage}
createRoute53Record: true
Depending on the sls deploy --stage
parameter, either the dev
or prod
domain will be configured.
More info on conditional logic: https://forum.serverless.com/t/conditional-serverless-yml-based-on-stage/1763
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With