Infrastructure as Code (IaC): Getting Started with Azure ARM Templates
Jeremiah Talamantes
Appsec @ Podium, Founder @ Compliiant.io, Founder @ Mitigated.io (Sold), Founder @ RedTeam Security (Sold), Author of Building Security Partner Programs, Social Engineer's Playbook and Physical Red Team Operations
You've likely heard about Infrastructure as Code (IaC). It's a powerful approach that allows us to manage and provision cloud resources using code and automation, like VMs, Databases, and Firewalls. One of the most popular tools for IaC is called Terraform by HashiCorp.
Other providers that fall into this category include CloudFormation by AWS and ARM Templates by Azure. Today, I'm diving deep into how you can get started with IaC using Microsoft Azure ARM Templates, with a particular focus on security.
What are ARM Templates?
At its core, Azure ARM (Azure Resource Manager) Templates are JSON files, but let's not oversimplify them. These files act as a master plan or, if you will, the DNA of your Azure cloud resources.
When we talk about Azure ARM Templates, again, we're diving into the realm of Infrastructure as Code (IaC). If you're new to IaC, think of it as writing code to manage and provision your infrastructures, similar to how you'd script software applications. So, instead of manually clicking through the Azure portal to set up a database, virtual machine, or any other service, you'd write a template in JSON format that describes your desired state, and Azure would make it happen.
But why are we so gung-ho about IaC? Here are some of its benefits:
In essence, Azure ARM Templates embody IaC for the Azure platform, allowing you to harness all the above benefits while optimizing your cloud infrastructure. It's a powerful tool in your tech arsenal, bridging the gap between development, operations, and security.
Setting up Your Environment
Before diving into the code, let's set up our environment:
# Install Azure CLI on macOS
brew update && brew install azure-cli
# On Linux
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
# On Windows, download the installer from the Azure website.
Creating Your First ARM Template
Here's a basic example of an ARM template that deploys a secure storage account:
To download this basic ARM Template refer to my Github repo below:
领英推荐
Here is a line-by-line description of this ARM Template:
In this template, we're deploying a storage account with the following security features:
Deploying the ARM Template
To deploy the template, use the Azure CLI:
az group create --name MyResourceGroup --location eastus
az deployment group create --resource-group MyResourceGroup --template-file /path_to_template/template.json
Security Best Practices
For Microsoft-approved ARM Templates, check out this Github repo:
Infrastructure as Code (IaC) with Azure ARM Templates is not just a nifty tool for DevOps; it's a game-changer for security professionals. Codifying our infrastructure can ensure that security is baked in from the start, and that's something we should be striving for.
Please visit my site, Compliiant.io, and share with your colleagues and friends. Cybersecurity Services as a Subscription with Compliiant.io means you only pay for the services you need and when you need them. Pause or cancel at any time without penalties or contracts.
Appsec @ Podium, Founder @ Compliiant.io, Founder @ Mitigated.io (Sold), Founder @ RedTeam Security (Sold), Author of Building Security Partner Programs, Social Engineer's Playbook and Physical Red Team Operations
1 年Here's a great video by John Savill on the topic: https://youtu.be/loxcA5MUf-I?si=xCCpUa5UEh_bUcuV