Link Search Menu Expand Document

azurerm

azurerm_app_service_plan/simple/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: A simple Azure App Service Plan

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_simple_app_service_plan_resource_group" {
  name     = "changeme-simple-app-service-plan-resource-group"
  location = "West Europe"
}

# Storage Account within the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account
resource "azurerm_storage_account" "changeme_simple_app_service_plan_storage_account" {
  name                     = "changemesimpleaspsaname"
  resource_group_name      = azurerm_resource_group.changeme_simple_app_service_plan_resource_group.name
  location                 = azurerm_resource_group.changeme_simple_app_service_plan_resource_group.location
  account_tier             = "Standard"
  account_replication_type = "LRS"
}

# App Service Plan within the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/app_service_plan
resource "azurerm_app_service_plan" "changeme_simple_app_service_plan" {
  name                = "changeme-simple-app-service-plan-name"
  location            = azurerm_resource_group.changeme_simple_app_service_plan_resource_group.location
  resource_group_name = azurerm_resource_group.changeme_simple_app_service_plan_resource_group.name

  sku {
    tier = "Standard"
    size = "S1"
  }
}
 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_container_group/simple/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: A simple Azure Container Group

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_simple_container_group_resource_group" {
  name     = "changeme-simple-kubernetes-cluster-resource-group"
  location = "West Europe"
}

# Container Group within the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/container_group
resource "azurerm_container_group" "changeme_simple_container_group" {
  name                = "changeme-simple-container-group"
  location            = azurerm_resource_group.changeme_simple_container_group_resource_group.location
  resource_group_name = azurerm_resource_group.changeme_simple_container_group_resource_group.name

  os_type = "Linux"

  container {
    name   = "hello-world"
    image  = "microsoft/aci-helloworld:latest"
    cpu    = "0.5"
    memory = "1.5"

    ports {
      port     = 443
      protocol = "TCP"
    }
  }
}
 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_container_registry/simple/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: A simple Azure Container Registry

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_simple_container_registry_resource_group" {
  name     = "changeme-simple-container-registry-resource-group"
  location = "West Europe"
}

# Container Registry within the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/container_registry
resource "azurerm_container_registry" "changeme_simple_container_registry" {
  name                = "changemesimplecontainerregistry"
  resource_group_name = azurerm_resource_group.changeme_simple_container_registry_resource_group.name
  location            = azurerm_resource_group.changeme_simple_container_registry_resource_group.location
  sku                 = "Standard"
}
 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_cosmosdb_account/simple/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: A simple Azure CosmosDB Account

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_simple_cosmosdb_account_resource_group" {
  name     = "changeme-simple-cosmosdb-account-resource-group"
  location = "West Europe"
}

# CosmosDB account in the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cosmosdb_account
resource "azurerm_cosmosdb_account" "changeme_simple_cosmosdb_account" {
  name                = "simple-cosmosdb-account-name"
  location            = azurerm_resource_group.changeme_simple_cosmosdb_account_resource_group.location
  resource_group_name = azurerm_resource_group.changeme_simple_cosmosdb_account_resource_group.name
  offer_type          = "Standard"
  kind                = "GlobalDocumentDB"

  geo_location {
    location          = azurerm_resource_group.changeme_simple_cosmosdb_account_resource_group.location
    failover_priority = 0
  }

  consistency_policy {
    consistency_level       = "BoundedStaleness"
    max_interval_in_seconds = 10
    max_staleness_prefix    = 200
  }
}
 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_cosmosdb_cassandra_keyspace/simple/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: A simple Azure CosmosDB Cassandra Keyspace
# Explanation: A Cassandra Keyspace is equivalent to a Database in RDBMS's

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_simple_cosmosdb_cassandra_keyspace_resource_group" {
  name     = "changeme-simple-cosmosdb-cassandra-keyspace-resource-group"
  location = "West Europe"
}

# CosmosDB account in the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cosmosdb_account
# Explanation: Cassandra API must be explicitly enabled at the account level
resource "azurerm_cosmosdb_account" "changeme_simple_cosmosdb_cassandra_keyspace_cosmosdb_account" {
  name                = "changeme-simple-cck-cosmosdb-account-name"
  location            = azurerm_resource_group.changeme_simple_cosmosdb_cassandra_keyspace_resource_group.location
  resource_group_name = azurerm_resource_group.changeme_simple_cosmosdb_cassandra_keyspace_resource_group.name
  offer_type          = "Standard"
  kind                = "GlobalDocumentDB"

  geo_location {
    location          = azurerm_resource_group.changeme_simple_cosmosdb_cassandra_keyspace_resource_group.location
    failover_priority = 0
  }

  capabilities {
    name = "EnableCassandra"
  }

  consistency_policy {
    consistency_level       = "BoundedStaleness"
    max_interval_in_seconds = 10
    max_staleness_prefix    = 200
  }
}

# Cassandra Keyspace in the CosmosDB Account
# Explanation: Throughput is optional, but recommended since it can't be changed by Terraform if not set at creation
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cosmosdb_cassandra_keyspace
resource "azurerm_cosmosdb_cassandra_keyspace" "changeme_simple_cosmosdb_cassandra_keyspace" {
  name                = "changeme-simple-cosmosdb-cassandra-keyspace-name"
  resource_group_name = azurerm_resource_group.changeme_simple_cosmosdb_cassandra_keyspace_resource_group.name
  account_name        = azurerm_cosmosdb_account.changeme_simple_cosmosdb_cassandra_keyspace_cosmosdb_account.name
  throughput          = 400
}
 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_cosmosdb_gremlin_database/simple/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: A simple Azure CosmosDB Gremlin Database

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_simple_cosmosdb_gremlin_database_resource_group" {
  name     = "changeme-simple-cosmosdb-gremlin-database-resource-group"
  location = "West Europe"
}

