Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Remove provider config from module" #76

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 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 @@ -89,7 +81,6 @@ A virtual machine or virtual machine scale set.
| <a name="input_endpoint_protection_upgrade_minor_version"></a> [endpoint\_protection\_upgrade\_minor\_version](#input\_endpoint\_protection\_upgrade\_minor\_version) | Specifies if the platform deploys the latest minor version Endpoint Protection update to the type\_handler\_version specified. | `bool` | `true` | no |
| <a name="input_env"></a> [env](#input\_env) | Environment name. | `string` | n/a | yes |
| <a name="input_install_azure_monitor"></a> [install\_azure\_monitor](#input\_install\_azure\_monitor) | Install Azure Monitor Agent. | `bool` | `true` | no |
| <a name="input_install_docker"></a> [install\_docker](#input\_install\_docker) | Should Docker and Docker Compose be installed -- Ubuntu only | `bool` | `false` | no |
| <a name="input_install_dynatrace_oneagent"></a> [install\_dynatrace\_oneagent](#input\_install\_dynatrace\_oneagent) | Install Dynatrace OneAgent. | `bool` | `true` | no |
| <a name="input_install_endpoint_protection"></a> [install\_endpoint\_protection](#input\_install\_endpoint\_protection) | Install Endpoint Protection. | `bool` | `true` | no |
| <a name="input_install_nessus_agent"></a> [install\_nessus\_agent](#input\_install\_nessus\_agent) | Install Nessus Agent. | `bool` | `true` | 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."
# }
2 changes: 1 addition & 1 deletion providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
configuration_aliases = [azurerm.cnp, azurerm.soc, azurerm.dcr]
configuration_aliases = [azurerm.cnp, azurerm.soc]
}
}
}
2 changes: 0 additions & 2 deletions run_command.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ resource "azurerm_virtual_machine_scale_set_extension" "azure_vmss_run_command"
RUN_XDR_AGENT = var.run_xdr_agent ? "true" : "false"
ENV = var.xdr_env == "prod" ? var.xdr_env : "nonprod"
XDR_TAGS = lower(local.xdr_tags_list)
INSTALL_DOCKER = var.install_docker ? "true" : "false"
})) }) : jsonencode({ script = compact(tolist([templatefile("${path.module}/scripts/windows_run_script.ps1", {
STORAGE_ACCOUNT_KEY = var.run_command_sa_key
RUN_CIS = var.rc_script_file == "scripts/windows_cis.ps1" || var.run_cis ? "true" : "false"
Expand Down Expand Up @@ -45,7 +44,6 @@ resource "azurerm_virtual_machine_extension" "azure_vm_run_command" {
RUN_XDR_AGENT = var.run_xdr_agent ? "true" : "false"
ENV = var.xdr_env == "prod" ? var.xdr_env : "nonprod"
XDR_TAGS = lower(local.xdr_tags_list)
INSTALL_DOCKER = var.install_docker ? "true" : "false"
})) }) : jsonencode({ script = compact(tolist([templatefile("${path.module}/scripts/windows_run_script.ps1", {
STORAGE_ACCOUNT_KEY = var.run_command_sa_key
RUN_CIS = var.rc_script_file == "scripts/windows_cis.ps1" || var.run_cis ? "true" : "false"
Expand Down
7 changes: 0 additions & 7 deletions tests/linux_vm_extensions.tftest.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@ provider "azurerm" {
skip_provider_registration = true
}

provider "azurerm" {
alias = "dcr"
features {}
subscription_id = var.env=="prod" || var.env=="production" ? "8999dec3-0104-4a27-94ee-6588559729d1" : var.env=="sbox" || var.env=="sandbox" ? "bf308a5c-0624-4334-8ff8-8dca9fd43783" : "1c4f0704-a29e-403d-b719-b90c34ef14c9"
skip_provider_registration = true
}

# Default variables for this test
variables {
env = "nonprod"
Expand Down
7 changes: 0 additions & 7 deletions tests/linux_vmss_extensions.tftest.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@ provider "azurerm" {
skip_provider_registration = true
}

provider "azurerm" {
alias = "dcr"
features {}
subscription_id = var.env=="prod" || var.env=="production" ? "8999dec3-0104-4a27-94ee-6588559729d1" : var.env=="sbox" || var.env=="sandbox" ? "bf308a5c-0624-4334-8ff8-8dca9fd43783" : "1c4f0704-a29e-403d-b719-b90c34ef14c9"
skip_provider_registration = true
}

# Default variables for this test
variables {
env = "nonprod"
Expand Down
7 changes: 0 additions & 7 deletions tests/windows_vm_extensions.tftest.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@ provider "azurerm" {
skip_provider_registration = true
}

provider "azurerm" {
alias = "dcr"
features {}
subscription_id = var.env=="prod" || var.env=="production" ? "8999dec3-0104-4a27-94ee-6588559729d1" : var.env=="sbox" || var.env=="sandbox" ? "bf308a5c-0624-4334-8ff8-8dca9fd43783" : "1c4f0704-a29e-403d-b719-b90c34ef14c9"
skip_provider_registration = true
}

# Default variables for this test
variables {
env = "nonprod"
Expand Down
7 changes: 0 additions & 7 deletions tests/windows_vmss_extensions.tftest.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@ provider "azurerm" {
skip_provider_registration = true
}

provider "azurerm" {
alias = "dcr"
features {}
subscription_id = var.env=="prod" || var.env=="production" ? "8999dec3-0104-4a27-94ee-6588559729d1" : var.env=="sbox" || var.env=="sandbox" ? "bf308a5c-0624-4334-8ff8-8dca9fd43783" : "1c4f0704-a29e-403d-b719-b90c34ef14c9"
skip_provider_registration = true
}

# Default variables for this test
variables {
env = "nonprod"
Expand Down
7 changes: 1 addition & 6 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ variable "run_xdr_collector" {
description = "Install XDR collectors using run command script?"
}


variable "run_xdr_agent" {
type = bool
default = false
Expand All @@ -353,12 +354,6 @@ variable "xdr_env" {
default = "prod"
}

variable "install_docker" {
description = "Should Docker and Docker Compose be installed -- Ubuntu only"
type = bool
default = false
}

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