Moving with speed and efficiency while retaining quality is a goal many engineering leaders and managers seek. They want a way to deploy code quickly and with a repeatable process. In the infrastructure and cloud world, that's typically done with infrastructure as code, sometimes called IaC.
Infrastructure-as-code tools range from general-purpose to those targeted for specific environments. Microsoft Azure cloud shops should compare Azure-focused approaches with those designed to work with any infrastructure, cloud or otherwise. Azure Bicep and Terraform are each an example of these categories of infrastructure-as-code methods.
Why infrastructure as code?
Infrastructure engineers and system administrators can deploy servers manually. It can take days to get an operating system installed, configure the services, install necessary applications and set up the networking on just one server. If organizations want to move faster, they need a way to remove manual processes and automate infrastructure deployments.
Infrastructure as code programmatically defines infrastructure, virtualization and clouds services using a configuration language. Configuration languages can be in the YAML or JSON general-purpose formats for programming or a purpose-driven new language developed alongside a tool, such as HashiCorp Configuration Language (HCL) for Terraform.
What used to be manual step-by-step processes has now turned automatic and repeatable via infrastructure as code. It takes far less time to deploy multiple servers with IaC than it would to deploy just one server manually.
Azure Bicep and Terraform are two of the products with features that can help an organization implement IaC.
Overview of Azure Bicep
Azure Bicep is a Microsoft-centric infrastructure-as-code domain-specific language (DSL) created to make IaC easier on Azure. Before Bicep, if you wanted to stay Microsoft-centric, you needed to use Azure Resource Manager (ARM) templates. ARM templates are a sophisticated way to do deployments, but a lot of engineers and technicians find the syntax confusing. To deploy something simple in Azure can be cumbersome and take more lines of code than it would in another infrastructure-as-code platform.
The primary benefit of using Azure Bicep inside of Azure is the move away from JSON. JSON was the way to write ARM templates, but Azure users wanted a simpler and declarative way to define resources. Azure Bicep reduces the time and complexity that it takes to create IaC compared to ARM templates.
Microsoft opted to create Bicep with an HCL-like syntax. It's not exactly HCL, but it should look and feel like HCL to engineers already used to Terraform.
If you're thinking about getting started with Azure Bicep, keep in mind that it is meant for Azure, and only Azure. If your IT organization runs or plans to run multi- or hybrid-cloud workloads, Azure Bicep won't be right for you.
Overview of Terraform
HashiCorp Terraform is a well-adopted infrastructure-as-code platform. Terraform users tout its simplistic nature in defining cloud, infrastructure and virtualization resources. It is a declarative and immutable way to define resources that you want to create, modify, update and delete using IaC.
To achieve its simplicity, Terraform moved away from JSON- and YAML-formatted IaC, and Ruby-based DSLs, to the functional-based HCL language. HCL is easy to read and write, and relatively straightforward.
Terraform, created and supported by HashiCorp, is open source. It can be used with any infrastructure setup, so it is multi-cloud and cross-functional. Terraform works with what it terms Providers, a set of code written in Go that has APIs available to interact with different resources. Providers are akin to libraries or modules in the programming world. The resources could be cloud services like Azure and AWS, a Cisco network, a VMware ESXi-based virtualization environment or another setup. Terraform users can create a Provider for a service or platform.
Azure Bicep vs. Terraform
To decide which IaC option you want to go with, consider how easy it would be to use and how exactly you would put it to work.
For something to deploy on more than one cloud, whether in a multi or hybrid-cloud scenario, your best bet is Terraform. Azure Bicep is Azure-specific, so you can use it only in Azure, not other clouds nor even other Microsoft platforms such as Hyper-V virtualization. Microsoft-based IT shops that have no intention to move to any other cloud find Azure Bicep a great choice. Organizations that want to automate deployments to any type of on-premises workloads, virtualization environments or other clouds should consider Terraform.
There are discrepancies between the syntax for the languages in Terraform and Bicep, but not a huge amount. Bicep isn't HCL, but it resembles it. Microsoft wanted the declarative Bicep syntax to be easy to read and easy to write, so ease of use is pretty comparable between the Bicep and Terraform.