# CosmosDB account in the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cosmosdb_account
resource "azurerm_cosmosdb_account" "changeme_simple_cosmosdb_gremlin_database_cosmosdb_account" {
  name                = "changeme-simple-cgd-cosmosdb-account-name"
  location            = azurerm_resource_group.changeme_simple_cosmosdb_gremlin_database_resource_group.location
  resource_group_name = azurerm_resource_group.changeme_simple_cosmosdb_gremlin_database_resource_group.name
  offer_type          = "Standard"
  kind                = "GlobalDocumentDB"

  geo_location {
    location          = azurerm_resource_group.changeme_simple_cosmosdb_gremlin_database_resource_group.location
    failover_priority = 0
  }

  capabilities {
    name = "EnableGremlin"
  }

  consistency_policy {
    consistency_level       = "BoundedStaleness"
    max_interval_in_seconds = 10
    max_staleness_prefix    = 200
  }
}

# Gremlin Database in the CosmosDB Account
# Explanation: Throughput is optional, but recommended since it can't be changed by Terraform if not set at creation
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cosmosdb_gremlin_database
resource "azurerm_cosmosdb_gremlin_database" "changeme_simple_cosmosdb_gremlin_database" {
  name                = "changeme-simple-cosmosdb-gremlin-database-name"
  resource_group_name = azurerm_resource_group.changeme_simple_cosmosdb_gremlin_database_resource_group.name
  account_name        = azurerm_cosmosdb_account.changeme_simple_cosmosdb_gremlin_database_cosmosdb_account.name
  throughput          = 400
}
 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_cosmosdb_mongo_database/simple/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: A simple Azure CosmosDB MongoDB Database

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_simple_cosmosdb_mongo_database_resource_group" {
  name     = "changeme-simple-cosmosdb-mongo-database-resource-group"
  location = "West Europe"
}

# CosmosDB account in the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cosmosdb_account
resource "azurerm_cosmosdb_account" "changeme_simple_cosmosdb_mongo_database_cosmosdb_account" {
  name                = "changeme-simple-cmd-cosmosdb-account-name"
  location            = azurerm_resource_group.changeme_simple_cosmosdb_mongo_database_resource_group.location
  resource_group_name = azurerm_resource_group.changeme_simple_cosmosdb_mongo_database_resource_group.name
  offer_type          = "Standard"
  kind                = "MongoDB"

  geo_location {
    location          = azurerm_resource_group.changeme_simple_cosmosdb_mongo_database_resource_group.location
    failover_priority = 0
  }

  consistency_policy {
    consistency_level       = "BoundedStaleness"
    max_interval_in_seconds = 10
    max_staleness_prefix    = 200
  }
}

# MongoDB Database in the CosmosDB Account
# Explanation: Throughput is optional, but recommended since it can't be changed by Terraform if not set at creation
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cosmosdb_mongo_database
resource "azurerm_cosmosdb_mongo_database" "changeme_simple_cosmosdb_mongo_database" {
  name                = "changeme-simple-cosmosdb-mongo-database-name"
  resource_group_name = azurerm_resource_group.changeme_simple_cosmosdb_mongo_database_resource_group.name
  account_name        = azurerm_cosmosdb_account.changeme_simple_cosmosdb_mongo_database_cosmosdb_account.name
  throughput          = 400
}
 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_cosmosdb_sql_database/simple/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: A simple Azure CosmosDB SQL Database

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_simple_cosmosdb_sql_database_resource_group" {
  name     = "changeme-simple-cosmosdb-sql-database-resource-group"
  location = "West Europe"
}

# CosmosDB account in the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cosmosdb_account
resource "azurerm_cosmosdb_account" "changeme_simple_cosmosdb_sql_database_cosmosdb_account" {
  name                = "changeme-simple-csd-cosmosdb-account-name"
  location            = azurerm_resource_group.changeme_simple_cosmosdb_sql_database_resource_group.location
  resource_group_name = azurerm_resource_group.changeme_simple_cosmosdb_sql_database_resource_group.name
  offer_type          = "Standard"
  kind                = "GlobalDocumentDB"

  geo_location {
    location          = azurerm_resource_group.changeme_simple_cosmosdb_sql_database_resource_group.location
    failover_priority = 0
  }

  consistency_policy {
    consistency_level       = "BoundedStaleness"
    max_interval_in_seconds = 10
    max_staleness_prefix    = 200
  }
}

# SQL Database in the CosmosDB Account
# Explanation: Throughput is optional, but recommended since it can't be changed by Terraform if not set at creation
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cosmosdb_sql_database
resource "azurerm_cosmosdb_sql_database" "changeme_simple_cosmosdb_sql_database" {
  name                = "changeme-simple-cosmosdb-sql-database-name"
  resource_group_name = azurerm_resource_group.changeme_simple_cosmosdb_sql_database_resource_group.name
  account_name        = azurerm_cosmosdb_account.changeme_simple_cosmosdb_sql_database_cosmosdb_account.name
  throughput          = 400
}
 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_dns_zone/simple/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: A simple Azure DNS Zone

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_simple_dns_zone_resource_group" {
  name     = "changeme-simple-dns-zone-resource-group"
  location = "West Europe"
}

# DNS Zone in the Resource Group
# Explanation: Note that this is a public DNS Zone, private ones are a separate resource called azurerm_private_dns_zone
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/dns_zone
resource "azurerm_dns_zone" "changeme_simple_dns_zone" {
  name                = "changeme-simple-dns-zone.com"
  resource_group_name = azurerm_resource_group.changeme_simple_dns_zone_resource_group.name
} 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_function_app/simple/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: A simple Azure Function App

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_simple_function_app_resource_group" {
  name     = "changeme-simple-function-app-resource-group"
  location = "West Europe"
}

# Storage Account within the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account
resource "azurerm_storage_account" "changeme_simple_function_app_storage_account" {
  name                     = "changemesfasaname"
  resource_group_name      = azurerm_resource_group.changeme_simple_function_app_resource_group.name
  location                 = azurerm_resource_group.changeme_simple_function_app_resource_group.location
  account_tier             = "Standard"
  account_replication_type = "LRS"
}

