May 4, 2021, Web

How to automate nop deployment with Terraform?

Paweł Rudyk .NET developer

In these tough times of global pandemic, we can all experience advantages (and disadvantages) of internet shops. As we try to avoid crowds and public interiors for fear of disease, more and more of us tend to shop online – safely (and responsibly) staying at home.

Many of us decide to trade the opportunity to see, touch and test the product for possibility to buy from our own couch. We also take the risk and send our money to someone somewhere far away, so we can get our package delivered by a courier company to our front door or even better, to a parcel locker, where we can get it without a single interaction or even without touching the machine thanks to mobile solutions like our InPost app. 

No wonder, that many ecommerce businesses report that their revenue in the last months achieved an all time high. For many companies, digital transformation was a matter of life and death. We, at iteo, completely understand how important, if difficult, this may be. We can’t help but see this trend, supporting our partners to move their business online or improve their shops and websites to handle higher visitors count and meet ever-growing customer expectations.

What was the problem?

In order to achieve what we have planned, we use two approaches. Sometimes our clients need custom, tailor-made software. There can be many reasons, like top performance, complicated business processes or unique integrations, just to name a few. However, in many cases, ready, well checked solutions are more than enough. In such situations, we propose platforms like nopCommerce. It is no coincidence that in 2020 we became nopCommerce Gold Solution Partner. Our certified developers are ready to fit nop to our clients’ needs and prepare any integrations which are not available out of the box.

We always try to automate tedious, time consuming and error-prone tasks and thus, reduce costs. One of such tasks is software deployment. Recently, we’ve found an excellent way to handle it and we’d love to share our findings about Terraform.

How we handled it

Hashicorp’s Terraform is a new and completely separate software tool which is designed to create and maintain application infrastructure. Such helpers are often called IaaC, which stands for Infrastructure as a Code. In fact, Terraform does exactly that – it let’s you describe and save application environment in a form of specially formatted text. This code can be then shared, reused and deployed multiple times. Thanks to that, we can make nopCommerce deployments easier, faster and more reliable.

When it comes to choosing deployment approaches, we provide our partners with different options. Some of them choose an “on-premise” path to utilize existing infrastructure. Some, on the other hand, appreciate advantages of cloud solutions and follow popular trends of Infrastructure as a Service or Platform as a Service strategies. Usually, we suggest our partners to deploy their applications on Microsoft Azure cloud. We are convinced that Platform as a Service (PaaS) solutions are an optimal choice for nopCommerce deployment environment. While our team is experienced in that field and officially certified, advantages go far beyond that. One of the biggest benefits of PaaS is that developers get machines which are already prepared for work, because an operating system and basic software come preinstalled. What is more, we don’t need to worry about any software updates, regardless whether it’s a new functionality or critical security fix. There is no worry about the machine’s constant power supply, parts wear leading to failure or simple, yet very important, physical access restriction.

Another advantage of Azure is excellent support in Terraform. Hashicorp has created and supports an official “provider”. This package allows us to handle virtually any Azure service and absolutely all services required to deploy nopCommerce. Our typical setting consists of five elements.

  1. Heart and foundation of the whole system is an App Service, which hosts nopCommerce itself. We prefer this serverless approach over Virtual Machine because it’s really easy to maintain. Moreover, it offers effortless scalability in case when the application will need to handle more visitors.
  2. To store all data regarding products, orders, customers etc. we have also picked a cloud solution – Azure-based SQL Server instance. Thanks to nopCommerce support for MySQL in version 4.30 and PostgreSQL in 4.40, we also had several different choices with varying pricing and performance.
  3. We prefer to keep all nopCommerce graphics in a separate resource – Storage Account. It’s a perfect choice for this use, because of the “pay-as-you-go” approach. Fees depend only on used disk space. It is not required to declare and pay for usage in advance. Moreover, there is no need to monitor storage quota and upgrade service level over time.
  4. Our typical nopCommerce deployment also utilizes Keyvault. It is no surprise for us, as it is our internal standard not only for ecommerce, but for all cloud solutions. This virtually free service allows us to store all confidential configuration of this solution like passwords, security certificates, etc. We get access to finely-grained access control and Microsoft takes care of the rest – from deployment machine to data encryption. It is a perfect match for Terraform, because it can store access keys generated for other services. Another important advantage is that Keyvault becomes a so-called single source of truth. This term describes a central place which can hold important and trusted information. If we need to change some configuration at any point in the future, we will do that in a single place. Every connected service will just take this new value and everything will work as before.
  5. In order to simplify application maintenance in future, we often add additional resource called Application Insights. It is designed to collect and process diagnostic and statistical data about application and selected resources. Thanks to this data, we can later optimize our code, increase performance or even find potential UX issues. This service is also smoothly integrated with many Microsoft products, even with .NET platform. As you may have already guessed, nopCommerce, as an ASP.NET application, is no exception.

Pic. Typical nopCommerce Azure deployment components diagram

Architecture shown in the picture may look simple at the first glance. Truth be told, each icon in that scheme hides extensive, detailed and precise configuration like names, addresses, passwords, deployment regions, service levels and many, many more. Part of this configuration is unique to a given partner and deployment, while the rest of it is usually replicated. You may suspect that Terraform shines in the second one. In fact, this tool is useful in both cases. It allows us to reuse this shared part, which is usually very tedious and error-prone when copying. At the same time, Terraform gives us the opportunity to pass information prepared in advance, like a partner’s Azure subscription or website domain name.

Thanks to this approach we are able to launch a new, standard environment in a few minutes with a single command. It is really useful, when we need a new testing site for our QA department or a quick nopCommerce demo during a business presentation.

Challenges we had to face

Obviously, Terraform, as any other tool, also has some disadvantages. First drawback, which your dev team (or you) may experience, is that it is a completely separate tool. It is not related to nopCommerce or technologies they may be used to, like .NET or Javascript. No matter how skilled the team is, there are high chances that they will have to learn about Terraform and it’s Hashicorp Configuration Language (HCL in short) from the very beginning.

Next disadvantage is that this tool depends on packages called “providers”. Each provider consists of numerous definitions of objects which Terraform will be able to work with. For example, “azurerm” package is required to work with Microsoft Azure, as it contains models of all resources and services available (there are also around 1000 different providers). This additional layer of abstraction may cause a few problems. One of them is a delay needed to update a package with data of new and updated services. It is possible that you will find some providers to be outdated or obsolete. Far worse, you may not be able to find providers for less popular environments.

Another problem is that while Microsoft is very reliable and announces new solutions every now and then, this progress comes at a cost. Azure cloud (just like all other clouds: AWS, GCP etc.) is under constant development – their services come and go, or simply change. It may happen that configuration which was totally valid a few months ago, now results in an error because one of the resources requires additional configuration. Deployment scripts prepared for Terraform should be checked and maintained every few weeks to keep them up to date.


To sum up, we faced a problem of improving the nopCommerce deployment process. We found out that Hashicorp’s Terraform is a perfect choice for such cases, because while it has some flaws, it can dramatically simplify and speed up the deployment processes. Main reasons are the ability to reuse previous configurations and extremely short time needed to create a new nopCommerce instance. We usually choose Microsoft Azure cloud, however we are equally able to use this tool on AWS, Google Cloud Platform and many other environments.

One of the examples of nopCommerce Terraform deployment is our very own plugin shop. Feel free to check it out at Iteo Store website.