Serverless Framework + AWS: automatically creating certificate and domain for your app

This is a guide showing how you can automatically create an SSL certificate on Amazon Certificate Manager (ACM) and configure a subdomain on Route 53 Hosted Zone using Serverless Framework with some wonderful plugins.

Tiago Boeing
2 min readFeb 25, 2022

Before start:

Firstly, you need to know that we'll use some Serverless Framework plugins to turn our life easier:

Note: I’ll show some scripts using NodeJS, but Serverless Framework can be used on almost any language (to not say literally anywhere).

With this in mind, let's go ahead! Start installing dependencies:

npm install serverless-domain-manager serverless-certificate-creator -— save-dev

Create a custom domain section

I usually separate domains to allow customization for each one, it would be like this in my stack:

Of course, the certificate name is chosen by you. I only like to use the same name of the domain to keep easier to locate on ACM.

This is the way how I organize my apps, take this as an example to customize/start.

See our custom section:

Deploy

Take the following tips and tricks:

Deploying to another stage (not on the default: dev) you need to use the option --stage (read more here). As an example for the first time you can use:

# First deploy PROD stage serverless create-cert --stage=prodserverless deploy --stage=prod

It’s possible to manually generate a domain using serverless-domain-manager, you can do it using the command serverless create_domain, this isn’t needed if you have the autoDomain flag enabled (as mentioned earlier).

Complete stack

See the complete Serverless stack below.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Tiago Boeing
Tiago Boeing

Written by Tiago Boeing

🇧🇷 Staff Software Engineer | AWS Community Builder | ⌨ Works at one of the biggest health insurance companies in Brazil | @tiagoboeing

Responses (1)

What are your thoughts?

Great article Tiago! Anyone interested in getting started with Serverless Framework should check out our blog post: https://medium.com/@serverlessinc/getting-started-with-serverless-framework-759fe0142294