# App Service Plan within the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/app_service_plan
resource "azurerm_app_service_plan" "changeme_simple_function_app_app_service_plan" {
  name                = "changeme-simple-function-app-app-service-plan-name"
  location            = azurerm_resource_group.changeme_simple_function_app_resource_group.location
  resource_group_name = azurerm_resource_group.changeme_simple_function_app_resource_group.name

  sku {
    tier = "Standard"
    size = "S1"
  }
}

# Function App using the App Service Plan backed by the Storage Account
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/function_app
resource "azurerm_function_app" "changeme_simple_function_app" {
  name                       = "changeme-simple-function-app-name"
  location                   = azurerm_resource_group.changeme_simple_function_app_resource_group.location
  resource_group_name        = azurerm_resource_group.changeme_simple_function_app_resource_group.name
  app_service_plan_id        = azurerm_app_service_plan.changeme_simple_function_app_app_service_plan.id
  storage_account_name       = azurerm_storage_account.changeme_simple_function_app_storage_account.name
  storage_account_access_key = azurerm_storage_account.changeme_simple_function_app_storage_account.primary_access_key
}
 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_kubernetes_cluster/simple/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: A simple Azure Kubernetes Cluster
# Explanation: Also known as Azure Kubernetes Service (AKS)

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_simple_k8s_rg" {
  name     = "changeme-simple-k8s-rg"
  location = "West Europe"
}

# Kubernetes Cluster within the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/kubernetes_cluster
resource "azurerm_kubernetes_cluster" "changeme_simple_k8s" {
  name                = "changeme-simple-k8s"
  location            = azurerm_resource_group.changeme_simple_k8s_rg.location
  resource_group_name = azurerm_resource_group.changeme_simple_k8s_rg.name

  dns_prefix = "changeme-simple-k8s-dns-prefix"

  identity {
    type = "SystemAssigned"
  }

  default_node_pool {
    name       = "changeme"
    node_count = 1
    vm_size    = "Standard_DS2_v2"
  }
}
 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_lb/simple/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: A simple Azure Load Balancer

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_simple_load_balancer_resource_group" {
  name     = "changeme-simple-load-balancer-resource-group-name"
  location = "West Europe"
}

# Public IP within the Resource Group
# Explanation: Note that the location of the Public IP does not need to match the location of the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/public_ip
resource "azurerm_public_ip" "changeme_simple_load_balancer_public_ip" {
  name                = "changeme-simple-load-balancer-public-ip-name"
  location            = "West US"
  resource_group_name = azurerm_resource_group.changeme_simple_load_balancer_resource_group.name
  allocation_method   = "Static"
}

# Load Balancer with the Public IP assigned
# Explanation: The location of the Public IP and the Load Balancer should preferably match
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/lb
resource "azurerm_lb" "changeme_simple_load_balancer" {
  name                = "changeme-simple-load-balancer-name"
  location            = "West US"
  resource_group_name = azurerm_resource_group.changeme_simple_load_balancer_resource_group.name

  frontend_ip_configuration {
    name                 = "changeme-simple-load-balancer-frontend-ip-config"
    public_ip_address_id = azurerm_public_ip.changeme_simple_load_balancer_public_ip.id
  }
}
 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_linux_virtual_machine/simple/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: A simple Azure Linux Virtual Machine

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_simple_linux_virtual_machine_resource_group" {
  name     = "changeme-simple-linux-virtual-machine-resource-group-name"
  location = "West Europe"
}

# Virtual Network within the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_network
resource "azurerm_virtual_network" "changeme_simple_linux_virtual_machine_virtual_network" {
  name                = "changeme-simple-linux-virtual-machine-virtual-network-name"
  resource_group_name = azurerm_resource_group.changeme_simple_linux_virtual_machine_resource_group.name
  location            = azurerm_resource_group.changeme_simple_linux_virtual_machine_resource_group.location
  address_space       = ["10.0.0.0/16"]
}

# Subnet within the Virtual Network
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subnet
resource "azurerm_subnet" "changeme_simple_linux_virtual_machine_subnet" {
  name                 = "changeme-simple-linux-virtual-machine-subnet-name"
  resource_group_name  = azurerm_resource_group.changeme_simple_linux_virtual_machine_resource_group.name
  virtual_network_name = azurerm_virtual_network.changeme_simple_linux_virtual_machine_virtual_network.name
  address_prefixes     = ["10.0.1.0/24"]
}

# NIC attached to the Subnet
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_interface
resource "azurerm_network_interface" "changeme_simple_linux_virtual_machine_network_interface" {
  name                = "changeme-simple-linux-virtual-machine-network-interface-name"
  location            = azurerm_resource_group.changeme_simple_linux_virtual_machine_resource_group.location
  resource_group_name = azurerm_resource_group.changeme_simple_linux_virtual_machine_resource_group.name

  ip_configuration {
    name                          = "internal"
    subnet_id                     = azurerm_subnet.changeme_simple_linux_virtual_machine_subnet.id
    private_ip_address_allocation = "Dynamic"
  }
}

# Linux Virtual Machine with the NIC attached
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/linux_virtual_machine
resource "azurerm_linux_virtual_machine" "changeme_simple_linux_virtual_machine" {
  name                  = "changme-simple-linux-virtual-machine-name"
  resource_group_name   = azurerm_resource_group.changeme_simple_linux_virtual_machine_resource_group.name
  location              = azurerm_resource_group.changeme_simple_linux_virtual_machine_resource_group.location
  size                  = "Standard_B1ls"
  admin_username        = "changeme-adminuser"
  network_interface_ids = [azurerm_network_interface.changeme_simple_linux_virtual_machine_network_interface.id]

  admin_ssh_key {
    username   = "changeme-adminuser"
    public_key = file("~/.ssh/id_rsa.pub")

  }

  os_disk {
    caching              = "ReadWrite"
    storage_account_type = "Standard_LRS"
  }

  source_image_reference {
    publisher = "Canonical"
    offer     = "UbuntuServer"
    sku       = "16.04-LTS"
    version   = "latest"
  }
}
 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_managed_disk/copy/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: An copy Azure Managed Disk created form another Azure Managed Disk

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_copy_managed_disk_resource_group" {
  name     = "changeme-copy-storage-table-resource-group"
  location = "West Europe"
}

