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

feat: support application insights on different rg #377

Merged
merged 2 commits into from
Nov 16, 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ proxy_url = VALUE
| <a name="input_allow_ssh_cidrs"></a> [allow\_ssh\_cidrs](#input\_allow\_ssh\_cidrs) | Allow port 22, if not provided, i.e leaving the default empty list, the rule will not be included in the SG | `list(string)` | `[]` | no |
| <a name="input_allow_weka_api_cidrs"></a> [allow\_weka\_api\_cidrs](#input\_allow\_weka\_api\_cidrs) | Allow connection to port 14000 on weka backends from specified CIDRs, by default no CIDRs are allowed. All ports (including 14000) are allowed within Vnet | `list(string)` | `[]` | no |
| <a name="input_application_insights_name"></a> [application\_insights\_name](#input\_application\_insights\_name) | The Application Insights name. | `string` | `""` | no |
| <a name="input_application_insights_rg_name"></a> [application\_insights\_rg\_name](#input\_application\_insights\_rg\_name) | The Application Insights resource group name. | `string` | `""` | no |
| <a name="input_apt_repo_server"></a> [apt\_repo\_server](#input\_apt\_repo\_server) | The URL of the apt private repository. | `string` | `""` | no |
| <a name="input_assign_public_ip"></a> [assign\_public\_ip](#input\_assign\_public\_ip) | Determines whether to assign public IP to all instances deployed by TF module. Includes backends, clients and protocol gateways. | `string` | `"auto"` | no |
| <a name="input_client_arch"></a> [client\_arch](#input\_client\_arch) | Use arch for ami id, value can be arm64/x86\_64. | `string` | `null` | no |
Expand Down
13 changes: 7 additions & 6 deletions functions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ locals {
install_weka_url = var.install_weka_url != "" ? var.install_weka_url : "https://[email protected]/dist/v1/install/${var.weka_version}/${var.weka_version}"
supported_regions = split("\n", replace(chomp(file("${path.module}/supported_regions/${var.function_app_dist}.txt")), "\r", ""))
# log analytics for function app
log_analytics_workspace_id = var.enable_application_insights ? var.log_analytics_workspace_id == "" ? azurerm_log_analytics_workspace.la_workspace[0].id : var.log_analytics_workspace_id : ""
application_insights_id = var.enable_application_insights ? var.application_insights_name == "" ? azurerm_application_insights.application_insights[0].id : data.azurerm_application_insights.application_insights[0].id : ""
insights_instrumenation_key = var.enable_application_insights ? var.application_insights_name == "" ? azurerm_application_insights.application_insights[0].instrumentation_key : data.azurerm_application_insights.application_insights[0].instrumentation_key : ""
log_analytics_workspace_id = var.enable_application_insights ? var.log_analytics_workspace_id == "" ? azurerm_log_analytics_workspace.la_workspace[0].id : var.log_analytics_workspace_id : ""
application_insights_id = var.enable_application_insights ? var.application_insights_name == "" ? azurerm_application_insights.application_insights[0].id : data.azurerm_application_insights.application_insights[0].id : ""
application_insights_rg_name = var.application_insights_rg_name == "" ? var.rg_name : var.application_insights_rg_name
insights_instrumenation_key = var.enable_application_insights ? var.application_insights_name == "" ? azurerm_application_insights.application_insights[0].instrumentation_key : data.azurerm_application_insights.application_insights[0].instrumentation_key : ""
# nfs autoscaling
nfs_deployment_container_name = var.nfs_deployment_container_name == "" ? "${local.alphanumeric_prefix_name}${local.alphanumeric_cluster_name}-protocol-deployment" : var.nfs_deployment_container_name

Expand Down Expand Up @@ -199,7 +200,7 @@ resource "azurerm_log_analytics_workspace" "la_workspace" {
count = var.log_analytics_workspace_id == "" && var.enable_application_insights ? 1 : 0
name = "${local.alphanumeric_prefix_name}-${local.alphanumeric_cluster_name}-workspace"
location = data.azurerm_resource_group.rg.location
resource_group_name = data.azurerm_resource_group.rg.name
resource_group_name = var.rg_name
sku = "PerGB2018"
retention_in_days = 30
lifecycle {
Expand All @@ -210,14 +211,14 @@ resource "azurerm_log_analytics_workspace" "la_workspace" {
data "azurerm_application_insights" "application_insights" {
count = var.application_insights_name != "" && var.enable_application_insights ? 1 : 0
name = var.application_insights_name
resource_group_name = data.azurerm_resource_group.rg.name
resource_group_name = local.application_insights_rg_name
}

resource "azurerm_application_insights" "application_insights" {
count = var.application_insights_name == "" && var.enable_application_insights ? 1 : 0
name = "${var.prefix}-${var.cluster_name}-application-insights"
location = data.azurerm_resource_group.rg.location
resource_group_name = data.azurerm_resource_group.rg.name
resource_group_name = local.application_insights_rg_name
workspace_id = local.log_analytics_workspace_id
application_type = "web"
lifecycle {
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,12 @@ variable "application_insights_name" {
default = ""
}

variable "application_insights_rg_name" {
type = string
description = "The Application Insights resource group name."
default = ""
}

variable "enable_application_insights" {
type = bool
default = true
Expand Down