How To Use A Custom Domain With AWS Lambda And Serverless
This post assumes you have working knowledge of AWS Lambda and Serverless.
3 min readJun 2, 2020
Assumptions
- You have at least one working lambda being deployed with the Serverless Framework.
- You have a registered domain name on AWS Route 53.
- You have a wild card¹ SSL Certificate assigned to your domain from AWS Certificate Manager.
Once you have those three things we can proceed.
First, install the Serverless plugin serverless-domain-manager
.
yarn add -D serverless-domain-manager
npm install --save-dev serverless-domain-manager
Navigate to your serverless.yml
file and add the following:
plugins:
- serverless-domain-manager
custom:
customDomain:
domainName: <choose a subdomain>.<your custom domain>.com
basePath: ""
certificateName: "*.<your custom domain>.com"
createRoute53Record: true
For a wildcard SSL certificate you must have a subdomain. So where it says <choose a subdomain>
pick something. It can be anything alphanumeric, but it can’t be blank. For example yoyo.google.com
will work but google.com
will throw an error.