# Managed Disk in the Resource Group
# Explanation: Managed Disks are housed in a managed Storage Account that can not be otherwise accessed
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/managed_disk
resource "azurerm_managed_disk" "changeme_copy_managed_disk_template_managed_disk" {
  name     = "changeme-copy-managed-disk-template-managed-disk-name"
  location = "West US"

  disk_size_gb = "1"

  create_option        = "Empty"
  resource_group_name  = azurerm_resource_group.changeme_copy_managed_disk_resource_group.name
  storage_account_type = "Standard_LRS"
}

# Managed Disk copied from another Managed Disk in the same Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/managed_disk
resource "azurerm_managed_disk" "changeme_copy_managed_disk" {
  name     = "changeme-copy-managed-disk-name"
  location = "West US"

  source_resource_id = azurerm_managed_disk.changeme_copy_managed_disk_template_managed_disk.id

  create_option        = "Copy"
  resource_group_name  = azurerm_resource_group.changeme_copy_managed_disk_resource_group.name
  storage_account_type = "Standard_LRS"
} 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_managed_disk/empty/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: An empty Azure Managed Disk

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_empty_managed_disk_resource_group" {
  name     = "changeme-empty-storage-table-resource-group"
  location = "West Europe"
}

# Managed Disk in the Storage Account
# Explanation: Managed Disks are housed in a managed Storage Account that can not be otherwise accessed
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/managed_disk
resource "azurerm_managed_disk" "changeme_empty_managed_disk" {
  name     = "changeme-empty-managed-disk-name"
  location = "West US"

  disk_size_gb = "1"

  create_option        = "Empty"
  resource_group_name  = azurerm_resource_group.changeme_empty_managed_disk_resource_group.name
  storage_account_type = "Standard_LRS"
} 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_management_group/child/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: A Management Group as a child of another Management Group

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Parent Management Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/management_group
resource "azurerm_management_group" "changeme_parent_management_group" {
  display_name = "changeme-parent-management-group-display-name"
}

# Management Group attached as a child to another Management Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/management_group
resource "azurerm_management_group" "changeme_child_management_group" {
  display_name               = "changeme-child-management-group-display-name"
  parent_management_group_id = azurerm_management_group.changeme_parent_management_group.id
}
 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_management_group/root/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: A Management Group as a child of the account root

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Management Group created without a parent, so it attaches to the tenant root
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/management_group
resource "azurerm_management_group" "changeme_root_management_group" {
  display_name = "changeme-root-management-group-display-name"
}
 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_mariadb_server/simple/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: A simple Azure MariaDB Server

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_simple_mariadb_server_resource_group" {
  name     = "changeme-simple-mariadb-database-resource-group"
  location = "West Europe"
}

# MariaDB Server within the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mariadb_server
resource "azurerm_mariadb_server" "changeme_simple_mariadb_server" {
  name                = "changeme-simple-mariadb-database-name"
  resource_group_name = azurerm_resource_group.changeme_simple_mariadb_server_resource_group.name
  location            = azurerm_resource_group.changeme_simple_mariadb_server_resource_group.location

  storage_mb = "5120"
  sku_name   = "B_Gen5_1"
  version    = "10.3"

  administrator_login          = "changemeadmin"
  administrator_login_password = "ch4ng3m3-A@£$%^&"

  ssl_enforcement_enabled = true
}
 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_mssql_server/simple/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: A simple Azure MSSQL Server

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_simple_mssql_server_resource_group" {
  name     = "changeme-simple-mssql-database-resource-group"
  location = "West Europe"
}

# MSSQL Server within the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mssql_server
resource "azurerm_mssql_server" "changeme_simple_mssql_server" {
  name                = "changeme-simple-mssql-database-name"
  resource_group_name = azurerm_resource_group.changeme_simple_mssql_server_resource_group.name
  location            = azurerm_resource_group.changeme_simple_mssql_server_resource_group.location

  version = "12.0"

  administrator_login          = "changemeadmin"
  administrator_login_password = "ch4ng3m3-A@£$%^&"
}
 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_mysql_server/simple/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: A simple Azure MySQL Server

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_simple_mysql_server_resource_group" {
  name     = "changeme-simple-mysql-database-resource-group"
  location = "West Europe"
}

# MySQL Server within the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mysql_server
resource "azurerm_mysql_server" "changeme_simple_mysql_server" {
  name                = "changeme-simple-mysql-database-name"
  resource_group_name = azurerm_resource_group.changeme_simple_mysql_server_resource_group.name
  location            = azurerm_resource_group.changeme_simple_mysql_server_resource_group.location

  storage_mb = "5120"
  sku_name   = "B_Gen5_1"
  version    = "8.0"

  administrator_login          = "changemeadmin"
  administrator_login_password = "ch4ng3m3-A@£$%^&"

  ssl_enforcement_enabled = true
}
 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_network_interface/simple/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: A simple Azure Linux Virtual Machine

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_simple_network_interface_resource_group" {
  name     = "changeme-simple-network-interface-resource-group-name"
  location = "West Europe"
}

# Virtual Network within the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_network
resource "azurerm_virtual_network" "changeme_simple_network_interface_virtual_network" {
  name                = "changeme-simple-network-interface-virtual-network-name"
  resource_group_name = azurerm_resource_group.changeme_simple_network_interface_resource_group.name
  location            = azurerm_resource_group.changeme_simple_network_interface_resource_group.location
  address_space       = ["10.0.0.0/16"]
}

# Subnet within the Virtual Network
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subnet
resource "azurerm_subnet" "changeme_simple_network_interface_subnet" {
  name                 = "changeme-simple-network-interface-subnet-name"
  resource_group_name  = azurerm_resource_group.changeme_simple_network_interface_resource_group.name
  virtual_network_name = azurerm_virtual_network.changeme_simple_network_interface_virtual_network.name
  address_prefixes     = ["10.0.1.0/24"]
}

