
This guide provides step-by-step instructions on how to automate the process of creating an SSL certificate using Amazon Certificate Manager (ACM) and configuring a subdomain using Serverless Domain Manager and using Route 53 Hosted Zone.
Pre Requisites:
- You need an AWS account.
- Have a little bit of knowledge of using Serverless Frameworks.
Firstly, you need to know that we’ll use some Serverless Framework plugins to turn our life easier:
- Serverless Domain Manager to control Route53 rules and API Gateway custom domain configs.
- Serverless Certificate Creator to create certificates on Amazon Certificate Manager and confirm by DNS method.
- Serverless Hosted Zone to create a Route53 hosted zone in AWS.
Install the Required Plugins
npm install --save-dev serverless-domain-manager serverless-certificate-creator serverless-hosted-zone
Serverless Template
plugins:
- serverless-domain-manager
- serverless-certificate-creator
- serverless-hosted-zone
custom:
enabled:
dev: false
production: true
customDomain:
domainName: ${env:API_DOMAIN}
basePath: ""
certificateName: mohammadhariszia.live
createRoute53Record: true
autoDomain: true
enabled: ${self:custom.enabled.${opt:stage, self:provider.stage}}
customCertificate:
certificateName: mohammadhariszia.live
hostedZoneNames: mohammadhariszia.live.
rewriteRecords: true
enabled: ${self:custom.enabled.${opt:stage, self:provider.stage}}
hostedZone:
name: mohammadhariszia.live.
Note: You can see that the template has been parameterized for running the custom domain and certificate for only the production environment.
Make sure to replace Certificate Name and add required variables in env.
Create Zone
serverless create-zone --stage production


Create Certificate
serverless create-cert --stage production


Important!
Open your Route53 and get the required NameServers of aws and add them to your domain manager. Secondly, check for the CNAME DNS record in your Route53 and add that to your domain manager as well.
Wait for 2–5 mins for AWS to verify your certificate.



Create Domain
serverless create_domain --stage production
Deploy
serverless deploy --stage production
And Voila! You have done it!
Originally published on Medium.
