taoufik07 / terraform-azurerm-linux-scaleset

Terraform module for Linux VMSS (Linux Virtual Machine ScaleSet)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Azure Linux ScaleSet

Changelog Notice Apache V2 License TF Registry

Azure terraform module to create an Azure Linux ScaleSet.

Global versioning rule for Claranet Azure modules

Module version Terraform version AzureRM version
>= 6.x.x 1.x >= 3.0
>= 5.x.x 0.15.x >= 2.0
>= 4.x.x 0.13.x / 0.14.x >= 2.0
>= 3.x.x 0.12.x >= 2.0
>= 2.x.x 0.12.x < 2.0
< 2.x.x 0.11.x < 2.0

Usage

This module is optimized to work with the Claranet terraform-wrapper tool which set some terraform variables in the environment needed by this module. More details about variables set by the terraform-wrapper available in the documentation.

module "azure_region" {
  source  = "claranet/regions/azurerm"
  version = "x.x.x"

  azure_region = var.azure_region
}

module "rg" {
  source  = "claranet/rg/azurerm"
  version = "x.x.x"

  location    = module.azure_region.location
  client_name = var.client_name
  environment = var.environment
  stack       = var.stack
}

module "vnet" {
  source  = "claranet/vnet/azurerm"
  version = "x.x.x"

  environment    = var.environment
  location       = module.azure_region.location
  location_short = module.azure_region.location_short
  client_name    = var.client_name
  stack          = var.stack

  resource_group_name = module.rg.resource_group_name
  vnet_cidr           = ["10.0.1.0/24"]
}


module "subnet" {
  source  = "claranet/subnet/azurerm"
  version = "x.x.x"

  environment    = var.environment
  location_short = module.azure_region.location_short
  client_name    = var.client_name
  stack          = var.stack

  resource_group_name  = module.rg.resource_group_name
  virtual_network_name = module.vnet.virtual_network_name
  subnet_cidr_list     = ["10.0.1.0/26"]
}


module "logs" {
  source  = "claranet/run-common/azurerm//modules/logs"
  version = "x.x.x"

  client_name    = var.client_name
  location       = module.azure_region.location
  location_short = module.azure_region.location_short
  environment    = var.environment
  stack          = var.stack

  resource_group_name = module.rg.resource_group_name
}

module "az_monitor" {
  source  = "claranet/run-iaas/azurerm//modules/vm-monitoring"
  version = "x.x.x"

  client_name    = var.client_name
  location       = module.azure_region.location
  location_short = module.azure_region.location_short
  environment    = var.environment
  stack          = var.stack

  resource_group_name        = module.rg.resource_group_name
  log_analytics_workspace_id = module.logs.log_analytics_workspace_id

  extra_tags = {
    foo = "bar"
  }
}

module "linux_scaleset" {
  source  = "claranet/linux-scaleset/azurerm"
  version = "x.x.x"

  client_name    = var.client_name
  environment    = var.environment
  stack          = var.stack
  location       = module.azure_region.location
  location_short = module.azure_region.location_short

  resource_group_name = module.rg.resource_group_name

  admin_username = "myusername"
  ssh_public_key = var.ssh_public_key

  vms_sku = "Standard_B2s"

  subnet_id = module.subnet.subnet_id

  source_image_reference = {
    publisher = "Debian"
    offer     = "debian-10"
    sku       = "10"
    version   = "latest"
  }

  azure_monitor_data_collection_rule_id = module.az_monitor.data_collection_rule_id
  log_analytics_workspace_guid          = module.logs.log_analytics_workspace_guid
  log_analytics_workspace_key           = module.logs.log_analytics_workspace_primary_key
}

Providers

Name Version
azurecaf ~> 1.1
azurerm ~> 3.0
null >= 3.0.0

Modules

No modules.

Resources

Name Type
azurecaf_name.ipconfig resource
azurecaf_name.nic resource
azurecaf_name.vmss_linux resource
azurerm_linux_virtual_machine_scale_set.linux_vmss resource
azurerm_virtual_machine_scale_set_extension.azure_monitor_agent resource
azurerm_virtual_machine_scale_set_extension.log_extension resource
null_resource.azure_monitor_link resource
azurerm_client_config.current data source

Inputs