# NIC attached to the Subnet
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_interface
resource "azurerm_network_interface" "changeme_simple_network_interface" {
  name                = "changeme-simple-network-interface-name"
  location            = azurerm_resource_group.changeme_simple_network_interface_resource_group.location
  resource_group_name = azurerm_resource_group.changeme_simple_network_interface_resource_group.name

  ip_configuration {
    name                          = "changeme-ipconfig-name"
    subnet_id                     = azurerm_subnet.changeme_simple_network_interface_subnet.id
    private_ip_address_allocation = "Dynamic"
  }
}
 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_postgresql_server/simple/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: A simple Azure PostgreSQL Server

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_simple_postgresql_server_resource_group" {
  name     = "changeme-simple-postgresql-database-resource-group"
  location = "West Europe"
}

# PostgreSQL Server within the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/postgresql_server
resource "azurerm_postgresql_server" "changeme_simple_postgresql_server" {
  name                = "changeme-simple-postgresql-database-name"
  resource_group_name = azurerm_resource_group.changeme_simple_postgresql_server_resource_group.name
  location            = azurerm_resource_group.changeme_simple_postgresql_server_resource_group.location

  sku_name = "B_Gen5_1"
  version  = "11"

  administrator_login          = "changemeadmin"
  administrator_login_password = "ch4ng3m3-A@£$%^&"

  ssl_enforcement_enabled = true
}
 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_private_dns_zone/simple/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: A simple Azure Private DNS Zone

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_simple_private_dns_zone_resource_group" {
  name     = "changeme-simple-public-dns-zone-resource-group"
  location = "West Europe"
}

# Private DNS Zone in the Resource Group
# Explanation: Note that this is a private DNS Zone, public ones are a separate resource called azurerm_dns_zone
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/dns_zone
resource "azurerm_private_dns_zone" "changeme_simple_private_dns_zone" {
  name                = "changeme-simple-public-dns-zone.com"
  resource_group_name = azurerm_resource_group.changeme_simple_private_dns_zone_resource_group.name
} 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_public_ip/simple/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: A simple Azure Public IP

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_simple_public_ip_resource_group" {
  name     = "changeme-simple-public-ip-resource-group-name"
  location = "West Europe"
}

# Public IP within the Resource Group
# Explanation: Note that the location of the Public IP does not need to match the location of the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/public_ip
resource "azurerm_public_ip" "changeme_simple_public_ip" {
  name                = "changeme-simple-load-balancer-public-ip-name"
  location            = "West US"
  resource_group_name = azurerm_resource_group.changeme_simple_public_ip_resource_group.name
  allocation_method   = "Static"
}
 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_sql_server/simple/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: A simple Azure SQL Server

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_simple_sql_server_resource_group" {
  name     = "changeme-simple-sql-database-resource-group"
  location = "West Europe"
}

# SQL Server within the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/sql_server
resource "azurerm_sql_server" "changeme_simple_sql_server" {
  name                = "changeme-simple-sql-database-name"
  resource_group_name = azurerm_resource_group.changeme_simple_sql_server_resource_group.name
  location            = azurerm_resource_group.changeme_simple_sql_server_resource_group.location

  version = "12.0"

  administrator_login          = "changemeadmin"
  administrator_login_password = "ch4ng3m3-A@£$%^&"
}
 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_storage_account/simple/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: A simple Azure Storage Account

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_simple_storage_account_resource_group" {
  name     = "changeme-simple-storage-account-resource-group"
  location = "West Europe"
}

# Storage Account within the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account
resource "azurerm_storage_account" "changeme_simple_storage_account" {
  name                     = "changemesimplesaname"
  resource_group_name      = azurerm_resource_group.changeme_simple_storage_account_resource_group.name
  location                 = azurerm_resource_group.changeme_simple_storage_account_resource_group.location
  account_tier             = "Standard"
  account_replication_type = "LRS"
}
 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_storage_blob/append/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: An Azure Storage Blob using Append Block storage
# Explanation: Append Blocks are block storage optimized for append operations

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_append_storage_blob_resource_group" {
  name     = "changeme-append-storage-blob-resource-group"
  location = "West Europe"
}

# Storage Account within the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account
resource "azurerm_storage_account" "changeme_append_storage_blob_storage_account" {
  name                     = "changemeappendbsaname"
  resource_group_name      = azurerm_resource_group.changeme_append_storage_blob_resource_group.name
  location                 = azurerm_resource_group.changeme_append_storage_blob_resource_group.location
  account_tier             = "Standard"
  account_replication_type = "LRS"
}

# Storage Container in the Storage Account
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_container
resource "azurerm_storage_container" "changeme_append_storage_blob_storage_container" {
  name                 = "changemeappendbsacname"
  storage_account_name = azurerm_storage_account.changeme_append_storage_blob_storage_account.name
}

# Append Block Storage Blob in the Storage Container
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_blob
resource "azurerm_storage_blob" "changeme_append_storage_blob" {
  name                   = "changemeappendblobname"
  storage_account_name   = azurerm_storage_account.changeme_append_storage_blob_storage_account.name
  storage_container_name = azurerm_storage_container.changeme_append_storage_blob_storage_container.name
  type                   = "Append"
} 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_storage_blob/block/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: An Azure Storage Blob using Block storage

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_block_storage_blob_resource_group" {
  name     = "changeme-block-storage-blob-resource-group"
  location = "West Europe"
}

# Storage Account within the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account
resource "azurerm_storage_account" "changeme_block_storage_blob_storage_account" {
  name                     = "changemeblockbsaname"
  resource_group_name      = azurerm_resource_group.changeme_block_storage_blob_resource_group.name
  location                 = azurerm_resource_group.changeme_block_storage_blob_resource_group.location
  account_tier             = "Standard"
  account_replication_type = "LRS"
}

# Storage Container in the Storage Account
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_container
resource "azurerm_storage_container" "changeme_block_storage_blob_storage_container" {
  name                 = "changemeblockbsacname"
  storage_account_name = azurerm_storage_account.changeme_block_storage_blob_storage_account.name
}

