Terraform allows you to manage your infrastructure as code, which is a great solution if you want to manage PaaS or SaaS solutions. And with the release of the LabDigital Terraform provider for commercetools, you can manage the configuration of your commercetools projects. For pre-sales activities, I wanted to see if I could take this a step further and deploy a defined configuration with one single configuration file. My goal was to always have a defined setup with languages, countries, zones, tax rates, shipment methods and stores so that I could immediately start adding products to a cart and succeed with a checkout. In this article, I describe the published terraform module, the options for the various regions (EMEA, APAC and the US) and explain how to use it.
The challenge
When preparing for a demo, it is nice to have a common dataset to work from, especially if the demo is for an international audience. If switching between languages and countries is easy, you can align your demo story around the capabilities of the platform that will resonate most with the customer.
When looking at commercetools, it provides a large number of capabilities out of the box that can be used to illustrate the benefits of the platform, but all of them need to be configured. Configuring commercetools is not that complicated, but can be time-consuming and is repetitive work that can be avoided.
A couple of months ago, commercetools improved its 60-day Free Trial. Now, when you sign up you can choose a defined setup that allows you to start with sample data. This is a huge time saver and is very useful in helping evaluate commercetools.
Instead of choosing “start from scratch,” select the option to start with sample data. Hit continue and a project is created for you.
After a few seconds, your project is created, including a full “good store” dataset, customers, promotions and multiple international settings.
As a result, you’ll see a catalog with 117 products along with several categories, 6 customers, 2 product discounts and 2 cart discounts. This is an ideal starting point for an evaluation of commercetools!
In the preparation for a demo, you sometimes want to go a bit further. You want to be able to set up a defined international configuration that is tailored to the configuration of a specific customer. To make this happen, I used LabDigital’s Terraform commercetools provider to create a demo.
The end results
When I started experimenting with the commercetools LabDigital Terraform provider, I immediately saw the benefits of being able to create a configuration baseline. It allowed me to create a recipe that completely describes what a configuration should look like. That recipe can have several dependencies within itself. For instance, when setting up a store, that store can depend on a supply channel, and that supply channel will need to have some countries and languages configured.
For each country, I wanted to specify a country code, the languages, the currencies and tax rates, so that it would automatically provision an environment with one distribution channel and one supply channel for that country.
By using naming conventions, this could then simply become:
After a couple of experiments to figure out how Terraform modules work, I was able to create a reusable module to always produce a standard international setup. The only thing I had to provide was a starting script to tell Terraform to load the module:
Couple of things to note here:
The config file points to a .yaml file that holds the configuration you would like to provision.
The envpath points to a .env file that holds the client credentials to the commercetools project.
I also added support for shipment methods and configured a zone setup so that multiple zones are available for shipment methods, with shipment rates for the configured zones.
With this, you can provision an environment simply by performing the following actions:
This will load all the dependencies from the Terraform registry, including the demo provisioned.
This will compare the actual configuration with the desired configuration, and will show what will be changes in the target when applied.
This will apply the configuration to the target, leading to a fully configured commercetools project setup.
On GitHub, the following starting configurations are available:
The terraform module is published here: https://registry.terraform.io/modules/commercetools-demo/demoprovisioner/commercetools/latest
To explore all of the amazing capabilities of commecetools Composable Commerce solutions and experiment with the Terraform provider, sign up for our 60-Day Free Trial today.