Name Description Type Default Required
accelerated_networking Specifies whether to enable accelerated networking or not bool false no
admin_password Password for the administrator account of the virtual machine. string null no
admin_username Username to use as admin user string n/a yes
application_gateway_backend_address_pool_ids Specifies an array of references to backend address pools of application gateways. A scale set can reference backend address pools of one application gateway list(string) [] no
application_security_group_ids Specifies up to 20 application security group IDs list(string) [] no
automatic_instance_repair Enable automatic instance repair. Must have health_probe_id or an Application Health Extension bool false no
automatic_os_upgrade Automatic OS patches can be applied by Azure to your scaleset. This is particularly useful when upgrade_policy_mode is set to Rolling. bool false no
azure_monitor_agent_version Azure Monitor Agent extension version string "1.12" no
azure_monitor_data_collection_rule_id Data Collection Rule ID from Azure Monitor for metrics and logs collection string n/a yes
boot_diagnostics_storage_uri Blob endpoint for the storage account to hold the virtual machine's diagnostic files string "" no
client_name Client name/account used in naming string n/a yes
custom_data The Base64-Encoded Custom Data which should be used for this Virtual Machine Scale Set. string null no
custom_ipconfig_name Custom name for Ipconfiguration string null no
custom_nic_name Custom name for Network Interfaces string null no
custom_vmss_name Custom name for the Virtual Machine ScaleSet string null no
data_disks A storage profile data disk list(any) [] no
default_tags_enabled Option to enable or disable default tags. bool true no
disable_automatic_rollback Disable automatic rollback in case of failured bool false no
dns_servers Specifies an array of DNS servers list(string) [] no
environment Project environment string n/a yes
extensions Can be specified to add extension profiles to the scale set map(any) {} no
extra_tags Additional tags to associate with your scale set. map(string) {} no
health_probe_id Specifies the identifier for the load balancer health probe. Required when using Rolling as your upgrade_policy_mode. string null no
identity Map with identity block informations as described here https://www.terraform.io/docs/providers/azurerm/r/linux_virtual_machine_scale_set.html#identity
object({
type = string
identity_ids = list(string)
})
null no
instances_count Specify the number of instances to run number 1 no
ip_forwarding Whether IP forwarding is enabled on this NIC bool false no
load_balancer_backend_address_pool_ids Specifies an array of references to backend address pools of load balancers. A scale set can reference backend address pools of one public and one internal load balancer list(string) [] no
load_balancer_inbound_nat_rules_ids Specifies an array of references to inbound NAT rules for load balancers list(string) [] no
location Azure region to use string n/a yes
location_short Short string for Azure location string n/a yes
log_analytics_agent_enabled Deploy Log Analytics VM extension - depending of OS (cf. https://docs.microsoft.com/fr-fr/azure/azure-monitor/agents/agents-overview#linux) bool true no
log_analytics_agent_version Azure Log Analytics extension version string "1.13" no
log_analytics_workspace_guid GUID of the Log Analytics Workspace to link with string null no
log_analytics_workspace_key Access key of the Log Analytics Workspace to link with string null no
name_prefix Optional prefix for the generated name string "" no
name_suffix Optional suffix for the generated name string "" no
network_security_group_id Specifies the id for the network security group string "" no
os_disk_caching Specifies the caching requirements [Possible values : None, ReadOnly, ReadWrite] string "None" no
os_disk_encryption_set_id The ID of the Disk Encryption Set which should be used to encrypt this Data Disk string null no
os_disk_is_local Specifies the Ephemeral Disk Settings for the OS Disk to Local bool false no
os_disk_managed_disk_type Specifies the type of managed disk to create [Possible values : Standard_LRS, StandardSSD_LRS or Premium_LRS] string "Standard_LRS" no
os_disk_size_gb Size of the OS disk in GB number 32 no
os_disk_write_accelerator_enabled True to enable Write Accelerator for this Data Disk bool false no
overprovision Should Azure over-provision Virtual Machines in this Scale Set? This means that multiple Virtual Machines will be provisioned and Azure will keep the instances which become available first - which improves provisioning success rates and improves deployment time. bool true no
resource_group_name Name of the resource group string n/a yes
rolling_upgrade_policy This is only applicable when the upgrade_policy_mode is Rolling.
object({
max_batch_instance_percent = number
max_unhealthy_instance_percent = number
max_unhealthy_upgraded_instance_percent = number
pause_time_between_batches = string
})
{
"max_batch_instance_percent": 25,
"max_unhealthy_instance_percent": 25,
"max_unhealthy_upgraded_instance_percent": 25,
"pause_time_between_batches": "PT30S"
}
no
scale_in_policy The scale-in policy rule that decides which virtual machines are chosen for removal when a Virtual Machine Scale Set is scaled in. Possible values for the scale-in policy rules are Default, NewestVM and OldestVM, defaults to Default string "Default" no
source_image_id Id of the image to use. string null no
source_image_reference Source Image references
object({
publisher = string
offer = string
sku = string
version = string
})
null no
ssh_private_key Private SSH key deployed on Scale set string null no
ssh_public_key Public SSH key deployed on Scale set string null no
stack Project stack name string n/a yes
subnet_id Specifies the identifier of the subnet string n/a yes
ultra_ssd_enabled Should the capacity to enable Data Disks of the UltraSSD_LRS storage account type be supported on this Virtual Machine Scale Set? bool false no
upgrade_mode Specifies how Upgrades (e.g. changing the Image/SKU) should be performed to Virtual Machine Instances. Possible values are Automatic, Manual and Rolling. Defaults to Manual. string "Manual" no
use_caf_naming Use the Azure CAF naming provider to generate default resource name. custom_vmss_name override this if set. Legacy default name is used if this is set to false. bool true no
vms_sku Specifies the size of virtual machines in a scale set string n/a yes
zone_balance Should the Virtual Machines in this Scale Set be strictly evenly distributed across Availability Zones? Changing this forces a new resource to be created. bool true no
zones_list A list of Availability Zones in which the Virtual Machines in this Scale Set should be created in. Changing this forces a new resource to be created. list(number)
[
1,
2,
3
]
no

Outputs

Name Description
scale_set_admin_password Scale Set admin password
scale_set_admin_ssh_private_key Scale Set admin SSH private key
scale_set_admin_ssh_public_key Scale Set admin SSH public key
scale_set_admin_username Scale Set admin username
scale_set_id Scale Set ID
scale_set_name Scale Set Name
system_assigned_identity Identity block with principal ID
terraform_module Information about this Terraform module

Related documentation

About

Terraform module for Linux VMSS (Linux Virtual Machine ScaleSet)

License:Apache License 2.0


Languages

Language:HCL 100.0%