# Block Storage Blob in the Storage Container
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_blob
resource "azurerm_storage_blob" "changeme_block_storage_blob" {
  name                   = "changemeblockblobname"
  storage_account_name   = azurerm_storage_account.changeme_block_storage_blob_storage_account.name
  storage_container_name = azurerm_storage_container.changeme_block_storage_blob_storage_container.name
  type                   = "Block"
} 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_storage_blob/page/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: An Azure Storage Blob using Page storage

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_page_storage_blob_resource_group" {
  name     = "changeme-page-storage-blob-resource-group"
  location = "West Europe"
}

# Storage Account within the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account
resource "azurerm_storage_account" "changeme_page_storage_blob_storage_account" {
  name                     = "changemepagebsaname"
  resource_group_name      = azurerm_resource_group.changeme_page_storage_blob_resource_group.name
  location                 = azurerm_resource_group.changeme_page_storage_blob_resource_group.location
  account_tier             = "Standard"
  account_replication_type = "LRS"
}

# Storage Container in the Storage Account
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_container
resource "azurerm_storage_container" "changeme_page_storage_blob_storage_container" {
  name                 = "changemepagebsacname"
  storage_account_name = azurerm_storage_account.changeme_page_storage_blob_storage_account.name
}

# Page Storage Blob in the Storage Container
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_blob
resource "azurerm_storage_blob" "changeme_page_storage_blob" {
  name                   = "changemepageblobname"
  storage_account_name   = azurerm_storage_account.changeme_page_storage_blob_storage_account.name
  storage_container_name = azurerm_storage_container.changeme_page_storage_blob_storage_container.name
  type                   = "Page"
  size                   = 512
} 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_storage_container/simple/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: A simple Azure Storage Container for Storage Blobs

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_simple_storage_container_resource_group" {
  name     = "changeme-simple-storage-container-resource-group"
  location = "West Europe"
}

# Storage Account within the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account
resource "azurerm_storage_account" "changeme_simple_storage_container_storage_account" {
  name                     = "changemesimpleqsaname"
  resource_group_name      = azurerm_resource_group.changeme_simple_storage_container_resource_group.name
  location                 = azurerm_resource_group.changeme_simple_storage_container_resource_group.location
  account_tier             = "Standard"
  account_replication_type = "LRS"
}

# Storage Container in the Storage Account
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_container
resource "azurerm_storage_container" "changeme_simple_storage_container" {
  name                 = "changemesimplecontainername"
  storage_account_name = azurerm_storage_account.changeme_simple_storage_container_storage_account.name
} 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_storage_queue/simple/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: A simple Azure Storage Queue

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_simple_storage_queue_resource_group" {
  name     = "changeme-simple-storage-queue-resource-group"
  location = "West Europe"
}

# Storage Account within the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account
resource "azurerm_storage_account" "changeme_simple_storage_queue_storage_account" {
  name                     = "changemesimpleqsaname"
  resource_group_name      = azurerm_resource_group.changeme_simple_storage_queue_resource_group.name
  location                 = azurerm_resource_group.changeme_simple_storage_queue_resource_group.location
  account_tier             = "Standard"
  account_replication_type = "LRS"
}

# Storage Queue in the Storage Account
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_queue
resource "azurerm_storage_queue" "changeme_simple_storage_queue" {
  name                 = "changemesimplequeuename"
  storage_account_name = azurerm_storage_account.changeme_simple_storage_queue_storage_account.name
} 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_storage_share/simple/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: A simple Azure Storage Share for filesystem storage

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_simple_storage_share_resource_group" {
  name     = "changeme-simple-storage-share-resource-group"
  location = "West Europe"
}

# Storage Account within the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account
resource "azurerm_storage_account" "changeme_simple_storage_share_storage_account" {
  name                     = "changemesimpleqsaname"
  resource_group_name      = azurerm_resource_group.changeme_simple_storage_share_resource_group.name
  location                 = azurerm_resource_group.changeme_simple_storage_share_resource_group.location
  account_tier             = "Standard"
  account_replication_type = "LRS"
}

# Storage Share in the Storage Account
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_share
resource "azurerm_storage_share" "changeme_simple_storage_share" {
  name                 = "changemesimplesharename"
  storage_account_name = azurerm_storage_account.changeme_simple_storage_share_storage_account.name
} 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_storage_table/simple/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: A simple Azure Storage Table

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_simple_storage_table_resource_group" {
  name     = "changeme-simple-storage-table-resource-group"
  location = "West Europe"
}

# Storage Account within the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account
resource "azurerm_storage_account" "changeme_simple_storage_table_storage_account" {
  name                     = "changemesimpletsaname"
  resource_group_name      = azurerm_resource_group.changeme_simple_storage_table_resource_group.name
  location                 = azurerm_resource_group.changeme_simple_storage_table_resource_group.location
  account_tier             = "Standard"
  account_replication_type = "LRS"
}

# Storage Table in the Storage Account
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_table
resource "azurerm_storage_table" "changeme_simple_storage_table" {
  name                 = "changemesimpletablename"
  storage_account_name = azurerm_storage_account.changeme_simple_storage_table_storage_account.name
} 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_subnet/simple/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: A simple Azure Linux Virtual Machine

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_simple_subnet_resource_group" {
  name     = "changeme-simple-resource-group"
  location = "West Europe"
}

# Virtual Network within the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_network
resource "azurerm_virtual_network" "changeme_simple_subnet_virtual_network" {
  name                = "changeme-simple-virtual-network"
  resource_group_name = azurerm_resource_group.changeme_simple_subnet_resource_group.name
  location            = azurerm_resource_group.changeme_simple_subnet_resource_group.location
  address_space       = ["10.0.0.0/16"]
}

# Subnet within the Virtual Network
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subnet
resource "azurerm_subnet" "changeme_simple_subnet" {
  name                 = "changeme-simple-subnet"
  resource_group_name  = azurerm_resource_group.changeme_simple_subnet_resource_group.name
  virtual_network_name = azurerm_virtual_network.changeme_simple_subnet_virtual_network.name
  address_prefixes     = ["10.0.1.0/24"]
} 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_subscription/customer_account/

destroy.sh

            #!/bin/bash
#../../../bin/destroy.sh azurerm
# Requires a Microsoft Customer Account to test
 

