Skip to content

telekom-mms/terraform-azurerm-compute

Repository files navigation

compute

This module manages the azurerm compute resources, see https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs.

For more information about the module structure see https://telekom-mms.github.io/terraform-template.

<-- This file is autogenerated, please do not change. -->

Requirements

Name Version
terraform >= 1.5
azurerm >= 4.0, < 5.0

Providers

Name Version
azurerm >= 4.0, < 5.0

Resources

Name Type
azurerm_linux_virtual_machine.linux_virtual_machine resource
azurerm_managed_disk.managed_disk resource
azurerm_virtual_machine_data_disk_attachment.virtual_machine_data_disk_attachment resource

Inputs

Name Description Type Default Required
linux_virtual_machine Resource definition, default settings are defined within locals and merged with var settings. For more information look at Outputs. any {} no
managed_disk Resource definition, default settings are defined within locals and merged with var settings. For more information look at Outputs. any {} no
virtual_machine_data_disk_attachment Resource definition, default settings are defined within locals and merged with var settings. For more information look at Outputs. any {} no

Outputs

Name Description
linux_virtual_machine Outputs all attributes of azurerm_linux_virtual_machine.
managed_disk Outputs all attributes of azurerm_managed_disk.
variables Displays all configurable variables passed by the module. default = predefined values per module. merged = result of merging the default values and custom values passed to the module
virtual_machine_data_disk_attachment Outputs all attributes of azurerm_virtual_machine_data_disk_attachment.

Examples

Minimal configuration to install the desired resources with the module

module "resource_group" {
  source = "registry.terraform.io/telekom-mms/resourcegroup/azurerm"
  resource_group = {
    rg-mms-github = {
      location = "westeurope"
    }
  }
}

module "network" {
  source = "registry.terraform.io/telekom-mms/network/azurerm"
  virtual_network = {
    vnet-mms-github = {
      location            = module.resource_group.resource_group["rg-mms-github"].location
      resource_group_name = module.resource_group.resource_group["rg-mms-github"].name
      address_space       = ["10.0.0.0/16"]
    }
  }
  subnet = {
    snet-mms-github = {
      resource_group_name  = module.resource_group.resource_group["rg-mms-github"].name
      virtual_network_name = module.network.virtual_network["vnet-mms-github"].name
      address_prefixes     = ["10.0.2.0/24"]
    }
  }
}

module "network_interface" {
  source = "registry.terraform.io/telekom-mms/network/azurerm"
  network_interface = {
    nic-mms-github = {
      resource_group_name = module.resource_group.resource_group["rg-mms-github"].name
      location            = module.resource_group.resource_group["rg-mms-github"].location
      ip_configuration = {
        internal = {
          subnet_id                     = module.network.subnet["snet-mms-github"].id
          private_ip_address_allocation = "Dynamic"
        }
      }
    }
  }
}

resource "tls_private_key" "example" {
  algorithm = "RSA"
  rsa_bits  = 4096
}

module "compute" {
  source = "registry.terraform.io/telekom-mms/compute/azurerm"

  linux_virtual_machine = {
    vm-mms-github = {
      resource_group_name   = module.resource_group.resource_group["rg-mms-github"].name
      location              = module.resource_group.resource_group["rg-mms-github"].location
      size                  = "Standard_B1s"
      admin_username        = "adminuser"
      network_interface_ids = [module.network_interface.network_interface["nic-mms-github"].id]
      admin_ssh_key = {
        key1 = {
          username   = "adminuser"
          public_key = tls_private_key.example.public_key_openssh
        }
      }
      os_disk = {
        caching              = "ReadWrite"
        storage_account_type = "Standard_LRS"
      }
      source_image_reference = {
        publisher = "Canonical"
        offer     = "UbuntuServer"
        sku       = "16.04-LTS"
        version   = "latest"
      }
    }
  }

  managed_disk = {
    disk-mms-github = {
      resource_group_name = module.resource_group.resource_group["rg-mms-github"].name
      location            = module.resource_group.resource_group["rg-mms-github"].location
      disk_size_gb        = 10
    }
  }

  virtual_machine_data_disk_attachment = {
    disk-attachment-min = {
      managed_disk_id    = module.compute.managed_disk["disk-mms-github"].id
      virtual_machine_id = module.compute.linux_virtual_machine["vm-mms-github"].id
      lun                = 10
      caching            = "ReadWrite"
    }
  }
}

Advanced configuration to install the desired resources with the module

module "resource_group" {
  source = "registry.terraform.io/telekom-mms/resourcegroup/azurerm"
  resource_group = {
    rg-mms-github = {
      location = "westeurope"
    }
  }
}

module "network" {
  source = "registry.terraform.io/telekom-mms/network/azurerm"
  virtual_network = {
    vnet-mms-github = {
      location            = module.resource_group.resource_group["rg-mms-github"].location
      resource_group_name = module.resource_group.resource_group["rg-mms-github"].name
      address_space       = ["10.0.0.0/16"]
    }
  }
  subnet = {
    snet-mms-github = {
      resource_group_name  = module.resource_group.resource_group["rg-mms-github"].name
      virtual_network_name = module.network.virtual_network["vnet-mms-github"].name
      address_prefixes     = ["10.0.2.0/24"]
    }
  }
}

module "network_interface" {
  source = "registry.terraform.io/telekom-mms/network/azurerm"
  network_interface = {
    nic-mms-github = {
      resource_group_name = module.resource_group.resource_group["rg-mms-github"].name
      location            = module.resource_group.resource_group["rg-mms-github"].location
      ip_configuration = {
        internal = {
          subnet_id                     = module.network.subnet["snet-mms-github"].id
          private_ip_address_allocation = "Dynamic"
        }
      }
    }
  }
}

resource "tls_private_key" "example" {
  algorithm = "RSA"
  rsa_bits  = 4096
}

module "compute" {
  source = "registry.terraform.io/telekom-mms/compute/azurerm"

  linux_virtual_machine = {
    vm-mms-github = {
      resource_group_name   = module.resource_group.resource_group["rg-mms-github"].name
      location              = module.resource_group.resource_group["rg-mms-github"].location
      size                  = "Standard_B2s"
      admin_username        = "adminuser"
      network_interface_ids = [module.network_interface.network_interface["nic-mms-github"].id]
      zone                  = "1"

      admin_ssh_key = {
        key1 = {
          username   = "adminuser"
          public_key = tls_private_key.example.public_key_openssh
        }
      }

      os_disk = {
        caching              = "ReadWrite"
        storage_account_type = "StandardSSD_LRS"
        disk_size_gb         = 30
      }

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

      identity = {
        type = "SystemAssigned"
      }

      boot_diagnostics = {
        storage_account_uri = null # Managed Storage Account
      }

      tags = {
        environment = "test"
        project     = "mms-github"
      }
    }
  }

  managed_disk = {
    disk-mms-github = {
      resource_group_name  = module.resource_group.resource_group["rg-mms-github"].name
      location             = module.resource_group.resource_group["rg-mms-github"].location
      disk_size_gb         = 20
      storage_account_type = "StandardSSD_LRS"
      zone                 = "1"

      tags = {
        environment = "test"
        project     = "mms-github"
      }
    }
  }

  virtual_machine_data_disk_attachment = {
    disk-attachment-full = {
      managed_disk_id    = module.compute.managed_disk["disk-mms-github"].id
      virtual_machine_id = module.compute.linux_virtual_machine["vm-mms-github"].id
      lun                = 10
      caching            = "ReadOnly"
    }
  }
}

About

A Terraform module that manages the azurerm compute resources from the azurerm provider.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages