Infrastructure as Code
Navdeep Singh Gill|14 - January - 2021
Subscription
Thanks for submitting the form.
As the name suggests, infrastructure as Code(IaC) is related to the codification of a given infrastructure. So in this blog, we will be going through what is IaC, what is the need for IaC, and when it comes to Azure, what do we have in store to achieve the IaC process.
Infrastructure as code is a provisioning & managing infrastructure like VM/EC2 VPC with code/configuration files. It allows us to treat infrastructure configuration and provisioning just like we handle application code, enabling us to version code in any popular SCM to take advantage of CI/CD pipelines easily.
Previously, infrastructure management & configuration was done manually. Each environment has its unique configuration, which was configured manually, and that led to several problems like:
Whereas IaC is idempotent, ensuring the same deployment results in a given environment.
Globally, 90% of fortune 500 have shown their belief in Azure to drive their business. It has various services to resolve business problems, from storage to AI/ML to IAM over a single platform. With IaC, Azure resources management gets way easier through configuration files with consistency, which ensures fewer errors & provides preciseness. The two important methods to implement IaC on Azure are:
To implement IaC on Azure, use Azure Resource Manager templates (ARM templates). It is a file written in json based on declarative syntax, which lets you define the state of the infrastructure you want to deploy without writing a sequence of commands to achieve that state.
In the ARM template, resources & their properties are specified for deployment. It is a native option for Azure.
ARM is compact with various features, making it an ideal choice for the IaC tool. Here are a few of them.
Azure Resource Manager service centralizes resource management, security & deployment via tags to enable users to create, modify & delete resources.
All requests from APIs, Azure tools or SDKs, and Resource Manager firstly get authenticated & authorized, then these requests are sent to the Azure service, which performs the requested action. All requests are handled via the same API, so you get consistent results.
Choosing ARM for IaC on Azure enables you with:
Limit the size of your template to 4 MB. This applies to the template's final state after expansion with iterative resources & values for variables & parameters. Also, each parameter file should be limited to 64 KB.
With further limitations:
Create a resource group in the same region as resources as it contains metadata of resources. If the resource group deployed in another region is temporarily unavailable, you won't be able to update resources in the resource group as metadata is unavailable.
Set the hard-coded value of the API version property for the resource type. While creating a new template, we recommend using the latest API version for a resource type to determine available values. When your template works as expected, the recommendation is to use the same API version so you don't worry about the changes.
It's a script that ensures best practices are followed in a given template. If the template isn't compatible with the best practices, it returns a list of warnings and suggested changes.
After ARM templates, the second most popular method to implement and use IaC principles on Azure is Terraform. It is the most popular and open-source tool provided by HashiCorp for infrastructure automation. It creates IaC for cloud providers like Azure, AWS, GCP with the same workflow. It helps in configuring, provisioning, and managing the infrastructure as code as it allows codification of infrastructure like VM, storage & other Azure resources through its configuration files. It enables developers to manage infrastructure with consistent tooling across various cloud platforms.
ReadA Complete Guide to Terraform - Open Source IaC tool
IaC is a process of representation and management of the infrastructure in the form of code that tends to be consistent & efficient. Additionally, Azure is one of the leading & reliable public CSP for IaC implementation due to its native service ARM template & its compatibility with open source tools like terraform.
Related resources
14 - October - 2021
Thanks for submitting the form.
Continuous Integration and Continuous Deployment Effectively