Last active
July 12, 2024 11:32
-
-
Save rswrz/2cdca1a738c247144844c0e4bac34d1f to your computer and use it in GitHub Desktop.
Revisions
-
rswrz revised this gist
Jul 12, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,7 +18,7 @@ resource "azurerm_network_interface" "this" { content { name = try(ip_configuration.value.name, "ipconfig${try((index(ip_configuration.value.*.name, ip_configuration.value.name) + 1), 1)}") private_ip_address_allocation = try(ip_configuration.private_ip_address_allocation, "Dynamic") subnet_id = try(ip_configuration.subnet_id, null) } } } -
rswrz revised this gist
Jul 12, 2024 . 2 changed files with 7 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,3 @@ locals { network_interfaces = coalescelist(var.network_interfaces, tolist([ { This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,10 @@ variable "location" { type = string } variable "resource_group_name" { type = string } variable "network_interfaces" { description = <<-EOT -
rswrz revised this gist
Jul 12, 2024 . 2 changed files with 102 additions and 83 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,3 +3,105 @@ This is an example of a complex Terraform input variable with a description written in Markdown. [terraform-docs](https://terraform-docs.io/) can then generate a lovely README. For complex `description`s, it is recommended to use the terraform-docs formatter [markdown-document](https://terraform-docs.io/reference/markdown-document/). <!-- BEGIN_TF_DOCS --> ## Required Inputs The following input variables are required: ### <a name="input_location"></a> [location](#input\_location) Type: `string` ### <a name="input_resource_group_name"></a> [resource\_group\_name](#input\_resource\_group\_name) Type: `string` ## Optional Inputs The following input variables are optional (have default values): ### <a name="input_network_interfaces"></a> [network\_interfaces](#input\_network\_interfaces) Description: A list of network interface objects to be created and attached to the virtual machine. Required object parameters: - `name` - The name of the Network Interface. Changing this forces a new resource to be created. Optional object parameters: - `accelerated_networking_enabled` - Should Accelerated Networking be enabled? Defaults to `false`. - `auxiliary_mode` - Specifies the auxiliary mode used to enable network high-performance feature on Network Virtual Appliances (NVAs). This feature offers competitive performance in Connections Per Second (CPS) optimization, along with improvements to handling large amounts of simultaneous connections. Possible values are `AcceleratedConnections`, `Floating`, `MaxConnections` and `None`. - `auxiliary_sku` - Specifies the SKU used for the network high-performance feature on Network Virtual Appliances (NVAs). Possible values are `A8`, `A4`, `A1`, `A2` and `None`. - `dns_servers` - A list of IP Addresses defining the DNS Servers which should be used for this Network Interface. - `edge_zone` - Specifies the Edge Zone within the Azure Region where this Network Interface should exist. Changing this forces a new Network Interface to be created. - `internal_dns_name_label` - The (relative) DNS Name used for internal communications between Virtual Machines in the same Virtual Network. - `ip_forwarding_enabled` - Should IP Forwarding be enabled? Defaults to `false`. - `ip_configurations` – A list ip configuration opbjects. A `ip_configurations` object supports the following optional parameters: - `name` - A name used for this IP Configuration. Default name is `ipconfigN`, where `N` is a consecutive number. - `gateway_load_balancer_frontend_ip_configuration_id` - The Frontend IP Configuration ID of a Gateway SKU Load Balancer. - `subnet_id` - The ID of the Subnet where this Network Interface should be located in. - `private_ip_address_version` - The IP Version to use. Possible values are IPv4 or IPv6. Defaults to IPv4. - `private_ip_address_allocation` - The allocation method used for the Private IP Address. Possible values are Dynamic and Static. - `public_ip_address_id` - Reference to a Public IP Address to associate with this NIC - `primary` - Is this the Primary IP Configuration? Must be true for the first ip\_configuration when multiple are specified. Defaults to false. - `private_ip_address` - The Static IP Address which should be used. #### Example ```hcl module "example" { source = "cloudeteer/vm/azurerm" name = "vm-example-dev-we-01" location = azurerm_resource_group.example.location resource_group_name = azurerm_resource_group.example.name image = "Win2022Datacenter" network_interfaces = [ { name = "nic-example-dev-we-01 ip_configurations = [ { subnet_id = azurerm_subnet.example.id } ] } ] } ``` Type: ```hcl list( object({ name = string accelerated_networking_enabled = optional(bool) auxiliary_mode = optional(string) auxiliary_sku = optional(string) dns_servers = optional(list(string)) edge_zone = optional(string) internal_dns_name_label = optional(string) ip_forwarding_enabled = optional(bool) ip_configurations = optional(list(object({ gateway_load_balancer_frontend_ip_configuration_id = optional(string) name = optional(string) primary = optional(bool) private_ip_address = optional(string) private_ip_address_allocation = optional(string) private_ip_address_version = optional(string) public_ip_address_id = optional(string) subnet_id = optional(string) }))) }) ) ``` Default: `[]` <!-- END_TF_DOCS --> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,83 +0,0 @@ -
rswrz revised this gist
Jul 12, 2024 . 1 changed file with 32 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ variable "location" { type = string } variable "resource_group_name" { type = string } locals { network_interfaces = coalescelist(var.network_interfaces, tolist([ { name = "nic-default" } ])) } resource "azurerm_network_interface" "this" { for_each = { for item in local.network_interfaces : item.name => item } name = each.value.name location = var.location resource_group_name = var.resource_group_name dynamic "ip_configuration" { for_each = coalescelist(try(each.value.ip_configurations, []), [{ _ : null }]) content { name = try(ip_configuration.value.name, "ipconfig${try((index(ip_configuration.value.*.name, ip_configuration.value.name) + 1), 1)}") private_ip_address_allocation = try(ip_configuration.private_ip_address_allocation, "Dynamic") subnet_id = try(ip_configuration.private_ip_address_allocation, null) } } } -
rswrz revised this gist
Jul 12, 2024 . No changes.There are no files selected for viewing
-
rswrz revised this gist
Jul 12, 2024 . 2 changed files with 6 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,11 +2,11 @@ Description: A list of network interface objects to be created and attached to the virtual machine. Required parameters: - `name` - The name of the Network Interface. Changing this forces a new resource to be created. Optional parameters: - `accelerated_networking_enabled` - Should Accelerated Networking be enabled? Defaults to `false`. - `auxiliary_mode` - Specifies the auxiliary mode used to enable network high-performance feature on Network Virtual Appliances (NVAs). This feature offers competitive performance in Connections Per Second (CPS) optimization, along with improvements to handling large amounts of simultaneous connections. Possible values are `AcceleratedConnections`, `Floating`, `MaxConnections` and `None`. @@ -28,7 +28,7 @@ A `ip_configurations` object supports the following optional parameters: - `primary` - Is this the Primary IP Configuration? Must be true for the first ip\_configuration when multiple are specified. Defaults to false. - `private_ip_address` - The Static IP Address which should be used. Example: ```hcl module "example" { This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,11 +3,11 @@ variable "network_interfaces" { description = <<-EOT A list of network interface objects to be created and attached to the virtual machine. Required parameters: - `name` - The name of the Network Interface. Changing this forces a new resource to be created. Optional parameters: - `accelerated_networking_enabled` - Should Accelerated Networking be enabled? Defaults to `false`. - `auxiliary_mode` - Specifies the auxiliary mode used to enable network high-performance feature on Network Virtual Appliances (NVAs). This feature offers competitive performance in Connections Per Second (CPS) optimization, along with improvements to handling large amounts of simultaneous connections. Possible values are `AcceleratedConnections`, `Floating`, `MaxConnections` and `None`. @@ -29,7 +29,7 @@ variable "network_interfaces" { - `primary` - Is this the Primary IP Configuration? Must be true for the first ip_configuration when multiple are specified. Defaults to false. - `private_ip_address` - The Static IP Address which should be used. Example: ```hcl module "example" { -
rswrz created this gist
Jul 12, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ # Complex Terraform Input Variable This is an example of a complex Terraform input variable with a description written in Markdown. [terraform-docs](https://terraform-docs.io/) can then generate a lovely README. For complex `description`s, it is recommended to use the terraform-docs formatter [markdown-document](https://terraform-docs.io/reference/markdown-document/). This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,83 @@ ### <a name="input_network_interfaces"></a> [network\_interfaces](#input\_network\_interfaces) Description: A list of network interface objects to be created and attached to the virtual machine. Required object parameters: - `name` - The name of the Network Interface. Changing this forces a new resource to be created. Optional object parameters: - `accelerated_networking_enabled` - Should Accelerated Networking be enabled? Defaults to `false`. - `auxiliary_mode` - Specifies the auxiliary mode used to enable network high-performance feature on Network Virtual Appliances (NVAs). This feature offers competitive performance in Connections Per Second (CPS) optimization, along with improvements to handling large amounts of simultaneous connections. Possible values are `AcceleratedConnections`, `Floating`, `MaxConnections` and `None`. - `auxiliary_sku` - Specifies the SKU used for the network high-performance feature on Network Virtual Appliances (NVAs). Possible values are `A8`, `A4`, `A1`, `A2` and `None`. - `dns_servers` - A list of IP Addresses defining the DNS Servers which should be used for this Network Interface. - `edge_zone` - Specifies the Edge Zone within the Azure Region where this Network Interface should exist. Changing this forces a new Network Interface to be created. - `internal_dns_name_label` - The (relative) DNS Name used for internal communications between Virtual Machines in the same Virtual Network. - `ip_forwarding_enabled` - Should IP Forwarding be enabled? Defaults to `false`. - `ip_configurations` – A list ip configuration opbjects. A `ip_configurations` object supports the following optional parameters: - `name` - A name used for this IP Configuration. Default name is `ipconfigN`, where `N` is a consecutive number. - `gateway_load_balancer_frontend_ip_configuration_id` - The Frontend IP Configuration ID of a Gateway SKU Load Balancer. - `subnet_id` - The ID of the Subnet where this Network Interface should be located in. - `private_ip_address_version` - The IP Version to use. Possible values are IPv4 or IPv6. Defaults to IPv4. - `private_ip_address_allocation` - The allocation method used for the Private IP Address. Possible values are Dynamic and Static. - `public_ip_address_id` - Reference to a Public IP Address to associate with this NIC - `primary` - Is this the Primary IP Configuration? Must be true for the first ip\_configuration when multiple are specified. Defaults to false. - `private_ip_address` - The Static IP Address which should be used. #### Example ```hcl module "example" { source = "cloudeteer/vm/azurerm" name = "vm-example-dev-we-01" location = azurerm_resource_group.example.location resource_group_name = azurerm_resource_group.example.name image = "Win2022Datacenter" network_interfaces = [ { name = "nic-example-dev-we-01 ip_configurations = [ { subnet_id = azurerm_subnet.example.id } ] } ] } ``` Type: ```hcl list( object({ name = string accelerated_networking_enabled = optional(bool) auxiliary_mode = optional(string) auxiliary_sku = optional(string) dns_servers = optional(list(string)) edge_zone = optional(string) internal_dns_name_label = optional(string) ip_forwarding_enabled = optional(bool) ip_configurations = optional(list(object({ gateway_load_balancer_frontend_ip_configuration_id = optional(string) name = optional(string) primary = optional(bool) private_ip_address = optional(string) private_ip_address_allocation = optional(string) private_ip_address_version = optional(string) public_ip_address_id = optional(string) subnet_id = optional(string) }))) }) ) ``` Default: `[]` This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,81 @@ variable "network_interfaces" { description = <<-EOT A list of network interface objects to be created and attached to the virtual machine. Required object parameters: - `name` - The name of the Network Interface. Changing this forces a new resource to be created. Optional object parameters: - `accelerated_networking_enabled` - Should Accelerated Networking be enabled? Defaults to `false`. - `auxiliary_mode` - Specifies the auxiliary mode used to enable network high-performance feature on Network Virtual Appliances (NVAs). This feature offers competitive performance in Connections Per Second (CPS) optimization, along with improvements to handling large amounts of simultaneous connections. Possible values are `AcceleratedConnections`, `Floating`, `MaxConnections` and `None`. - `auxiliary_sku` - Specifies the SKU used for the network high-performance feature on Network Virtual Appliances (NVAs). Possible values are `A8`, `A4`, `A1`, `A2` and `None`. - `dns_servers` - A list of IP Addresses defining the DNS Servers which should be used for this Network Interface. - `edge_zone` - Specifies the Edge Zone within the Azure Region where this Network Interface should exist. Changing this forces a new Network Interface to be created. - `internal_dns_name_label` - The (relative) DNS Name used for internal communications between Virtual Machines in the same Virtual Network. - `ip_forwarding_enabled` - Should IP Forwarding be enabled? Defaults to `false`. - `ip_configurations` – A list ip configuration opbjects. A `ip_configurations` object supports the following optional parameters: - `name` - A name used for this IP Configuration. Default name is `ipconfigN`, where `N` is a consecutive number. - `gateway_load_balancer_frontend_ip_configuration_id` - The Frontend IP Configuration ID of a Gateway SKU Load Balancer. - `subnet_id` - The ID of the Subnet where this Network Interface should be located in. - `private_ip_address_version` - The IP Version to use. Possible values are IPv4 or IPv6. Defaults to IPv4. - `private_ip_address_allocation` - The allocation method used for the Private IP Address. Possible values are Dynamic and Static. - `public_ip_address_id` - Reference to a Public IP Address to associate with this NIC - `primary` - Is this the Primary IP Configuration? Must be true for the first ip_configuration when multiple are specified. Defaults to false. - `private_ip_address` - The Static IP Address which should be used. #### Example ```hcl module "example" { source = "cloudeteer/vm/azurerm" name = "vm-example-dev-we-01" location = azurerm_resource_group.example.location resource_group_name = azurerm_resource_group.example.name image = "Win2022Datacenter" network_interfaces = [ { name = "nic-example-dev-we-01 ip_configurations = [ { subnet_id = azurerm_subnet.example.id } ] } ] } ``` EOT type = list( object({ name = string accelerated_networking_enabled = optional(bool) auxiliary_mode = optional(string) auxiliary_sku = optional(string) dns_servers = optional(list(string)) edge_zone = optional(string) internal_dns_name_label = optional(string) ip_forwarding_enabled = optional(bool) ip_configurations = optional(list(object({ gateway_load_balancer_frontend_ip_configuration_id = optional(string) name = optional(string) primary = optional(bool) private_ip_address = optional(string) private_ip_address_allocation = optional(string) private_ip_address_version = optional(string) public_ip_address_id = optional(string) subnet_id = optional(string) }))) }) ) default = [] }