Convert Figma logo to code with AI

hashicorp logoterraform-provider-azurerm

Terraform provider for Azure Resource Manager

4,512
4,598
4,512
2,898

Top Related Projects

The AWS Provider enables Terraform to manage AWS resources.

Terraform Provider for Google Cloud Platform

Terraform Kubernetes provider

20,922

Pulumi - Infrastructure as Code in any programming language 🚀

Quick Overview

The terraform-provider-azurerm repository is the official Terraform provider for Azure Resource Manager (ARM). It allows users to manage Azure resources using Terraform, an infrastructure-as-code tool. This provider enables the creation, modification, and deletion of Azure resources through declarative configuration files.

Pros

  • Comprehensive coverage of Azure services and resources
  • Regular updates to support new Azure features and services
  • Well-documented with extensive examples and guides
  • Strong community support and active development

Cons

  • Complex configuration for some advanced Azure features
  • Occasional breaking changes between major versions
  • Learning curve for users new to both Terraform and Azure
  • Some Azure-specific concepts may not translate perfectly to Terraform's declarative model

Code Examples

  1. Creating an Azure Resource Group:
resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "West Europe"
}
  1. Deploying an Azure Virtual Machine:
resource "azurerm_virtual_machine" "example" {
  name                  = "example-vm"
  location              = azurerm_resource_group.example.location
  resource_group_name   = azurerm_resource_group.example.name
  network_interface_ids = [azurerm_network_interface.example.id]
  vm_size               = "Standard_DS1_v2"

  storage_image_reference {
    publisher = "Canonical"
    offer     = "UbuntuServer"
    sku       = "18.04-LTS"
    version   = "latest"
  }

  storage_os_disk {
    name              = "myosdisk1"
    caching           = "ReadWrite"
    create_option     = "FromImage"
    managed_disk_type = "Standard_LRS"
  }

  os_profile {
    computer_name  = "hostname"
    admin_username = "testadmin"
    admin_password = "Password1234!"
  }

  os_profile_linux_config {
    disable_password_authentication = false
  }
}
  1. Creating an Azure Storage Account:
resource "azurerm_storage_account" "example" {
  name                     = "examplestorageaccount"
  resource_group_name      = azurerm_resource_group.example.name
  location                 = azurerm_resource_group.example.location
  account_tier             = "Standard"
  account_replication_type = "GRS"
}

Getting Started

To use the Azure Provider in your Terraform configuration:

  1. Install Terraform (https://www.terraform.io/downloads.html)
  2. Create a new Terraform configuration file (e.g., main.tf)
  3. Add the Azure provider block:
terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 3.0"
    }
  }
}

provider "azurerm" {
  features {}
}
  1. Authenticate with Azure (e.g., using Azure CLI or service principal)
  2. Add resources to your configuration file
  3. Run terraform init, terraform plan, and terraform apply

For detailed instructions, refer to the official documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs

Competitor Comparisons

The AWS Provider enables Terraform to manage AWS resources.

Pros of terraform-provider-aws

  • More mature and feature-rich due to AWS's longer presence in the cloud market
  • Larger community and more extensive documentation
  • Supports a wider range of AWS services and features

Cons of terraform-provider-aws

  • Can be more complex to use due to the vast number of resources and options
  • May require more frequent updates to keep up with rapid AWS service changes

Code Comparison

terraform-provider-aws:

resource "aws_instance" "example" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "t2.micro"
  tags = {
    Name = "ExampleInstance"
  }
}

terraform-provider-azurerm:

resource "azurerm_virtual_machine" "example" {
  name                  = "example-vm"
  location              = azurerm_resource_group.example.location
  resource_group_name   = azurerm_resource_group.example.name
  vm_size               = "Standard_DS1_v2"
  network_interface_ids = [azurerm_network_interface.example.id]
}

Both providers offer similar functionality for creating virtual machines, but the syntax and required parameters differ. The AWS provider typically requires fewer configuration options for basic resources, while the Azure provider often needs more explicit configuration, such as specifying the resource group.

Terraform Provider for Google Cloud Platform

Pros of terraform-provider-google

  • More comprehensive support for Google Cloud Platform (GCP) services
  • Better integration with GCP-specific features and APIs
  • Faster adoption of new GCP product releases and updates

Cons of terraform-provider-google

  • Steeper learning curve for users not familiar with GCP
  • Less extensive documentation compared to Azure provider
  • Fewer community-contributed examples and modules