main.tf

            # Summary: A Subscription attached to an existing MCA

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Explanation: You need an existing Subscription with management rights to the MCA
# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}
  subscription_id = var.azure_subscription_id
}

# Explanation: Getting the details of the existing MCA
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/billing_mca_account_scope
data "azurerm_billing_mca_account_scope" "changeme_mca_account_scope" {
  billing_account_name = "changeme_billing_account_name"
  billing_profile_name = "changeme_billing_profile_name"
  invoice_section_name = "changeme_invoice_section_name"
}

# Subscription attached to the MCA
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subscription
resource "azurerm_subscription" "changeme_customer_account_subscription" {
  subscription_name = "changeme-new-subscription-name"
  billing_scope_id  = data.azurerm_billing_mca_account_scope.changeme_mca_account_scope.id
}
 

run.sh

            #!/bin/bash
#../../../bin/apply.sh azurerm
# Requires a Microsoft Customer Account to test
 

azurerm_subscription/enterprise_enrollment/

destroy.sh

            #!/bin/bash
#../../../bin/destroy.sh azurerm
# Requires a Microsoft Enterprise Enrollment to test 

main.tf

            # Summary: A Subscription attached to an existing Enterprise Enrollment Account

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Explanation: You need an existing Subscription with management rights to the Enterprise Enrollment
# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}
  subscription_id = var.azure_subscription_id
}

# Explanation: Getting the details of the existing Enrollment Account
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/billing_enrollment_account_scope
data "azurerm_billing_enrollment_account_scope" "changeme_enrollment_account_scope" {
  billing_account_name    = "changeme_billing_account_name"
  enrollment_account_name = "changeme_enrollment_account_name"
}

# Subscription attached to the Enrollment Account
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subscription
resource "azurerm_subscription" "changeme_enterprise_enrollment_subscription" {
  subscription_name = "changeme-subscription-name"
  billing_scope_id  = data.azurerm_billing_enrollment_account_scope.changeme_enrollment_account_scope.id
}
 

run.sh

            #!/bin/bash
#../../../bin/apply.sh azurerm
# Requires a Microsoft Enterprise Enrollment to test 

azurerm_virtual_machine/linux/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: A simple Azure Virtual Machine (deprecated in favor of the Linux and Windows specific resources)

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_simple_virtual_machine_linux_resource_group" {
  name     = "changeme-simple-virtual-machine-linux-resource-group-name"
  location = "West Europe"
}

# Virtual Network within the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_network
resource "azurerm_virtual_network" "changeme_simple_virtual_machine_linux_virtual_network" {
  name                = "changeme-simple-virtual-machine-linux-virtual-network-name"
  resource_group_name = azurerm_resource_group.changeme_simple_virtual_machine_linux_resource_group.name
  location            = azurerm_resource_group.changeme_simple_virtual_machine_linux_resource_group.location
  address_space       = ["10.0.0.0/16"]
}

# Subnet within the Virtual Network
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subnet
resource "azurerm_subnet" "changeme_simple_virtual_machine_linux_subnet" {
  name                 = "changeme-simple-virtual-machine-linux-subnet-name"
  resource_group_name  = azurerm_resource_group.changeme_simple_virtual_machine_linux_resource_group.name
  virtual_network_name = azurerm_virtual_network.changeme_simple_virtual_machine_linux_virtual_network.name
  address_prefixes     = ["10.0.1.0/24"]
}

# NIC attached to the Subnet
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_interface
resource "azurerm_network_interface" "changeme_simple_virtual_machine_linux_network_interface" {
  name                = "changeme-simple-virtual-machine-linux-network-interface-name"
  location            = azurerm_resource_group.changeme_simple_virtual_machine_linux_resource_group.location
  resource_group_name = azurerm_resource_group.changeme_simple_virtual_machine_linux_resource_group.name

  ip_configuration {
    name                          = "internal"
    subnet_id                     = azurerm_subnet.changeme_simple_virtual_machine_linux_subnet.id
    private_ip_address_allocation = "Dynamic"
  }
}

# Virtual Machine (Linux) with the NIC attached
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources_virtual_machine
resource "azurerm_virtual_machine" "changeme_simple_virtual_machine_linux" {
  name                  = "changeme-simple-virtual-machine-linux-name"
  resource_group_name   = azurerm_resource_group.changeme_simple_virtual_machine_linux_resource_group.name
  location              = azurerm_resource_group.changeme_simple_virtual_machine_linux_resource_group.location
  vm_size               = "Standard_B1ls"
  network_interface_ids = [azurerm_network_interface.changeme_simple_virtual_machine_linux_network_interface.id]

  delete_os_disk_on_termination    = true
  delete_data_disks_on_termination = true

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

  storage_os_disk {
    name              = "changeme-os-disk-name"
    caching           = "ReadWrite"
    create_option     = "FromImage"
    managed_disk_type = "Standard_LRS"
  }

  os_profile {
    computer_name  = "changeme-simple"
    admin_username = "changeme"
    admin_password = "Password1234!"
  }

  os_profile_linux_config {
    disable_password_authentication = false
  }
}
 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_virtual_machine/windows/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: A simple Azure Virtual Machine (deprecated in favor of the Linux and Windows specific resources)

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_simple_virtual_machine_windows_resource_group" {
  name     = "changeme-simple-virtual-machine-windows-resource-group-name"
  location = "West Europe"
}

# Virtual Network within the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_network
resource "azurerm_virtual_network" "changeme_simple_virtual_machine_windows_virtual_network" {
  name                = "changeme-simple-virtual-machine-windows-virtual-network-name"
  resource_group_name = azurerm_resource_group.changeme_simple_virtual_machine_windows_resource_group.name
  location            = azurerm_resource_group.changeme_simple_virtual_machine_windows_resource_group.location
  address_space       = ["10.0.0.0/16"]
}

# Subnet within the Virtual Network
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subnet
resource "azurerm_subnet" "changeme_simple_virtual_machine_windows_subnet" {
  name                 = "changeme-simple-virtual-machine-windows-subnet-name"
  resource_group_name  = azurerm_resource_group.changeme_simple_virtual_machine_windows_resource_group.name
  virtual_network_name = azurerm_virtual_network.changeme_simple_virtual_machine_windows_virtual_network.name
  address_prefixes     = ["10.0.1.0/24"]
}

