Skip to content

Commit 1c429bd

Browse files
Removing subnet creation from the module. We should not be altering the customers network. Updated the health check to use the appropriate 41080 port. renamed the sensor admin user to "ubuntu" to match our documentation. Added the Linux Health Extension to provide a grace period before health checks are sent. (#12)
1 parent 380dfde commit 1c429bd

File tree

8 files changed

+46
-51
lines changed

8 files changed

+46
-51
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@ module "sensor" {
1313
license_key = "<your Corelight sensor license key>"
1414
location = "<Azure location to deploy resources in>"
1515
resource_group_name = "<resource group to deploy in>"
16-
virtual_network_name = "<virtual network where VMSS subnet should be deployed>"
17-
virtual_network_resource_group = "<virtual network resource group>"
18-
virtual_network_address_space = "<virtual network address space (CIDR) used to create subnet>"
1916
corelight_sensor_image_id = "<image resource id from Corelight>"
2017
community_string = "<the community string (api string) often times referenced by Fleet>"
2118
sensor_ssh_public_key = "<path to ssh public key>"
22-
19+
management_subnet_id = "<full management NIC subnet resource ID>"
20+
monitoring_subnet_id = "<full management NIC subnet resource ID>"
21+
2322
tags = {
2423
foo: bar,
2524
terraform: true,

load_balancer.tf

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ resource "azurerm_lb" "scale_set_lb" {
66

77
frontend_ip_configuration {
88
name = var.lb_frontend_ip_config_name
9-
subnet_id = azurerm_subnet.subnet.id
9+
subnet_id = var.monitoring_subnet_id
1010
}
1111

1212
tags = var.tags
@@ -25,11 +25,12 @@ resource "azurerm_lb_backend_address_pool" "monitoring_pool" {
2525
resource "azurerm_lb_probe" "sensor_health_check_probe" {
2626
loadbalancer_id = azurerm_lb.scale_set_lb.id
2727
name = var.lb_health_check_probe_name
28-
port = 443
29-
request_path = "/api/system/healthcheck/"
30-
protocol = "Https"
28+
port = 41080
29+
request_path = "/api/system/healthcheck"
30+
protocol = "Http"
3131
interval_in_seconds = 30
32-
probe_threshold = 3
32+
number_of_probes = 2
33+
probe_threshold = 2
3334
}
3435

3536
resource "azurerm_lb_rule" "monitoring_vxlan_lb_rule" {
@@ -45,28 +46,15 @@ resource "azurerm_lb_rule" "monitoring_vxlan_lb_rule" {
4546
probe_id = azurerm_lb_probe.sensor_health_check_probe.id
4647
}
4748

48-
resource "azurerm_lb_rule" "monitoring_geneve_lb_rule" {
49-
name = var.lb_geneve_rule_name
50-
loadbalancer_id = azurerm_lb.scale_set_lb.id
51-
protocol = "Udp"
52-
backend_port = 6081
53-
frontend_port = 6081
54-
frontend_ip_configuration_name = azurerm_lb.scale_set_lb.frontend_ip_configuration[0].name
55-
backend_address_pool_ids = [
56-
azurerm_lb_backend_address_pool.monitoring_pool.id
57-
]
58-
probe_id = azurerm_lb_probe.sensor_health_check_probe.id
59-
}
60-
6149
resource "azurerm_lb_rule" "monitoring_health_check_rule" {
6250
name = var.lb_health_check_rule_name
6351
loadbalancer_id = azurerm_lb.scale_set_lb.id
6452
protocol = "Tcp"
65-
backend_port = 443
66-
frontend_port = 443
53+
backend_port = 41080
54+
frontend_port = 41080
6755
frontend_ip_configuration_name = azurerm_lb.scale_set_lb.frontend_ip_configuration[0].name
6856
backend_address_pool_ids = [
69-
azurerm_lb_backend_address_pool.management_pool.id
57+
azurerm_lb_backend_address_pool.monitoring_pool.id
7058
]
7159
probe_id = azurerm_lb_probe.sensor_health_check_probe.id
7260
}

nat_gateway.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ resource "azurerm_nat_gateway" "lb_nat_gw" {
1717
}
1818

1919
resource "azurerm_subnet_nat_gateway_association" "nat_gw_association" {
20-
subnet_id = azurerm_subnet.subnet.id
20+
subnet_id = var.management_subnet_id
2121
nat_gateway_id = azurerm_nat_gateway.lb_nat_gw.id
2222
}
2323

outputs.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ output "sensor_scale_set_name" {
1818
value = azurerm_linux_virtual_machine_scale_set.sensor_scale_set.name
1919
}
2020

21-
output "sensor_scale_set_subnet_name" {
22-
value = azurerm_subnet.subnet.name
21+
output "sensor_load_balancer_frontend_ip_address" {
22+
value = azurerm_lb.scale_set_lb.frontend_ip_configuration[0].private_ip_address
2323
}

scale_set.tf

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,41 @@ resource "azurerm_linux_virtual_machine_scale_set" "sensor_scale_set" {
3333
ip_configuration {
3434
name = "management-nic-ip-cfg"
3535
primary = true
36-
subnet_id = azurerm_subnet.subnet.id
36+
subnet_id = var.management_subnet_id
3737
load_balancer_backend_address_pool_ids = [
3838
azurerm_lb_backend_address_pool.management_pool.id
3939
]
4040
}
4141
}
4242

4343
network_interface {
44-
name = "monitoring-nic"
44+
name = "monitoring-nic"
45+
enable_accelerated_networking = true
4546
ip_configuration {
4647
name = "monitoring-nic-ip-cfg"
47-
primary = true
48-
subnet_id = azurerm_subnet.subnet.id
48+
subnet_id = var.monitoring_subnet_id
4949
load_balancer_backend_address_pool_ids = [
5050
azurerm_lb_backend_address_pool.monitoring_pool.id
5151
]
5252
}
5353
}
5454

55+
extension {
56+
name = "HealthExtension"
57+
publisher = "Microsoft.ManagedServices"
58+
type = "ApplicationHealthLinux"
59+
type_handler_version = "2.0"
60+
auto_upgrade_minor_version = true
61+
settings = jsonencode({
62+
protocol = "https"
63+
port = 41080
64+
requestPath = "/api/system/healthcheck"
65+
intervalInSeconds = 15
66+
numberOfProbes = 2
67+
gracePeriod = 600
68+
})
69+
}
70+
5571
tags = var.tags
5672

5773
depends_on = [

sensor_config.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ module "sensor_config" {
1717
sensor_management_interface_name = "eth0"
1818
sensor_monitoring_interface_name = "eth1"
1919
sensor_health_check_probe_source_ranges_cidr = [local.azure_lb_health_check_probe_ip]
20-
sensor_health_check_http_port = 443
2120
gzip_config = true
2221
base64_encode_config = true
2322
enrichment_enabled = var.enrichment_storage_account_name != "" && var.enrichment_storage_container_name != ""

subnet.tf

Lines changed: 0 additions & 8 deletions
This file was deleted.

variables.tf

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,13 @@ variable "license_key" {
1414
sensitive = true
1515
}
1616

17-
variable "virtual_network_name" {
18-
description = "The name of the virtual network the sensor will be deployed in"
17+
variable "management_subnet_id" {
18+
description = "The subnet used to access the sensor"
1919
type = string
2020
}
2121

22-
variable "virtual_network_address_space" {
23-
description = "The address space of the virtual network the sensor be deployed in"
24-
type = string
25-
}
26-
27-
variable "virtual_network_resource_group" {
28-
description = "The resource group where the virtual network is deployed"
22+
variable "monitoring_subnet_id" {
23+
description = "The subnet used for monitoring traffic"
2924
type = string
3025
}
3126

@@ -54,7 +49,7 @@ variable "sensor_subnet_name" {
5449
variable "sensor_admin_username" {
5550
description = "The name of the admin user on the corelight sensor VM in the VMSS"
5651
type = string
57-
default = "corelight"
52+
default = "ubuntu"
5853
}
5954

6055
variable "nat_gateway_ip_name" {
@@ -202,3 +197,9 @@ variable "fleet_no_proxy" {
202197
default = ""
203198
description = "(optional) hosts or domains to bypass the proxy for fleet traffic"
204199
}
200+
201+
variable "monitoring_nsg_name" {
202+
type = string
203+
default = "corelight-monitoring-nsg"
204+
description = "(optional) Name of the monitoring network security group"
205+
}

0 commit comments

Comments
 (0)