Automatic releasing of Terraform modules (per-repo-module)

3 min readJul 20

In this article I’m going to be covering how to use semantic-release to progamatically release new semantic versions when changes are made to a Terraform module stored in a GitHub repository.

This article does assume that you have a basic understanding of conventional commits, if not, I have an article on this here.

It’s also assumed that you have a repository configured already with some terraform in it that you are ready to release as a Terraform module. If you don’t.. You can use this demo repository as reference (

This article covers Terraform modules which are stored in a one-repository-per-module format, I’ll be following on from this article soon with another for automatic releasing of individual Terraform modules stored in a mono-repo of Terraform modules (more details at the end of this article).

Photo by Ankush Minda on Unsplash

Configuring the module repository

The first thing we will want to do in the repository, is create a package.json file with a few fields required for semantic-release:

"name": "terraform-demo-module",
"private": true,
"devDependencies": {
"@semantic-release/github": "^9.0.3",
"semantic-release": "^21.0.5"
"release": {
"branches": [
"plugins": [

To break this down:

name: The name of your module, this should be “release friendly” (Eg no spaces.
private: Stops semantic-release from trying to publish this module publically.
devDependencies: Pretty self explanatory but ensures that required packages are installed by npm on build
release: The branch on which to public releases from
plugins: Also “as it says on the tin” but plugins for semantic-release that we will be using to publish our releases.

Now that we have our package.json configured, we need to write up our workflow to run the release when a PR is merged into main branch (update as appropriate).