Skip to content

Commit

Permalink
Merge pull request #70 from hmcts/ieuanb74-patch-2
Browse files Browse the repository at this point in the history
Remove provider and dcr related code
  • Loading branch information
ieuanb74 authored Sep 6, 2024
2 parents 5c075e7 + b2c2a4f commit 3267df2
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 104 deletions.
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,12 @@ A virtual machine or virtual machine scale set.
|------|---------|
| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | n/a |
| <a name="provider_azurerm.cnp"></a> [azurerm.cnp](#provider\_azurerm.cnp) | n/a |
| <a name="provider_azurerm.dcr"></a> [azurerm.dcr](#provider\_azurerm.dcr) | n/a |
| <a name="provider_azurerm.soc"></a> [azurerm.soc](#provider\_azurerm.soc) | n/a |

## Resources

| Name | Type |
|------|------|
| [azurerm_monitor_data_collection_rule_association.linux_vm_dcra](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_data_collection_rule_association) | resource |
| [azurerm_monitor_data_collection_rule_association.linux_vmss_dcra](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_data_collection_rule_association) | resource |
| [azurerm_monitor_data_collection_rule_association.windows_vm_dcra](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_data_collection_rule_association) | resource |
| [azurerm_monitor_data_collection_rule_association.windows_vmss_dcra](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_data_collection_rule_association) | resource |
| [azurerm_virtual_machine_extension.azure_monitor](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_machine_extension) | resource |
| [azurerm_virtual_machine_extension.azure_vm_run_command](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_machine_extension) | resource |
| [azurerm_virtual_machine_extension.custom_script](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_machine_extension) | resource |
Expand All @@ -56,9 +51,6 @@ A virtual machine or virtual machine scale set.
| [azurerm_key_vault_secret.splunk_password](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/key_vault_secret) | data source |
| [azurerm_key_vault_secret.splunk_username](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/key_vault_secret) | data source |
| [azurerm_key_vault_secret.token](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/key_vault_secret) | data source |
| [azurerm_monitor_data_collection_rule.linux_data_collection_rule](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/monitor_data_collection_rule) | data source |
| [azurerm_monitor_data_collection_rule.windows_data_collection_rule](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/monitor_data_collection_rule) | data source |
| [azurerm_resource_group.la_rg](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/resource_group) | data source |

## Inputs

Expand Down Expand Up @@ -94,8 +86,6 @@ A virtual machine or virtual machine scale set.
| <a name="input_install_nessus_agent"></a> [install\_nessus\_agent](#input\_install\_nessus\_agent) | Install Nessus Agent. | `bool` | `true` | no |
| <a name="input_install_splunk_uf"></a> [install\_splunk\_uf](#input\_install\_splunk\_uf) | Install Splunk UF. | `bool` | `true` | no |
| <a name="input_location"></a> [location](#input\_location) | The region in Azure that the Data collection rule will be deployed to. | `string` | `"UK South"` | no |
| <a name="input_log_analytics_sub_id"></a> [log\_analytics\_sub\_id](#input\_log\_analytics\_sub\_id) | A map of log analytics workspace names and their subscription IDs. | `map(string)` | <pre>{<br> "hmcts-nonprod": "1c4f0704-a29e-403d-b719-b90c34ef14c9",<br> "hmcts-prod": "8999dec3-0104-4a27-94ee-6588559729d1",<br> "hmcts-sandbox": "bf308a5c-0624-4334-8ff8-8dca9fd43783"<br>}</pre> | no |
| <a name="input_log_analytics_workspace_names"></a> [log\_analytics\_workspace\_names](#input\_log\_analytics\_workspace\_names) | A map of environments and their corresponding log analytics workspace names. | `map(string)` | <pre>{<br> "aat": "hmcts-nonprod",<br> "demo": "hmcts-nonprod",<br> "ithc": "hmcts-nonprod",<br> "nonprod": "hmcts-nonprod",<br> "perftest": "hmcts-nonprod",<br> "prod": "hmcts-prod",<br> "production": "hmcts-prod",<br> "ptl": "hmcts-prod",<br> "ptlsbox": "hmcts-sandbox",<br> "sandbox": "hmcts-sandbox",<br> "sbox": "hmcts-sandbox",<br> "staging": "hmcts-nonprod",<br> "stg": "hmcts-nonprod",<br> "test": "hmcts-nonprod"<br>}</pre> | no |
| <a name="input_nessus_groups"></a> [nessus\_groups](#input\_nessus\_groups) | Nessus group name. | `string` | `"Platform-Operation-Bastions"` | no |
| <a name="input_nessus_key"></a> [nessus\_key](#input\_nessus\_key) | Nessus linking key - read input from keyvault. | `string` | `null` | no |
| <a name="input_nessus_server"></a> [nessus\_server](#input\_nessus\_server) | Nessus server endpoint - read input from keyvault. | `string` | `""` | no |
Expand Down
105 changes: 52 additions & 53 deletions azure_monitor.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,56 +26,55 @@ resource "azurerm_virtual_machine_extension" "azure_monitor" {
tags = var.common_tags
}

data "azurerm_resource_group" "la_rg" {
provider = azurerm.dcr
name = "oms-automation"
}

data "azurerm_monitor_data_collection_rule" "linux_data_collection_rule" {
provider = azurerm.dcr
name = "ama-linux-vm-logs"
resource_group_name = data.azurerm_resource_group.la_rg.name
}

data "azurerm_monitor_data_collection_rule" "windows_data_collection_rule" {
provider = azurerm.dcr
name = "ama-windows-vm-logs"
resource_group_name = data.azurerm_resource_group.la_rg.name
}


resource "azurerm_monitor_data_collection_rule_association" "linux_vm_dcra" {
count = var.install_azure_monitor == true && lower(var.os_type) == "linux" && var.virtual_machine_type == "vm" ? 1 : 0

name = "vm-${local.vm_name}-dcra"
target_resource_id = var.virtual_machine_id
data_collection_rule_id = data.azurerm_monitor_data_collection_rule.linux_data_collection_rule.id
description = "Association between a linux VM and the appropriate data collection rule."
}

resource "azurerm_monitor_data_collection_rule_association" "linux_vmss_dcra" {
count = var.install_azure_monitor == true && lower(var.os_type) == "linux" && var.virtual_machine_type == "vmss" ? 1 : 0

name = "vmss-${local.vmss_name}-dcra"
target_resource_id = var.virtual_machine_scale_set_id
data_collection_rule_id = data.azurerm_monitor_data_collection_rule.linux_data_collection_rule.id
description = "Association between a linux VMSS and the appropriate data collection rule."
}

resource "azurerm_monitor_data_collection_rule_association" "windows_vm_dcra" {
count = var.install_azure_monitor == true && lower(var.os_type) == "windows" && var.virtual_machine_type == "vm" ? 1 : 0

name = "vm-${local.vm_name}-dcra"
target_resource_id = var.virtual_machine_id
data_collection_rule_id = data.azurerm_monitor_data_collection_rule.windows_data_collection_rule.id
description = "Association between a windows VM and the appropriate data collection rule."
}

resource "azurerm_monitor_data_collection_rule_association" "windows_vmss_dcra" {
count = var.install_azure_monitor == true && lower(var.os_type) == "windows" && var.virtual_machine_type == "vmss" ? 1 : 0

name = "vmss-${local.vmss_name}-dcra"
target_resource_id = var.virtual_machine_scale_set_id
data_collection_rule_id = data.azurerm_monitor_data_collection_rule.windows_data_collection_rule.id
description = "Association between a windows VMSS and the appropriate data collection rule."
}
# data "azurerm_resource_group" "la_rg" {
# name = "oms-automation"
# }

# data "azurerm_monitor_data_collection_rule" "linux_data_collection_rule" {
# provider = azurerm.dcr
# name = "ama-linux-vm-logs"
# resource_group_name = data.azurerm_resource_group.la_rg.name
# }

# data "azurerm_monitor_data_collection_rule" "windows_data_collection_rule" {
# provider = azurerm.dcr
# name = "ama-windows-vm-logs"
# resource_group_name = data.azurerm_resource_group.la_rg.name
# }


# resource "azurerm_monitor_data_collection_rule_association" "linux_vm_dcra" {
# count = var.install_azure_monitor == true && lower(var.os_type) == "linux" && var.virtual_machine_type == "vm" ? 1 : 0

# name = "vm-${local.vm_name}-dcra"
# target_resource_id = var.virtual_machine_id
# data_collection_rule_id = data.azurerm_monitor_data_collection_rule.linux_data_collection_rule.id
# description = "Association between a linux VM and the appropriate data collection rule."
# }

# resource "azurerm_monitor_data_collection_rule_association" "linux_vmss_dcra" {
# count = var.install_azure_monitor == true && lower(var.os_type) == "linux" && var.virtual_machine_type == "vmss" ? 1 : 0

# name = "vmss-${local.vmss_name}-dcra"
# target_resource_id = var.virtual_machine_scale_set_id
# data_collection_rule_id = data.azurerm_monitor_data_collection_rule.linux_data_collection_rule.id
# description = "Association between a linux VMSS and the appropriate data collection rule."
# }

# resource "azurerm_monitor_data_collection_rule_association" "windows_vm_dcra" {
# count = var.install_azure_monitor == true && lower(var.os_type) == "windows" && var.virtual_machine_type == "vm" ? 1 : 0

# name = "vm-${local.vm_name}-dcra"
# target_resource_id = var.virtual_machine_id
# data_collection_rule_id = data.azurerm_monitor_data_collection_rule.windows_data_collection_rule.id
# description = "Association between a windows VM and the appropriate data collection rule."
# }

# resource "azurerm_monitor_data_collection_rule_association" "windows_vmss_dcra" {
# count = var.install_azure_monitor == true && lower(var.os_type) == "windows" && var.virtual_machine_type == "vmss" ? 1 : 0

# name = "vmss-${local.vmss_name}-dcra"
# target_resource_id = var.virtual_machine_scale_set_id
# data_collection_rule_id = data.azurerm_monitor_data_collection_rule.windows_data_collection_rule.id
# description = "Association between a windows VMSS and the appropriate data collection rule."
# }
3 changes: 0 additions & 3 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ locals {

xdr_tags_list = var.xdr_tags != null ? join(",", [var.xdr_tags, "hmcts,server"]) : "hmcts,server"

log_analytics_workspace = var.log_analytics_workspace_names[var.env]
log_analytics_subscription = var.log_analytics_sub_id[local.log_analytics_workspace]

vm_name = var.virtual_machine_id != null ? regex("virtualMachines/([^/]+)", var.virtual_machine_id)[0] : null
vmss_name = var.virtual_machine_scale_set_id != null ? regex("virtualMachineScaleSets/([^/]+)", var.virtual_machine_scale_set_id)[0] : null

Expand Down
6 changes: 0 additions & 6 deletions providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,3 @@ terraform {
}
}
}

provider "azurerm" {
alias = "dcr"
features {}
subscription_id = local.log_analytics_subscription
}
32 changes: 0 additions & 32 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@ variable "soc_vault_name" {
default = "soc-prod"
}


variable "run_command_sa_key" {
description = "SA key for the run command"
default = ""
Expand Down Expand Up @@ -355,37 +354,6 @@ variable "xdr_env" {
default = "prod"
}

variable "log_analytics_workspace_names" {
type = map(string)
default = {
"production" = "hmcts-prod"
"prod" = "hmcts-prod"
"ptl" = "hmcts-prod"
"nonprod" = "hmcts-nonprod"
"aat" = "hmcts-nonprod"
"staging" = "hmcts-nonprod"
"stg" = "hmcts-nonprod"
"demo" = "hmcts-nonprod"
"perftest" = "hmcts-nonprod"
"test" = "hmcts-nonprod"
"ithc" = "hmcts-nonprod"
"sandbox" = "hmcts-sandbox"
"sbox" = "hmcts-sandbox"
"ptlsbox" = "hmcts-sandbox"
}
description = "A map of environments and their corresponding log analytics workspace names."
}

variable "log_analytics_sub_id" {
description = "A map of log analytics workspace names and their subscription IDs."
type = map(string)
default = {
"hmcts-prod" = "8999dec3-0104-4a27-94ee-6588559729d1"
"hmcts-nonprod" = "1c4f0704-a29e-403d-b719-b90c34ef14c9"
"hmcts-sandbox" = "bf308a5c-0624-4334-8ff8-8dca9fd43783"
}
}

variable "location" {
description = "The region in Azure that the Data collection rule will be deployed to."
type = string
Expand Down

0 comments on commit 3267df2

Please sign in to comment.