Skip to content

Commit a70be8a

Browse files
committed
updating the documentation #3
1 parent 19d5698 commit a70be8a

File tree

1 file changed

+150
-35
lines changed

1 file changed

+150
-35
lines changed

README.md

Lines changed: 150 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ Azure virtual machine scale sets let you create and manage a group of identical,
44

55
This module deploys Windows or Linux virtual machine scale sets with Public / Private Load Balancer support and many other features.
66

7-
> **[NOTE]**
8-
> **This module now supports the meta arguments including `providers`, `depends_on`, `count`, and `for_each`.**
9-
107
## Resources Supported
118

129
* [Linux Virtual Machine Scale Set](https://www.terraform.io/docs/providers/azurerm/r/linux_virtual_machine_scale_set.html)
1310
* [Windows Virtual Machine Scale Set](https://www.terraform.io/docs/providers/azurerm/r/windows_virtual_machine_scale_set.html)
11+
* [Automatic OS image upgrade](https://docs.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-automatic-upgrade)
1412
* [Public Azure Load Balancer](https://www.terraform.io/docs/providers/azurerm/r/lb.html)
1513
* [Private Azure Load Balancer](https://www.terraform.io/docs/providers/azurerm/r/lb.html)
1614
* [Inbound NAT Rule](https://www.terraform.io/docs/providers/azurerm/r/lb_nat_pool.html)
@@ -20,42 +18,47 @@ This module deploys Windows or Linux virtual machine scale sets with Public / Pr
2018

2119
## Module Usage
2220

23-
```hcl
21+
```terraform
2422
# Azurerm provider configuration
2523
provider "azurerm" {
2624
features {}
2725
}
2826
27+
data "azurerm_log_analytics_workspace" "example" {
28+
name = "loganalytics-we-sharedtest2"
29+
resource_group_name = "rg-shared-westeurope-01"
30+
}
31+
2932
module "vmscaleset" {
3033
source = "kumarvna/vm-scale-sets/azurerm"
31-
version = "2.2.0"
34+
version = "2.3.0"
3235
3336
# Resource Group and location, VNet and Subnet detials (Required)
3437
resource_group_name = "rg-shared-westeurope-01"
3538
virtual_network_name = "vnet-shared-hub-westeurope-001"
3639
subnet_name = "snet-management"
3740
vmscaleset_name = "testvmss"
3841
39-
# (Optional) To enable Azure Monitoring and install log analytics agents
40-
# (Optional) Specify `storage_account_name` to save monitoring logs to storage.
41-
log_analytics_workspace_name = var.log_analytics_workspace_name
42-
43-
# Deploy log analytics agents to virtual machine. Log analytics workspace name required.
44-
# Defaults to `false`
45-
deploy_log_analytics_agent = false
46-
4742
# This module support multiple Pre-Defined Linux and Windows Distributions.
48-
# These distributions support the Automatic OS image upgrades in virtual machine scale sets
49-
# Linux images: ubuntu1804, ubuntu1604, centos75, coreos
50-
# Windows Images: windows2012r2dc, windows2016dc, windows2019dc, windows2016dccore
51-
# Specify the RSA key for production workloads and set generate_admin_ssh_key argument to false
52-
# When you use Autoscaling feature, instances_count will become default and minimum instance count.
43+
# Check the README.md file for more pre-defined images for Ubuntu, Centos, RedHat.
44+
# Please make sure to use gen2 images supported VM sizes if you use gen2 distributions
45+
# Specify `disable_password_authentication = false` to create random admin password
46+
# Specify a valid password with `admin_password` argument to use your own password
47+
# To generate SSH key pair, specify `generate_admin_ssh_key = true`
48+
# To use existing key pair, specify `admin_ssh_key_data` to a valid SSH public key path.
5349
os_flavor = "linux"
5450
linux_distribution_name = "ubuntu1804"
55-
generate_admin_ssh_key = false
56-
admin_ssh_key_data = "~/.ssh/id_rsa.pub"
51+
virtual_machine_size = "Standard_A2_v2"
52+
admin_username = "azureadmin"
53+
generate_admin_ssh_key = true
5754
instances_count = 2
5855
56+
# Proxymity placement group, Automatic Instance repair and adding Public IP to VM's are optional.
57+
# remove these argument from module if you dont want to use it.
58+
enable_proximity_placement_group = true
59+
assign_public_ip_to_each_vm_in_vmss = true
60+
enable_automatic_instance_repair = true
61+
5962
# Public and private load balancer support for VM scale sets
6063
# Specify health probe port to allow LB to detect the backend endpoint status
6164
# Standard Load Balancer helps load-balance TCP and UDP flows on all ports simultaneously
@@ -75,10 +78,14 @@ module "vmscaleset" {
7578
scale_out_cpu_percentage_threshold = 80
7679
scale_in_cpu_percentage_threshold = 20
7780
81+
# Boot diagnostics to troubleshoot virtual machines, by default uses managed
82+
# To use custom storage account, specify `storage_account_name` with a valid name
83+
# Passing a `null` value will utilize a Managed Storage Account to store Boot Diagnostics
84+
enable_boot_diagnostics = true
85+
7886
# Network Seurity group port allow definitions for each Virtual Machine
7987
# NSG association to be added automatically for all network interfaces.
80-
# SSH port 22 and 3389 is exposed to the Internet recommended for only testing.
81-
# For production environments, we recommend using a VPN or private connection
88+
# Remove this NSG rules block, if `existing_network_security_group_id` is specified
8289
nsg_inbound_rules = [
8390
{
8491
name = "http"
@@ -93,10 +100,19 @@ module "vmscaleset" {
93100
},
94101
]
95102
96-
# Adding TAG's to your Azure resources (Required)
97-
# ProjectName and Env are already declared above, to use them here, create a varible.
103+
# (Optional) To enable Azure Monitoring and install log analytics agents
104+
# (Optional) Specify `storage_account_name` to save monitoring logs to storage.
105+
log_analytics_workspace_id = data.azurerm_log_analytics_workspace.example.id
106+
107+
# Deploy log analytics agents to virtual machine.
108+
# Log analytics workspace customer id and primary shared key required.
109+
deploy_log_analytics_agent = true
110+
log_analytics_customer_id = data.azurerm_log_analytics_workspace.example.workspace_id
111+
log_analytics_workspace_primary_shared_key = data.azurerm_log_analytics_workspace.example.primary_shared_key
112+
113+
# Adding additional TAG's to your Azure resources
98114
tags = {
99-
ProjectName = "demo-internal"
115+
ProjectName = "demo-project"
100116
Env = "dev"
101117
102118
BusinessUnit = "CORP"
@@ -131,14 +147,15 @@ If the pre-defined Windows or Linux variants are not sufficient then, you can sp
131147
```hcl
132148
module "vmscaleset" {
133149
source = "kumarvna/vm-scale-sets/azurerm"
134-
version = "2.2.0"
150+
version = "2.3.0"
135151
136152
# .... omitted
137153
138154
os_flavor = "linux"
139155
linux_distribution_name = "ubuntu1804"
140-
generate_admin_ssh_key = false
141-
admin_ssh_key_data = "~/.ssh/id_rsa.pub"
156+
virtual_machine_size = "Standard_A2_v2"
157+
admin_username = "azureadmin"
158+
generate_admin_ssh_key = true
142159
instances_count = 2
143160
144161
custom_image = {
@@ -149,6 +166,8 @@ module "vmscaleset" {
149166
}
150167
151168
# .... omitted
169+
170+
}
152171
```
153172

154173
## Custom DNS servers
@@ -233,6 +252,68 @@ When an instance goes through a state change operation because of a PUT, PATCH o
233252

234253
The automatic instance repair feature can be enabled while creating a new scale set by setting up the argument `enable_automatic_instance_repair = true` and the grace period can be managed using the argument `grace_period = "PT30M"`. Default grace period is 30 minutes.
235254

255+
### `enable_proximity_placement_group` - Achieving the lowest possible latency
256+
257+
Placing VMs in a single region reduces the physical distance between the instances. Placing them within a single availability zone will also bring them physically closer together. However, as the Azure footprint grows, a single availability zone may span multiple physical data centers, which may result in a network latency impacting your application.
258+
259+
To get VMs as close as possible, achieving the lowest possible latency, you should deploy them within a proximity placement group.
260+
261+
A proximity placement group is a logical grouping used to make sure that Azure compute resources are physically located close to each other. Proximity placement groups are useful for workloads where low latency is a requirement.
262+
263+
By default, this not enabled and set to disable. To enable the Proximity placement group with this module, set the argument `enable_proximity_placement_group = true`.
264+
265+
### `Identity` - Configure managed identities for Azure resources on a VM Scale Sets
266+
267+
Managed identities for Azure resources provides Azure services with an automatically managed identity in Azure Active Directory. You can use this identity to authenticate to any service that supports Azure AD authentication, without having credentials in your code.
268+
269+
There are two types of managed identities:
270+
271+
* **System-assigned**: When enabled a system-assigned managed identity an identity is created in Azure AD that is tied to the lifecycle of that service instance. when the resource is deleted, Azure automatically deletes the identity. By design, only that Azure resource can use this identity to request tokens from Azure AD.
272+
* **User-assigned**: A managed identity as a standalone Azure resource. For User-assigned managed identities, the identity is managed separately from the resources that use it.
273+
274+
Regardless of the type of identity chosen a managed identity is a service principal of a special type that may only be used with Azure resources. When the managed identity is deleted, the corresponding service principal is automatically removed.
275+
276+
```terraform
277+
resource "azurerm_user_assigned_identity" "example" {
278+
for_each = toset(["user-identity1", "user-identity2"])
279+
resource_group_name = "rg-shared-westeurope-01"
280+
location = "westeurope"
281+
name = each.key
282+
}
283+
284+
module "vmscaleset" {
285+
source = "kumarvna/vm-scale-sets/azurerm"
286+
version = "2.3.0"
287+
288+
# .... omitted for bravity
289+
290+
os_flavor = "linux"
291+
linux_distribution_name = "ubuntu1804"
292+
virtual_machine_size = "Standard_A2_v2"
293+
admin_username = "azureadmin"
294+
generate_admin_ssh_key = true
295+
instances_count = 2
296+
297+
# Configure managed identities for Azure resources on a VM
298+
# Possible types are `SystemAssigned`, `UserAssigned` and `SystemAssigned, UserAssigned`.
299+
managed_identity_type = "UserAssigned"
300+
managed_identity_ids = [for k in azurerm_user_assigned_identity.example : k.id]
301+
302+
# .... omitted for bravity
303+
304+
}
305+
```
306+
307+
### `enable_boot_diagnostics` - boot diagnostics to troubleshoot virtual machines
308+
309+
Boot diagnostics is a debugging feature for Azure virtual machines (VM) that allows the diagnosis of VM boot failures. Boot diagnostics enables a user to observe the state of their VM as it is booting up by collecting serial log information and screenshots. This module enabled this feature by setting up `enable_boot_diagnostics = true`. Azure Storage Account to be used to store Boot Diagnostics, including Console Output and Screenshots from the Hypervisor. This module supports the existing storage account using the `storage_account_name` argument with a valid name. If we are not passing any storage account, it will utilize a Managed Storage Account to store Boot Diagnostics.
310+
311+
### `winrm_protocol` - Enable WinRM wiht HTTPS
312+
313+
Window remote management - in short, `WinRM` is a built-in windows protocol/Service which uses soap[simple object access protocol] to connect from another source system. Using WinRM, we can connect the remote system and execute any command there as its native user.
314+
315+
WinRM comes pre-installed with all new window OS. We need to enable WinRM service and configure the ports for outside traffic. This module configure `winRM` by setting up `winrm_protocol = "Https"` and `key_vault_certificate_secret_url` value to the Secret URL of a Key Vault Certificate.
316+
236317
## Network Security Groups
237318

238319
By default, the network security groups connected to Network Interface and allow necessary traffic and block everything else (deny-all rule). Use `nsg_inbound_rules` in this Terraform module to create a Network Security Group (NSG) for network interface and allow it to add additional rules for inbound flows.
@@ -244,14 +325,15 @@ In the Source and Destination columns, `VirtualNetwork`, `AzureLoadBalancer`, an
244325
```hcl
245326
module "vmscaleset" {
246327
source = "kumarvna/vm-scale-sets/azurerm"
247-
version = "2.2.0"
328+
version = "2.3.0"
248329
249-
# .... omitted
330+
# .... omitted for bravity
250331
251332
os_flavor = "linux"
252333
linux_distribution_name = "ubuntu1804"
253-
generate_admin_ssh_key = false
254-
admin_ssh_key_data = "~/.ssh/id_rsa.pub"
334+
virtual_machine_size = "Standard_A2_v2"
335+
admin_username = "azureadmin"
336+
generate_admin_ssh_key = true
255337
instances_count = 2
256338
257339
nsg_inbound_rules = [
@@ -270,6 +352,39 @@ module "vmscaleset" {
270352
}
271353
```
272354

355+
## Using exisging Network Security Groups
356+
357+
Enterprise environments may need a requirement to use pre-existing NSG groups to maintain capabilities. This module supports existing network security groups usage. To use this feature, set the argument `existing_network_security_group_id` with a valid NSG resource id and remove all NSG inbound rules blocks from the module.
358+
359+
```terraform
360+
data "azurerm_network_security_group" "example" {
361+
name = "nsg_mgnt_subnet_in"
362+
resource_group_name = "vnet-shared-hub-westeurope-001"
363+
}
364+
365+
module "vmscaleset" {
366+
source = "kumarvna/vm-scale-sets/azurerm"
367+
version = "2.3.0"
368+
369+
# .... omitted for bravity
370+
371+
os_flavor = "linux"
372+
linux_distribution_name = "ubuntu1804"
373+
virtual_machine_size = "Standard_A2_v2"
374+
admin_username = "azureadmin"
375+
generate_admin_ssh_key = true
376+
instances_count = 2
377+
378+
# Network Seurity group port allow definitions for each Virtual Machine
379+
# NSG association to be added automatically for all network interfaces.
380+
# Remove this NSG rules block, if `existing_network_security_group_id` is specified
381+
existing_network_security_group_id = data.azurerm_network_security_group.example.id
382+
383+
# .... omitted for bravity
384+
385+
}
386+
```
387+
273388
## Recommended naming and tagging conventions
274389

275390
Applying tags to your Azure resources, resource groups, and subscriptions to logically organize them into a taxonomy. Each tag consists of a name and a value pair. For example, you can apply the name `Environment` and the value `Production` to all the resources in production.
@@ -291,9 +406,9 @@ azurerm | >= 2.59.0
291406

292407
| Name | Version |
293408
|------|---------|
294-
azurerm |>= 2.59.0
295-
random | n/a
296-
tls | n/a
409+
| azurerm | >= 2.59.0 |
410+
| random | >= 3.1.0 |
411+
| tls | >= 3.1.0 |
297412

298413
## Inputs
299414

0 commit comments

Comments
 (0)