# NIC attached to the Subnet
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_interface
resource "azurerm_network_interface" "changeme_simple_virtual_machine_windows_network_interface" {
  name                = "changeme-simple-virtual-machine-windows-network-interface-name"
  location            = azurerm_resource_group.changeme_simple_virtual_machine_windows_resource_group.location
  resource_group_name = azurerm_resource_group.changeme_simple_virtual_machine_windows_resource_group.name

  ip_configuration {
    name                          = "internal"
    subnet_id                     = azurerm_subnet.changeme_simple_virtual_machine_windows_subnet.id
    private_ip_address_allocation = "Dynamic"
  }
}

# Virtual Machine (Windows) with the NIC attached
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources_virtual_machine
resource "azurerm_virtual_machine" "changeme_simple_virtual_machine_windows" {
  name                  = "changeme-simple-virtual-machine-windows-name"
  resource_group_name   = azurerm_resource_group.changeme_simple_virtual_machine_windows_resource_group.name
  location              = azurerm_resource_group.changeme_simple_virtual_machine_windows_resource_group.location
  vm_size               = "Standard_B1ls"
  network_interface_ids = [azurerm_network_interface.changeme_simple_virtual_machine_windows_network_interface.id]

  storage_image_reference {
    publisher = "MicrosoftWindowsServer"
    offer     = "WindowsServer"
    sku       = "2019-Datacenter-Core-smalldisk"
    version   = "latest"
  }

  storage_os_disk {
    name              = "changeme-os-disk-name"
    caching           = "ReadWrite"
    create_option     = "FromImage"
    managed_disk_type = "Standard_LRS"
    os_type           = "Windows"
  }

  os_profile {
    computer_name  = "changeme-simple"
    admin_username = "changeme"
    admin_password = "Password1234!"
  }

  os_profile_windows_config {}
}
 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_virtual_network/simple/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: A simple Azure Virtual Network

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_simple_resource_group" {
  name     = "changeme-simple-resource-group"
  location = "West Europe"
}

# Virtual Network within the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_network
resource "azurerm_virtual_network" "changeme_simple_virtual_network" {
  name                = "changeme-simple-virtual-network"
  resource_group_name = azurerm_resource_group.changeme_simple_resource_group.name
  location            = azurerm_resource_group.changeme_simple_resource_group.location
  address_space       = ["10.0.0.0/16"]
}
 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm
 

azurerm_windows_virtual_machine/simple/

destroy.sh

            #!/bin/bash
../../../bin/destroy.sh azurerm
 

main.tf

            # Summary: A simple Azure Windows Virtual Machine

# Documentation: https://www.terraform.io/docs/language/settings/index.html
terraform {
  required_version = ">= 1.0.0"
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 2.0"
    }
  }
}

# Documentation: https://www.terraform.io/docs/language/values/variables.html
variable "azure_subscription_id" {
  type = string
}

# Documentation: https://www.terraform.io/docs/language/providers/requirements.html
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
provider "azurerm" {
  features {}

  subscription_id = var.azure_subscription_id
}

# Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group
resource "azurerm_resource_group" "changeme_simple_windows_virtual_machine_resource_group" {
  name     = "changeme-simple-windows-virtual-machine-resource-group-name"
  location = "West Europe"
}

# Virtual Network within the Resource Group
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_network
resource "azurerm_virtual_network" "changeme_simple_windows_virtual_machine_virtual_network" {
  name                = "changeme-simple-windows-virtual-machine-virtual-network-name"
  resource_group_name = azurerm_resource_group.changeme_simple_windows_virtual_machine_resource_group.name
  location            = azurerm_resource_group.changeme_simple_windows_virtual_machine_resource_group.location
  address_space       = ["10.0.0.0/16"]
}

# Subnet within the Virtual Network
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subnet
resource "azurerm_subnet" "changeme_simple_windows_virtual_machine_subnet" {
  name                 = "changeme-simple-windows-virtual-machine-subnet-name"
  resource_group_name  = azurerm_resource_group.changeme_simple_windows_virtual_machine_resource_group.name
  virtual_network_name = azurerm_virtual_network.changeme_simple_windows_virtual_machine_virtual_network.name
  address_prefixes     = ["10.0.1.0/24"]
}

# NIC attached to the Subnet
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_interface
resource "azurerm_network_interface" "changeme_simple_windows_virtual_machine_network_interface" {
  name                = "changeme-simple-windows-virtual-machine-network-interface-name"
  location            = azurerm_resource_group.changeme_simple_windows_virtual_machine_resource_group.location
  resource_group_name = azurerm_resource_group.changeme_simple_windows_virtual_machine_resource_group.name

  ip_configuration {
    name                          = "internal"
    subnet_id                     = azurerm_subnet.changeme_simple_windows_virtual_machine_subnet.id
    private_ip_address_allocation = "Dynamic"
  }
}

# Windows Virtual Machine with the NIC attached
# Documentation: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/windows_virtual_machine
resource "azurerm_windows_virtual_machine" "changeme_simple_windows_virtual_machine" {
  name                  = "changeme"
  resource_group_name   = azurerm_resource_group.changeme_simple_windows_virtual_machine_resource_group.name
  location              = azurerm_resource_group.changeme_simple_windows_virtual_machine_resource_group.location
  size                  = "Standard_B1ls"
  admin_username        = "changeme-adminuser"
  admin_password        = "changeme-P@$$w0rd!"
  network_interface_ids = [azurerm_network_interface.changeme_simple_windows_virtual_machine_network_interface.id]

  os_disk {
    caching              = "ReadWrite"
    storage_account_type = "Standard_LRS"
  }

  source_image_reference {
    publisher = "MicrosoftWindowsServer"
    offer     = "WindowsServer"
    sku       = "2016-Datacenter"
    version   = "latest"
  }
}
 

run.sh

            #!/bin/bash
../../../bin/apply.sh azurerm