resource "azurerm_resource_group" "rg" {
name = "rg-firewall"
location = "SouthEast Asia"
}
resource "azurerm_virtual_network" "vnet" {
name = "vnet-firewall"
resource_group_name = "${azurerm_resource_group.rg.name}"
address_space = ["172.16.1.0/24"]
location = "SouthEast Asia"
}
resource "azurerm_subnet" "External_subnet" {
name = "External"
resource_group_name = "${azurerm_resource_group.rg.name}"
virtual_network_name = "${azurerm_virtual_network.vnet.name}"
address_prefix = "172.16.1.0/27"
}
resource "azurerm_subnet" "Internal_subnet" {
name = "Internal"
resource_group_name = "${azurerm_resource_group.rg.name}"
virtual_network_name = "${azurerm_virtual_network.vnet.name}"
address_prefix = "172.16.1.32/27"
}
resource "azurerm_network_interface" "vsec-eth0" {
name = "vsec-eth0"
location = "SouthEast Asia"
resource_group_name = "${azurerm_resource_group.rg.name}"
enable_ip_forwarding = "true"
ip_configuration {
name = "member-ip"
subnet_id = "${azurerm_subnet.External_subnet.id}"
private_ip_address_allocation = "Static"
private_ip_address = "172.16.1.10"
primary = true
#public_ip_address_id = "${azurerm_public_ip.gwpublicip.id}"
}
ip_configuration {
name = "cluster-vip"
subnet_id = "${azurerm_subnet.External_subnet.id}"
private_ip_address_allocation = "Static"
private_ip_address = "172.16.1.12"
primary = false
}
}
resource "azurerm_network_interface" "vsec-eth1" {
name = "vsec-eth1"
location = "SouthEast Asia"
resource_group_name = "${azurerm_resource_group.rg.name}"
enable_ip_forwarding = "true"
ip_configuration {
name = "member-ip"
subnet_id = "${azurerm_subnet.Internal_subnet.id}"
private_ip_address_allocation = "Static"
private_ip_address = "172.16.1.40"
primary = true
}
}
resource "azurerm_network_interface" "vsec2-eth0" {
name = "vsec2-eth0"
location = "SouthEast Asia"
resource_group_name = "${azurerm_resource_group.rg.name}"
enable_ip_forwarding = "true"
ip_configuration {
name = "member-ip"
subnet_id = "${azurerm_subnet.External_subnet.id}"
private_ip_address_allocation = "Static"
private_ip_address = "172.16.1.11"
primary = true
}
}
resource "azurerm_network_interface" "vsec2-eth1" {
name = "vsec2-eth1"
location = "SouthEast Asia"
resource_group_name = "${azurerm_resource_group.rg.name}"
enable_ip_forwarding = "true"
ip_configuration {
name = "ipconfig0"
subnet_id = "${azurerm_subnet.Internal_subnet.id}"
private_ip_address_allocation = "Static"
private_ip_address = "172.16.1.41"
}
}
resource "azurerm_virtual_machine" "vsec01" {
name = "vsec01"
location = "SouthEast Asia"
resource_group_name = "${azurerm_resource_group.rg.name}"
network_interface_ids = ["${azurerm_network_interface.vsec-eth0.id}", "${azurerm_network_interface.vsec-eth1.id}"]
primary_network_interface_id = "${azurerm_network_interface.vsec-eth0.id}"
availability_set_id = "${azurerm_availability_set.avset.id}"
vm_size = "Standard_D2S_v3"
storage_os_disk {
name = "vsec01-osdisk"
caching = "ReadWrite"
create_option = "FromImage"
managed_disk_type = "Standard_LRS"
}
storage_image_reference {
publisher = "checkpoint"
offer = "check-point-vsec-r80"
sku = "sg-byol"
version = "latest"
}
plan {
name = "sg-byol"
publisher = "checkpoint"
product = "check-point-vsec-r80"
}
os_profile {
computer_name = "vsec01"
admin_username = "azureuser"
admin_password = "password"
custom_data = <<EOF
#!/bin/bash
clish -c 'set hostname vsec01' -s
cat <<EEOFF >$FWDIR/conf/azure-ha.json
{
"debug": false,
"subscriptionId": "subscription_id",
"location": "southeastasia",
"environment": "AzureCloud",
"resourceGroup": "rg-firewall",
"credentials": {
"tenant": "tenant_id",
"grant_type": "client_credentials",
"client_id": "",
"client_secret": ""
},
"proxy": "",
"virtualNetwork": "vnet-firewall",
"clusterName": "vsec0",
"clusterNetworkInterfaces": {
"eth0": [
"172.16.1.12",
"vsec0"
]
},
"lbName": ""
}
EEOFF
azure-ha-conf --client-id client_id' --client-secret 'client_secret' --force
/opt/CPda/bin/dastop
config_system -s 'install_security_gw=true&install_ppak=true&gateway_cluster_member=true&install_security_managment=false&ipstat_v6=off&ftw_sic_key=sic_key'
/opt/CPda/bin/dastart
shutdown -r now
EOF
}
os_profile_linux_config {
disable_password_authentication = false
}
boot_diagnostics {
enabled = "true"
storage_uri = "${azurerm_storage_account.mystorageaccount.primary_blob_endpoint}"
}
}
resource "azurerm_virtual_machine" "vsec02" {
name = "vsec02"
location = "SouthEast Asia"
resource_group_name = "${azurerm_resource_group.rg.name}"
network_interface_ids = ["${azurerm_network_interface.vsec2-eth0.id}", "${azurerm_network_interface.vsec2-eth1.id}"]
primary_network_interface_id = "${azurerm_network_interface.vsec2-eth0.id}"
availability_set_id = "${azurerm_availability_set.avset.id}"
vm_size = "Standard_D2S_v3"
storage_os_disk {
name = "vsec02-osdisk"
caching = "ReadWrite"
create_option = "FromImage"
managed_disk_type = "Standard_LRS"
}
storage_image_reference {
publisher = "checkpoint"
offer = "check-point-vsec-r80"
sku = "sg-byol"
version = "latest"
}
plan {
name = "sg-byol"
publisher = "checkpoint"
product = "check-point-vsec-r80"
}
os_profile {
computer_name = "vsec02"
admin_username = "azureuser"
admin_password = "password"
custom_data = <<EOF
#!/bin/bash
clish -c 'set hostname vsec02' -s
cat <<EEOFF >$FWDIR/conf/azure-ha.json
{
"debug": false,
"subscriptionId": "subscription_id",
"location": "southeastasia",
"environment": "AzureCloud",
"resourceGroup": "rg-firewall",
"credentials": {
"tenant": "tenant_id",
"grant_type": "client_credentials",
"client_id": "",
"client_secret": ""
},
"proxy": "",
"virtualNetwork": "vnet-firewall",
"clusterName": "vsec0",
"clusterNetworkInterfaces": {
"eth0": [
"172.16.1.12",
"vsec0"
]
},
"lbName": ""
}
EEOFF
azure-ha-conf --client-id client_id' --client-secret 'client_secret' --force
/opt/CPda/bin/dastop
config_system -s 'install_security_gw=true&install_ppak=true&gateway_cluster_member=true&install_security_managment=false&ipstat_v6=off&ftw_sic_key=sic_key'
/opt/CPda/bin/dastart
shutdown -r now
EOF
}
os_profile_linux_config {
disable_password_authentication = false
}
boot_diagnostics {
enabled = "true"
storage_uri = "${azurerm_storage_account.mystorageaccount.primary_blob_endpoint}"
}
}