Code Comparison

terraform-provider-google:

resource "google_compute_instance" "default" {
  name         = "test-instance"
  machine_type = "e2-medium"
  zone         = "us-central1-a"
}

terraform-provider-azurerm:

resource "azurerm_virtual_machine" "example" {
  name                  = "example-vm"
  location              = azurerm_resource_group.example.location
  resource_group_name   = azurerm_resource_group.example.name
  vm_size               = "Standard_DS1_v2"
}

The code examples show that while both providers allow for creating virtual machines, the syntax and required parameters differ. The Google provider typically requires fewer configuration options, while the Azure provider often needs more explicit resource group and location specifications.

Terraform Kubernetes provider

Pros of terraform-provider-kubernetes

  • Platform-agnostic, works with any Kubernetes cluster regardless of cloud provider
  • Offers more granular control over Kubernetes-specific resources and configurations
  • Supports custom resource definitions (CRDs) and custom operators

Cons of terraform-provider-kubernetes

  • Requires more in-depth knowledge of Kubernetes concepts and architecture
  • May need additional configuration for cloud-specific features or integrations
  • Less integrated with cloud provider-specific services and resources

Code Comparison

terraform-provider-kubernetes:

resource "kubernetes_deployment" "example" {
  metadata {
    name = "example-deployment"
  }
  spec {
    replicas = 3
    selector {
      match_labels = {
        app = "example"
      }
    }
    template {
      metadata {
        labels = {
          app = "example"
        }
      }
      spec {
        container {
          image = "nginx:1.7.8"
          name  = "example"
        }
      }
    }
  }
}

terraform-provider-azurerm:

resource "azurerm_kubernetes_cluster" "example" {
  name                = "example-aks"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  dns_prefix          = "exampleaks"

  default_node_pool {
    name       = "default"
    node_count = 1
    vm_size    = "Standard_D2_v2"
  }

  identity {
    type = "SystemAssigned"
  }
}
20,922

Pulumi - Infrastructure as Code in any programming language 🚀

Pros of Pulumi

  • Supports multiple programming languages (Python, JavaScript, Go, etc.) for infrastructure as code
  • Offers more flexibility and expressiveness through general-purpose languages
  • Provides built-in state management and secrets handling

Cons of Pulumi

  • Steeper learning curve for those unfamiliar with supported programming languages
  • Smaller community and ecosystem compared to Terraform
  • May require more setup and configuration for complex projects

Code Comparison

Terraform (Azure Resource Manager provider):

resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "West Europe"
}

Pulumi (Azure Native provider):

import pulumi_azure_native as azure_native

resource_group = azure_native.resources.ResourceGroup("example",
    resource_group_name="example-resources",
    location="West Europe"
)

Both examples create an Azure resource group, but Pulumi uses Python syntax while Terraform uses HCL (HashiCorp Configuration Language). Pulumi's approach allows for more complex logic and reusability within the code, while Terraform's HCL is more declarative and focused on infrastructure definition.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Terraform logo

Terraform Provider for Azure (Resource Manager)

The AzureRM Terraform Provider allows managing resources within Azure Resource Manager.

When using version 4.0 of the AzureRM Provider we recommend using the latest version of Terraform Core (the latest version can be found here).

Usage Example

# 1. Specify the version of the AzureRM Provider to use
terraform {
  required_providers {
    azurerm = {
      source = "hashicorp/azurerm"
      version = "=3.0.1"
    }
  }
}

# 2. Configure the AzureRM Provider
provider "azurerm" {
  # The AzureRM Provider supports authenticating using via the Azure CLI, a Managed Identity
  # and a Service Principal. More information on the authentication methods supported by
  # the AzureRM Provider can be found here:
  # https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs#authenticating-to-azure

  # The features block allows changing the behaviour of the Azure Provider, more
  # information can be found here:
  # https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/guides/features-block
  features {}
}

# 3. Create a resource group
resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "West Europe"
}

# 4. Create a virtual network within the resource group
resource "azurerm_virtual_network" "example" {
  name                = "example-network"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location
  address_space       = ["10.0.0.0/16"]
}

Developing & Contributing to the Provider

The DEVELOPER.md file is a basic outline on how to build and develop the provider while more detailed guides geared towards contributors can be found in the /contributing directory of this repository.