-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [PAYMCLOUD-98] terraform monitoring function refactor with new …
…container app job resource (#359) * Refactor monitoring job to use azurerm_container_app_job Reworked the monitoring job resource from azapi_resource to azurerm_container_app_job for improved maintainability and compatibility. * Standardize secret names to lowercase Updated the secret names in the monitoring function configuration to consistent lowercase format. * Refactor secret names to use hyphenated format Updated the secret names in `01_main.tf` to use hyphens instead of underscores. * Add alert auto-mitigation variable Introduce a new variable `alert_set_auto_mitigate` to control if metric alerts should auto-resolve, defaulting to true. Updated the README to document this new optional input. * Add azapi support and conditionally manage app job resources Added azapi provider and introduced a "legacy" variable to toggle between legacy and new resource provisioning methods. Modified container app job resource definitions to either use azapi or azurerm based on the "legacy" setting, ensuring a smoother transition and rollback capability. * Add Terraform configuration for monitoring function test environment * Remove .terraform-version file This file was specifying the Terraform version as 1.8.5. It is no longer needed and can be managed through other version control mechanisms. * Fix sequential resource creation-destruction comment * Format README files with consistent Markdown Replaced spaces between pre tags with slashes to ensure consistent formatting across all README files. This change does not alter the functionality but improves readability and uniformity in documentation. * Update Markdown formatting in README files for consistency Converted newline characters from escaped newlines to plain newlines in code blocks within multiple README.md files. This change enhances readability and maintains a consistent formatting style across the documentation. * Add auto_mitigate option to alert configuration Added the "auto_mitigate" field to the alert configuration in the README.md and 01_main.tf files. This new optional parameter allows automatic resolution of alerts and defaults to true. Adjusted documentation and local variables to accommodate this change. * Update README formatting for input parameter tables Fixed markdown formatting issues for several input parameter tables in the README. This ensures better readability and consistent styling throughout the documentation.
- Loading branch information
Showing
14 changed files
with
522 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
resource "azurerm_resource_group" "synthetic_rg" { | ||
location = var.location | ||
name = "${local.project}-rg" | ||
} | ||
|
||
|
||
resource "azurerm_log_analytics_workspace" "log_analytics_workspace" { | ||
name = "${local.project}-law" | ||
location = azurerm_resource_group.synthetic_rg.location | ||
resource_group_name = azurerm_resource_group.synthetic_rg.name | ||
sku = var.law_sku | ||
retention_in_days = var.law_retention_in_days | ||
daily_quota_gb = var.law_daily_quota_gb | ||
|
||
tags = var.tags | ||
} | ||
|
||
# Application insights | ||
resource "azurerm_application_insights" "application_insights" { | ||
name = "${local.project}-appinsights" | ||
location = azurerm_resource_group.synthetic_rg.location | ||
resource_group_name = azurerm_resource_group.synthetic_rg.name | ||
application_type = "other" | ||
|
||
workspace_id = azurerm_log_analytics_workspace.log_analytics_workspace.id | ||
|
||
tags = var.tags | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
subscription=DevOpsLab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
resource "random_id" "unique" { | ||
byte_length = 3 | ||
} | ||
|
||
locals { | ||
project = "${var.prefix}${substr(random_id.unique.hex, 0, 1)}" | ||
rg_name = "${local.project}-${substr(random_id.unique.hex, 0, 1)}-rg" | ||
key_vault_name = "${local.project}-kv" | ||
vnet_name = "${local.project}-vnet" | ||
subnet_name = "${local.project}-subnet" | ||
law_name = "${local.project}-runner-law" | ||
environment_name = "${local.project}-runner-cae" | ||
} | ||
|
||
locals { | ||
product = "${var.prefix}-${var.env_short}" | ||
domain = "synthetic" | ||
|
||
|
||
monitor_appinsights_name = "${local.product}-appinsights" | ||
monitor_action_group_slack_name = "SlackPagoPA" | ||
monitor_action_group_email_name = "PagoPA" | ||
monitor_resource_group_name = "${local.product}-monitor-rg" | ||
|
||
vnet_core_resource_group_name = "${local.product}-vnet-rg" | ||
vnet_core_name = "${local.product}-vnet" | ||
log_analytics_workspace_name = "${local.product}-law" | ||
log_analytics_workspace_resource_group_name = "${local.product}-monitor-rg" | ||
|
||
|
||
} |
18 changes: 18 additions & 0 deletions
18
monitoring_function/tests/monitoring_configuration.json.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[ | ||
{ | ||
"apiName" : "root", | ||
"appName" : "pagopa", | ||
"url" : "https://${api_dot_env_name}.platform.pagopa.it/", | ||
"type" : "public", | ||
"checkCertificate" : true, | ||
"method" : "GET", | ||
"expectedCodes" : ["200"], | ||
"tags" : { | ||
"description" : "pagopa ${env_name} context root" | ||
}, | ||
"durationLimit" : 10000, | ||
"alertConfiguration" : { | ||
"enabled" : false | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
output "random_id" { | ||
value = random_id.unique.hex | ||
} | ||
|
||
output "subnet_name" { | ||
value = azurerm_subnet.subnet.name | ||
description = "Subnet name" | ||
} | ||
|
||
output "subnet_cidr" { | ||
value = azurerm_subnet.subnet.address_prefixes | ||
description = "Subnet CIDR blocks" | ||
} | ||
|
||
output "cae_name" { | ||
value = azurerm_container_app_environment.container_app_environment.name | ||
description = "Container App Environment name" | ||
} |
Oops, something went wrong.