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

GA-52-P6-SingleUser #1769

Open
wants to merge 57 commits into
base: GA_PRM_Master
Choose a base branch
from
Open

GA-52-P6-SingleUser #1769

wants to merge 57 commits into from

Conversation

prashanthkumarnb
Copy link
Contributor

@prashanthkumarnb prashanthkumarnb commented Feb 22, 2024

# Conflicts:
#	src/integrationTest/java/uk/gov/hmcts/reform/orgrolemapping/controller/RefreshControllerIntegrationTest.java
#	src/integrationTest/java/uk/gov/hmcts/reform/orgrolemapping/controller/RefreshControllerRefreshJobIntegrationTest.java
@helenbirdhmcts helenbirdhmcts self-requested a review March 25, 2024 11:47
@shaed-parkar shaed-parkar dismissed abul-syed’s stale review March 26, 2024 14:18

issues have been addressed but Abul is not on the project anymore

@hmcts-jenkins-a-to-c
Copy link
Contributor

Plan Result (aat)

⚠️ Resource Deletion will happen ⚠️

This plan contains resource delete operation. Please check the plan result very carefully!

Plan: 21 to add, 0 to change, 2 to destroy.
  • Create
    • module.am-prm-action-group.azurerm_resource_group_template_deployment.action-group
    • module.prm-process-failure-alerts["prm-process-1"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-failure-alerts["prm-process-2"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-failure-alerts["prm-process-3"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-failure-alerts["prm-process-4"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-failure-alerts["prm-process-5"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-failure-alerts["prm-process-6"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-not-completed-alerts["prm-process-1"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-not-completed-alerts["prm-process-2"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-not-completed-alerts["prm-process-3"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-not-completed-alerts["prm-process-4"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-not-completed-alerts["prm-process-5"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-not-completed-alerts["prm-process-6"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-not-started-alerts["prm-process-1"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-not-started-alerts["prm-process-2"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-not-started-alerts["prm-process-3"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-not-started-alerts["prm-process-4"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-not-started-alerts["prm-process-5"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-not-started-alerts["prm-process-6"].azurerm_resource_group_template_deployment.custom_alert[0]
  • Replace
    • module.org-role-mapping-database-v15.null_resource.set-schema-ownership["org_role_mapping"]
    • module.org-role-mapping-database-v15.null_resource.set-user-permissions-additionaldbs["org_role_mapping"]
Change Result (Click me)
  # module.am-prm-action-group.azurerm_resource_group_template_deployment.action-group will be created
  + resource "azurerm_resource_group_template_deployment" "action-group" {
      + deployment_mode     = "Incremental"
      + id                  = (known after apply)
      + name                = "am-prm-support"
      + output_content      = (known after apply)
      + parameters_content  = (sensitive value)
      + resource_group_name = "am-shared-infrastructure-aat"
      + template_content    = jsonencode(
            {
              + "$schema"      = "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#"
              + contentVersion = "1.0.0.0"
              + parameters     = {
                  + actionGroupName      = {
                      + type = "string"
                    }
                  + emailReceiverAddress = {
                      + metadata = {
                          + description = "Email address of the receiver"
                        }
                      + type     = "string"
                    }
                  + emailReceiverName    = {
                      + metadata = {
                          + description = "Name of the email receiver"
                        }
                      + type     = "string"
                    }
                  + location             = {
                      + defaultValue = "global"
                      + type         = "string"
                    }
                  + shortName            = {
                      + type = "string"
                    }
                }
              + resources      = [
                  + {
                      + apiVersion = "2017-04-01"
                      + location   = "[parameters('location')]"
                      + name       = "[parameters('actionGroupName')]"
                      + properties = {
                          + emailReceivers   = [
                              + {
                                  + emailAddress = "[parameters('emailReceiverAddress')]"
                                  + name         = "[parameters('emailReceiverName')]"
                                },
                            ]
                          + enabled          = true
                          + groupShortName   = "[parameters('shortName')]"
                          + smsReceivers     = []
                          + webhookReceivers = []
                        }
                      + tags       = {}
                      + type       = "microsoft.insights/actionGroups"
                    },
                ]
            }
        )
    }

  # module.org-role-mapping-database-v15.null_resource.set-schema-ownership["org_role_mapping"] must be replaced
-/+ resource "null_resource" "set-schema-ownership" {
      ~ id       = "4314787180474489447" -> (known after apply)
      ~ triggers = { # forces replacement
          ~ "force_trigger" = "5" -> "4"
            # (2 unchanged elements hidden)
        }
    }

  # module.org-role-mapping-database-v15.null_resource.set-user-permissions-additionaldbs["org_role_mapping"] must be replaced
-/+ resource "null_resource" "set-user-permissions-additionaldbs" {
      ~ id       = "3220316387869115121" -> (known after apply)
      ~ triggers = { # forces replacement
          ~ "force_trigger"  = "5" -> "4"
            # (3 unchanged elements hidden)
        }
    }

  # module.prm-process-failure-alerts["prm-process-1"].azurerm_resource_group_template_deployment.custom_alert[0] will be created
  + resource "azurerm_resource_group_template_deployment" "custom_alert" {
      + deployment_mode     = "Incremental"
      + id                  = (known after apply)
      + name                = "am-prm-process-1-failure-alert"
      + output_content      = (known after apply)
      + parameters_content  = jsonencode(
            {
              + actionGroupName          = {
                  + value = "am-prm-support"
                }
              + actionGroupRg            = {
                  + value = "am-shared-infrastructure-aat"
                }
              + alertDesc                = {
                  + value = "Triggers when PRM Process 1 - Find Case Definition Changes fails am-aat."
                }
              + alertName                = {
                  + value = "am-prm-process-1-failure-alert"
                }
              + appInsightsName          = {
                  + value = "am-aat"
                }
              + appInsightsQuery         = {
                  + value = "customEvents | where name == 'PRM Process 1 - Find Case Definition Changes - Failed'"
                }
              + commonTags               = {
                  + value = "eyJhcHBsaWNhdGlvbiI6ImFjY2Vzcy1tYW5hZ2VtZW50IiwiYXV0b1NodXRkb3duIjoidHJ1ZSIsImJ1aWx0RnJvbSI6Imh0dHBzOi8vZ2l0aHViLmNvbS9ITUNUUy9hbS1vcmctcm9sZS1tYXBwaW5nLXNlcnZpY2UuZ2l0IiwiYnVzaW5lc3NBcmVhIjoiQ0ZUIiwiY29udGFjdFNsYWNrQ2hhbm5lbCI6IiNhbS1tYXN0ZXItYnVpbGRzIiwiZW52aXJvbm1lbnQiOiJzdGFnaW5nIiwibWFuYWdlZEJ5IjoiQU0ifQ=="
                }
              + customEmailSubject       = {
                  + value = "Alert: PRM Process 1 - Find Case Definition Changes failed in am-aat"
                }
              + frequencyInMinutes       = {
                  + value = "15"
                }
              + location                 = {
                  + value = "UK South"
                }
              + severityLevel            = {
                  + value = "2"
                }
              + timeWindowInMinutes      = {
                  + value = "10080"
                }
              + triggerThreshold         = {
                  + value = "0"
                }
              + triggerThresholdOperator = {
                  + value = "GreaterThan"
                }
            }
        )
      + resource_group_name = "am-shared-infrastructure-aat"
      + template_content    = jsonencode(
            {
              + "$schema"      = "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#"
              + contentVersion = "1.0.0.0"
              + parameters     = {
                  + actionGroupName          = {
                      + type = "string"
                    }
                  + actionGroupRg            = {
                      + type = "string"
                    }
                  + alertDesc                = {
                      + type = "string"
                    }
                  + alertName                = {
                      + type = "string"
                    }
                  + appInsightsName          = {
                      + type = "string"
                    }
                  + appInsightsQuery         = {
                      + type = "string"
                    }
                  + commonTags               = {
                      + type = "string"
                    }
                  + customEmailSubject       = {
                      + type = "string"
                    }
                  + frequencyInMinutes       = {
                      + defaultValue = "5"
                      + type         = "string"
                    }
                  + location                 = {
                      + type = "string"
                    }
                  + severityLevel            = {
                      + defaultValue = "3"
                      + type         = "string"
                    }
                  + timeWindowInMinutes      = {
                      + defaultValue = "5"
                      + type         = "string"
                    }
                  + triggerThreshold         = {
                      + type = "string"
                    }
                  + triggerThresholdOperator = {
                      + allowedValues = [
                          + "GreaterThan",
                          + "Equal",
                          + "LessThan",
                        ]
                      + defaultValue  = "GreaterThan"
                      + type          = "string"
                    }
                }
              + resources      = [
                  + {
                      + apiVersion = "2017-09-01-preview"
                      + location   = "[parameters('location')]"
                      + name       = "[parameters('alertName')]"
                      + properties = {
                          + action      = {
                              + aznsAction   = {
                                  + actionGroup  = [
                                      + "[resourceId(parameters('actionGroupRg'), 'microsoft.insights/actionGroups', parameters('actionGroupName'))]",
                                    ]
                                  + emailSubject = "[parameters('customEmailSubject')]"
                                }
                              + "odata.type" = "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction"
                              + severity     = "[parameters('severityLevel')]"
                              + status       = "Active"
                              + trigger      = {
                                  + consecutiveBreach = 1
                                  + threshold         = "[parameters('triggerThreshold')]"
                                  + thresholdOperator = "[parameters('triggerThresholdOperator')]"
                                }
                            }
                          + description = "[parameters('alertDesc')]"
                          + enabled     = "true"
                          + schedule    = {
                              + frequencyInMinutes  = "[parameters('frequencyInMinutes')]"
                              + timeWindowInMinutes = "[parameters('timeWindowInMinutes')]"
                            }
                          + skuType     = "L1"
                          + source      = {
                              + dataSourceId = "[resourceId('microsoft.insights/components', parameters('appInsightsName'))]"
                              + query        = "[parameters('appInsightsQuery')]"
                              + queryType    = "ResultCount"
                            }
                        }
                      + tags       = "[union(variables('tags'), variables('additionalTags'))]"
                      + type       = "microsoft.insights/scheduledqueryrules"
                    },
                ]
              + variables      = {
                  + additionalTags = {
                      + "[concat('hidden-link:', resourceId('microsoft.insights/components', parameters('appInsightsName')))]" = "Resource"
                    }
                  + tags           = "[base64ToJson(parameters('commonTags'))]"
                }
            }
        )
    }

  # module.prm-process-failure-alerts["prm-process-2"].azurerm_resource_group_template_deployment.custom_alert[0] will be created
  + resource "azurerm_resource_group_template_deployment" "custom_alert" {
      + deployment_mode     = "Incremental"
      + id                  = (known after apply)
      + name                = "am-prm-process-2-failure-alert"
      + output_content      = (known after apply)
      + parameters_content  = jsonencode(
            {
              + actionGroupName          = {
                  + value = "am-prm-support"
                }
              + actionGroupRg            = {
                  + value = "am-shared-infrastructure-aat"
                }
              + alertDesc                = {
                  + value = "Triggers when PRM Process 2 - Find Organisations with Stale Profiles fails am-aat."
                }
              + alertName                = {
                  + value = "am-prm-process-2-failure-alert"
                }
              + appInsightsName          = {
                  + value = "am-aat"
                }
              + appInsightsQuery         = {
                  + value = "customEvents | where name == 'PRM Process 2 - Find Organisations with Stale Profiles - Failed'"
                }
              + commonTags               = {
                  + value = "eyJhcHBsaWNhdGlvbiI6ImFjY2Vzcy1tYW5hZ2VtZW50IiwiYXV0b1NodXRkb3duIjoidHJ1ZSIsImJ1aWx0RnJvbSI6Imh0dHBzOi8vZ2l0aHViLmNvbS9ITUNUUy9hbS1vcmctcm9sZS1tYXBwaW5nLXNlcnZpY2UuZ2l0IiwiYnVzaW5lc3NBcmVhIjoiQ0ZUIiwiY29udGFjdFNsYWNrQ2hhbm5lbCI6IiNhbS1tYXN0ZXItYnVpbGRzIiwiZW52aXJvbm1lbnQiOiJzdGFnaW5nIiwibWFuYWdlZEJ5IjoiQU0ifQ=="
                }
              + customEmailSubject       = {
                  + value = "Alert: PRM Process 2 - Find Organisations with Stale Profiles failed in am-aat"
                }
              + frequencyInMinutes       = {
                  + value = "15"
                }
              + location                 = {
                  + value = "UK South"
                }
              + severityLevel            = {
                  + value = "2"
                }
              + timeWindowInMinutes      = {
                  + value = "10080"
                }
              + triggerThreshold         = {
                  + value = "0"
                }
              + triggerThresholdOperator = {
                  + value = "GreaterThan"
                }
            }
        )
      + resource_group_name = "am-shared-infrastructure-aat"
      + template_content    = jsonencode(
            {
              + "$schema"      = "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#"
              + contentVersion = "1.0.0.0"
              + parameters     = {
                  + actionGroupName          = {
                      + type = "string"
                    }
                  + actionGroupRg            = {
                      + type = "string"
                    }
                  + alertDesc                = {
                      + type = "string"
                    }
                  + alertName                = {
                      + type = "string"
                    }
                  + appInsightsName          = {
                      + type = "string"
                    }
                  + appInsightsQuery         = {
                      + type = "string"
                    }
                  + commonTags               = {
                      + type = "string"
                    }
                  + customEmailSubject       = {
                      + type = "string"
                    }
                  + frequencyInMinutes       = {
                      + defaultValue = "5"
                      + type         = "string"
                    }
                  + location                 = {
                      + type = "string"
                    }
                  + severityLevel            = {
                      + defaultValue = "3"
                      + type         = "string"
                    }
                  + timeWindowInMinutes      = {
                      + defaultValue = "5"
                      + type         = "string"
                    }
                  + triggerThreshold         = {
                      + type = "string"
                    }
                  + triggerThresholdOperator = {
                      + allowedValues = [
                          + "GreaterThan",
                          + "Equal",
                          + "LessThan",
                        ]
                      + defaultValue  = "GreaterThan"
                      + type          = "string"
                    }
                }
              + resources      = [
                  + {
                      + apiVersion = "2017-09-01-preview"
                      + location   = "[parameters('location')]"
                      + name       = "[parameters('alertName')]"
                      + properties = {
                          + action      = {
                              + aznsAction   = {
                                  + actionGroup  = [
                                      + "[resourceId(parameters('actionGroupRg'), 'microsoft.insights/actionGroups', parameters('actionGroupName'))]",
                                    ]
                                  + emailSubject = "[parameters('customEmailSubject')]"
                                }
                              + "odata.type" = "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction"
                              + severity     = "[parameters('severityLevel')]"
                              + status       = "Active"
                              + trigger      = {
                                  + consecutiveBreach = 1
                                  + threshold         = "[parameters('triggerThreshold')]"
                                  + thresholdOperator = "[parameters('triggerThresholdOperator')]"
                                }
                            }
                          + description = "[parameters('alertDesc')]"
                          + enabled     = "true"
                          + schedule    = {
                              + frequencyInMinutes  = "[parameters('frequencyInMinutes')]"
                              + timeWindowInMinutes = "[parameters('timeWindowInMinutes')]"
                            }
                          + skuType     = "L1"
                          + source      = {
                              + dataSourceId = "[resourceId('microsoft.insights/components', parameters('appInsightsName'))]"
                              + query        = "[parameters('appInsightsQuery')]"
                              + queryType    = "ResultCount"
                            }
                        }
                      + tags       = "[union(variables('tags'), variables('additionalTags'))]"
                      + type       = "microsoft.insights/scheduledqueryrules"
                    },
                ]
              + variables      = {
                  + additionalTags = {
                      + "[concat('hidden-link:', resourceId('microsoft.insights/components', parameters('appInsightsName')))]" = "Resource"
                    }
                  + tags           = "[base64ToJson(parameters('commonTags'))]"
                }
            }
        )
    }

  # module.prm-process-failure-alerts["prm-process-3"].azurerm_resource_group_template_deployment.custom_alert[0] will be created
  + resource "azurerm_resource_group_template_deployment" "custom_alert" {
      + deployment_mode     = "Incremental"
      + id                  = (known after apply)
      + name                = "am-prm-process-3-failure-alert"
      + output_content      = (known after apply)
      + parameters_content  = jsonencode(
            {
              + actionGroupName          = {
                  + value = "am-prm-support"
                }
              + actionGroupRg            = {
                  + value = "am-shared-infrastructure-aat"
                }
              + alertDesc                = {
                  + value = "Triggers when PRM Process 3 - Find organisation changes fails am-aat."
                }
              + alertName                = {
                  + value = "am-prm-process-3-failure-alert"
                }
              + appInsightsName          = {
                  + value = "am-aat"
                }
              + appInsightsQuery         = {
                  + value = "customEvents | where name == 'PRM Process 3 - Find organisation changes - Failed'"
                }
              + commonTags               = {
                  + value = "eyJhcHBsaWNhdGlvbiI6ImFjY2Vzcy1tYW5hZ2VtZW50IiwiYXV0b1NodXRkb3duIjoidHJ1ZSIsImJ1aWx0RnJvbSI6Imh0dHBzOi8vZ2l0aHViLmNvbS9ITUN

# ...
# ... The maximum length of GitHub Comment is 65536, so the content is omitted by tfcmt.
# ...

          }
                  + actionGroupRg            = {
                      + type = "string"
                    }
                  + alertDesc                = {
                      + type = "string"
                    }
                  + alertName                = {
                      + type = "string"
                    }
                  + appInsightsName          = {
                      + type = "string"
                    }
                  + appInsightsQuery         = {
                      + type = "string"
                    }
                  + commonTags               = {
                      + type = "string"
                    }
                  + customEmailSubject       = {
                      + type = "string"
                    }
                  + frequencyInMinutes       = {
                      + defaultValue = "5"
                      + type         = "string"
                    }
                  + location                 = {
                      + type = "string"
                    }
                  + severityLevel            = {
                      + defaultValue = "3"
                      + type         = "string"
                    }
                  + timeWindowInMinutes      = {
                      + defaultValue = "5"
                      + type         = "string"
                    }
                  + triggerThreshold         = {
                      + type = "string"
                    }
                  + triggerThresholdOperator = {
                      + allowedValues = [
                          + "GreaterThan",
                          + "Equal",
                          + "LessThan",
                        ]
                      + defaultValue  = "GreaterThan"
                      + type          = "string"
                    }
                }
              + resources      = [
                  + {
                      + apiVersion = "2017-09-01-preview"
                      + location   = "[parameters('location')]"
                      + name       = "[parameters('alertName')]"
                      + properties = {
                          + action      = {
                              + aznsAction   = {
                                  + actionGroup  = [
                                      + "[resourceId(parameters('actionGroupRg'), 'microsoft.insights/actionGroups', parameters('actionGroupName'))]",
                                    ]
                                  + emailSubject = "[parameters('customEmailSubject')]"
                                }
                              + "odata.type" = "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction"
                              + severity     = "[parameters('severityLevel')]"
                              + status       = "Active"
                              + trigger      = {
                                  + consecutiveBreach = 1
                                  + threshold         = "[parameters('triggerThreshold')]"
                                  + thresholdOperator = "[parameters('triggerThresholdOperator')]"
                                }
                            }
                          + description = "[parameters('alertDesc')]"
                          + enabled     = "true"
                          + schedule    = {
                              + frequencyInMinutes  = "[parameters('frequencyInMinutes')]"
                              + timeWindowInMinutes = "[parameters('timeWindowInMinutes')]"
                            }
                          + skuType     = "L1"
                          + source      = {
                              + dataSourceId = "[resourceId('microsoft.insights/components', parameters('appInsightsName'))]"
                              + query        = "[parameters('appInsightsQuery')]"
                              + queryType    = "ResultCount"
                            }
                        }
                      + tags       = "[union(variables('tags'), variables('additionalTags'))]"
                      + type       = "microsoft.insights/scheduledqueryrules"
                    },
                ]
              + variables      = {
                  + additionalTags = {
                      + "[concat('hidden-link:', resourceId('microsoft.insights/components', parameters('appInsightsName')))]" = "Resource"
                    }
                  + tags           = "[base64ToJson(parameters('commonTags'))]"
                }
            }
        )
    }

  # module.prm-process-not-started-alerts["prm-process-5"].azurerm_resource_group_template_deployment.custom_alert[0] will be created
  + resource "azurerm_resource_group_template_deployment" "custom_alert" {
      + deployment_mode     = "Incremental"
      + id                  = (known after apply)
      + name                = "am-prm-process-5-not-started-alert"
      + output_content      = (known after apply)
      + parameters_content  = jsonencode(
            {
              + actionGroupName          = {
                  + value = "am-prm-support"
                }
              + actionGroupRg            = {
                  + value = "am-shared-infrastructure-aat"
                }
              + alertDesc                = {
                  + value = "Triggers when PRM Process 5 - Find User Changes has not started the expected time frame in am-aat."
                }
              + alertName                = {
                  + value = "am-prm-process-5-not-started-alert"
                }
              + appInsightsName          = {
                  + value = "am-aat"
                }
              + appInsightsQuery         = {
                  + value = "customEvents | where name == 'PRM Process 5 - Find User Changes - Started' | limit 1"
                }
              + commonTags               = {
                  + value = "eyJhcHBsaWNhdGlvbiI6ImFjY2Vzcy1tYW5hZ2VtZW50IiwiYXV0b1NodXRkb3duIjoidHJ1ZSIsImJ1aWx0RnJvbSI6Imh0dHBzOi8vZ2l0aHViLmNvbS9ITUNUUy9hbS1vcmctcm9sZS1tYXBwaW5nLXNlcnZpY2UuZ2l0IiwiYnVzaW5lc3NBcmVhIjoiQ0ZUIiwiY29udGFjdFNsYWNrQ2hhbm5lbCI6IiNhbS1tYXN0ZXItYnVpbGRzIiwiZW52aXJvbm1lbnQiOiJzdGFnaW5nIiwibWFuYWdlZEJ5IjoiQU0ifQ=="
                }
              + customEmailSubject       = {
                  + value = "Alert: PRM Process 5 - Find User Changes has not started in expected time frame in am-aat"
                }
              + frequencyInMinutes       = {
                  + value = "15"
                }
              + location                 = {
                  + value = "UK South"
                }
              + severityLevel            = {
                  + value = "2"
                }
              + timeWindowInMinutes      = {
                  + value = "10080"
                }
              + triggerThreshold         = {
                  + value = "1"
                }
              + triggerThresholdOperator = {
                  + value = "LessThan"
                }
            }
        )
      + resource_group_name = "am-shared-infrastructure-aat"
      + template_content    = jsonencode(
            {
              + "$schema"      = "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#"
              + contentVersion = "1.0.0.0"
              + parameters     = {
                  + actionGroupName          = {
                      + type = "string"
                    }
                  + actionGroupRg            = {
                      + type = "string"
                    }
                  + alertDesc                = {
                      + type = "string"
                    }
                  + alertName                = {
                      + type = "string"
                    }
                  + appInsightsName          = {
                      + type = "string"
                    }
                  + appInsightsQuery         = {
                      + type = "string"
                    }
                  + commonTags               = {
                      + type = "string"
                    }
                  + customEmailSubject       = {
                      + type = "string"
                    }
                  + frequencyInMinutes       = {
                      + defaultValue = "5"
                      + type         = "string"
                    }
                  + location                 = {
                      + type = "string"
                    }
                  + severityLevel            = {
                      + defaultValue = "3"
                      + type         = "string"
                    }
                  + timeWindowInMinutes      = {
                      + defaultValue = "5"
                      + type         = "string"
                    }
                  + triggerThreshold         = {
                      + type = "string"
                    }
                  + triggerThresholdOperator = {
                      + allowedValues = [
                          + "GreaterThan",
                          + "Equal",
                          + "LessThan",
                        ]
                      + defaultValue  = "GreaterThan"
                      + type          = "string"
                    }
                }
              + resources      = [
                  + {
                      + apiVersion = "2017-09-01-preview"
                      + location   = "[parameters('location')]"
                      + name       = "[parameters('alertName')]"
                      + properties = {
                          + action      = {
                              + aznsAction   = {
                                  + actionGroup  = [
                                      + "[resourceId(parameters('actionGroupRg'), 'microsoft.insights/actionGroups', parameters('actionGroupName'))]",
                                    ]
                                  + emailSubject = "[parameters('customEmailSubject')]"
                                }
                              + "odata.type" = "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction"
                              + severity     = "[parameters('severityLevel')]"
                              + status       = "Active"
                              + trigger      = {
                                  + consecutiveBreach = 1
                                  + threshold         = "[parameters('triggerThreshold')]"
                                  + thresholdOperator = "[parameters('triggerThresholdOperator')]"
                                }
                            }
                          + description = "[parameters('alertDesc')]"
                          + enabled     = "true"
                          + schedule    = {
                              + frequencyInMinutes  = "[parameters('frequencyInMinutes')]"
                              + timeWindowInMinutes = "[parameters('timeWindowInMinutes')]"
                            }
                          + skuType     = "L1"
                          + source      = {
                              + dataSourceId = "[resourceId('microsoft.insights/components', parameters('appInsightsName'))]"
                              + query        = "[parameters('appInsightsQuery')]"
                              + queryType    = "ResultCount"
                            }
                        }
                      + tags       = "[union(variables('tags'), variables('additionalTags'))]"
                      + type       = "microsoft.insights/scheduledqueryrules"
                    },
                ]
              + variables      = {
                  + additionalTags = {
                      + "[concat('hidden-link:', resourceId('microsoft.insights/components', parameters('appInsightsName')))]" = "Resource"
                    }
                  + tags           = "[base64ToJson(parameters('commonTags'))]"
                }
            }
        )
    }

  # module.prm-process-not-started-alerts["prm-process-6"].azurerm_resource_group_template_deployment.custom_alert[0] will be created
  + resource "azurerm_resource_group_template_deployment" "custom_alert" {
      + deployment_mode     = "Incremental"
      + id                  = (known after apply)
      + name                = "am-prm-process-6-not-started-alert"
      + output_content      = (known after apply)
      + parameters_content  = jsonencode(
            {
              + actionGroupName          = {
                  + value = "am-prm-support"
                }
              + actionGroupRg            = {
                  + value = "am-shared-infrastructure-aat"
                }
              + alertDesc                = {
                  + value = "Triggers when PRM Process 6 - Refresh - Single User Mode and new PRM endpoint has not started the expected time frame in am-aat."
                }
              + alertName                = {
                  + value = "am-prm-process-6-not-started-alert"
                }
              + appInsightsName          = {
                  + value = "am-aat"
                }
              + appInsightsQuery         = {
                  + value = "customEvents | where name == 'PRM Process 6 - Refresh - Single User Mode and new PRM endpoint - Started' | limit 1"
                }
              + commonTags               = {
                  + value = "eyJhcHBsaWNhdGlvbiI6ImFjY2Vzcy1tYW5hZ2VtZW50IiwiYXV0b1NodXRkb3duIjoidHJ1ZSIsImJ1aWx0RnJvbSI6Imh0dHBzOi8vZ2l0aHViLmNvbS9ITUNUUy9hbS1vcmctcm9sZS1tYXBwaW5nLXNlcnZpY2UuZ2l0IiwiYnVzaW5lc3NBcmVhIjoiQ0ZUIiwiY29udGFjdFNsYWNrQ2hhbm5lbCI6IiNhbS1tYXN0ZXItYnVpbGRzIiwiZW52aXJvbm1lbnQiOiJzdGFnaW5nIiwibWFuYWdlZEJ5IjoiQU0ifQ=="
                }
              + customEmailSubject       = {
                  + value = "Alert: PRM Process 6 - Refresh - Single User Mode and new PRM endpoint has not started in expected time frame in am-aat"
                }
              + frequencyInMinutes       = {
                  + value = "15"
                }
              + location                 = {
                  + value = "UK South"
                }
              + severityLevel            = {
                  + value = "2"
                }
              + timeWindowInMinutes      = {
                  + value = "10080"
                }
              + triggerThreshold         = {
                  + value = "1"
                }
              + triggerThresholdOperator = {
                  + value = "LessThan"
                }
            }
        )
      + resource_group_name = "am-shared-infrastructure-aat"
      + template_content    = jsonencode(
            {
              + "$schema"      = "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#"
              + contentVersion = "1.0.0.0"
              + parameters     = {
                  + actionGroupName          = {
                      + type = "string"
                    }
                  + actionGroupRg            = {
                      + type = "string"
                    }
                  + alertDesc                = {
                      + type = "string"
                    }
                  + alertName                = {
                      + type = "string"
                    }
                  + appInsightsName          = {
                      + type = "string"
                    }
                  + appInsightsQuery         = {
                      + type = "string"
                    }
                  + commonTags               = {
                      + type = "string"
                    }
                  + customEmailSubject       = {
                      + type = "string"
                    }
                  + frequencyInMinutes       = {
                      + defaultValue = "5"
                      + type         = "string"
                    }
                  + location                 = {
                      + type = "string"
                    }
                  + severityLevel            = {
                      + defaultValue = "3"
                      + type         = "string"
                    }
                  + timeWindowInMinutes      = {
                      + defaultValue = "5"
                      + type         = "string"
                    }
                  + triggerThreshold         = {
                      + type = "string"
                    }
                  + triggerThresholdOperator = {
                      + allowedValues = [
                          + "GreaterThan",
                          + "Equal",
                          + "LessThan",
                        ]
                      + defaultValue  = "GreaterThan"
                      + type          = "string"
                    }
                }
              + resources      = [
                  + {
                      + apiVersion = "2017-09-01-preview"
                      + location   = "[parameters('location')]"
                      + name       = "[parameters('alertName')]"
                      + properties = {
                          + action      = {
                              + aznsAction   = {
                                  + actionGroup  = [
                                      + "[resourceId(parameters('actionGroupRg'), 'microsoft.insights/actionGroups', parameters('actionGroupName'))]",
                                    ]
                                  + emailSubject = "[parameters('customEmailSubject')]"
                                }
                              + "odata.type" = "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction"
                              + severity     = "[parameters('severityLevel')]"
                              + status       = "Active"
                              + trigger      = {
                                  + consecutiveBreach = 1
                                  + threshold         = "[parameters('triggerThreshold')]"
                                  + thresholdOperator = "[parameters('triggerThresholdOperator')]"
                                }
                            }
                          + description = "[parameters('alertDesc')]"
                          + enabled     = "true"
                          + schedule    = {
                              + frequencyInMinutes  = "[parameters('frequencyInMinutes')]"
                              + timeWindowInMinutes = "[parameters('timeWindowInMinutes')]"
                            }
                          + skuType     = "L1"
                          + source      = {
                              + dataSourceId = "[resourceId('microsoft.insights/components', parameters('appInsightsName'))]"
                              + query        = "[parameters('appInsightsQuery')]"
                              + queryType    = "ResultCount"
                            }
                        }
                      + tags       = "[union(variables('tags'), variables('additionalTags'))]"
                      + type       = "microsoft.insights/scheduledqueryrules"
                    },
                ]
              + variables      = {
                  + additionalTags = {
                      + "[concat('hidden-link:', resourceId('microsoft.insights/components', parameters('appInsightsName')))]" = "Resource"
                    }
                  + tags           = "[base64ToJson(parameters('commonTags'))]"
                }
            }
        )
    }

Plan: 21 to add, 0 to change, 2 to destroy.

@hmcts-jenkins-a-to-c
Copy link
Contributor

Plan Result (prod)

⚠️ Resource Deletion will happen ⚠️

This plan contains resource delete operation. Please check the plan result very carefully!

Plan: 20 to add, 0 to change, 1 to destroy.
  • Create
    • module.am-prm-action-group.azurerm_resource_group_template_deployment.action-group
    • module.prm-process-failure-alerts["prm-process-1"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-failure-alerts["prm-process-2"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-failure-alerts["prm-process-3"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-failure-alerts["prm-process-4"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-failure-alerts["prm-process-5"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-failure-alerts["prm-process-6"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-not-completed-alerts["prm-process-1"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-not-completed-alerts["prm-process-2"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-not-completed-alerts["prm-process-3"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-not-completed-alerts["prm-process-4"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-not-completed-alerts["prm-process-5"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-not-completed-alerts["prm-process-6"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-not-started-alerts["prm-process-1"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-not-started-alerts["prm-process-2"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-not-started-alerts["prm-process-3"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-not-started-alerts["prm-process-4"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-not-started-alerts["prm-process-5"].azurerm_resource_group_template_deployment.custom_alert[0]
    • module.prm-process-not-started-alerts["prm-process-6"].azurerm_resource_group_template_deployment.custom_alert[0]
  • Replace
    • module.org-role-mapping-database-v15.null_resource.set-user-permissions-additionaldbs["org_role_mapping"]
Change Result (Click me)
  # module.am-prm-action-group.azurerm_resource_group_template_deployment.action-group will be created
  + resource "azurerm_resource_group_template_deployment" "action-group" {
      + deployment_mode     = "Incremental"
      + id                  = (known after apply)
      + name                = "am-prm-support"
      + output_content      = (known after apply)
      + parameters_content  = (sensitive value)
      + resource_group_name = "am-shared-infrastructure-prod"
      + template_content    = jsonencode(
            {
              + "$schema"      = "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#"
              + contentVersion = "1.0.0.0"
              + parameters     = {
                  + actionGroupName      = {
                      + type = "string"
                    }
                  + emailReceiverAddress = {
                      + metadata = {
                          + description = "Email address of the receiver"
                        }
                      + type     = "string"
                    }
                  + emailReceiverName    = {
                      + metadata = {
                          + description = "Name of the email receiver"
                        }
                      + type     = "string"
                    }
                  + location             = {
                      + defaultValue = "global"
                      + type         = "string"
                    }
                  + shortName            = {
                      + type = "string"
                    }
                }
              + resources      = [
                  + {
                      + apiVersion = "2017-04-01"
                      + location   = "[parameters('location')]"
                      + name       = "[parameters('actionGroupName')]"
                      + properties = {
                          + emailReceivers   = [
                              + {
                                  + emailAddress = "[parameters('emailReceiverAddress')]"
                                  + name         = "[parameters('emailReceiverName')]"
                                },
                            ]
                          + enabled          = true
                          + groupShortName   = "[parameters('shortName')]"
                          + smsReceivers     = []
                          + webhookReceivers = []
                        }
                      + tags       = {}
                      + type       = "microsoft.insights/actionGroups"
                    },
                ]
            }
        )
    }

  # module.org-role-mapping-database-v15.null_resource.set-user-permissions-additionaldbs["org_role_mapping"] must be replaced
-/+ resource "null_resource" "set-user-permissions-additionaldbs" {
      ~ id       = "7958113704267574158" -> (known after apply)
      ~ triggers = { # forces replacement
          ~ "force_trigger"  = "5" -> "4"
            # (3 unchanged elements hidden)
        }
    }

  # module.prm-process-failure-alerts["prm-process-1"].azurerm_resource_group_template_deployment.custom_alert[0] will be created
  + resource "azurerm_resource_group_template_deployment" "custom_alert" {
      + deployment_mode     = "Incremental"
      + id                  = (known after apply)
      + name                = "am-prm-process-1-failure-alert"
      + output_content      = (known after apply)
      + parameters_content  = jsonencode(
            {
              + actionGroupName          = {
                  + value = "am-prm-support"
                }
              + actionGroupRg            = {
                  + value = "am-shared-infrastructure-prod"
                }
              + alertDesc                = {
                  + value = "Triggers when PRM Process 1 - Find Case Definition Changes fails am-prod."
                }
              + alertName                = {
                  + value = "am-prm-process-1-failure-alert"
                }
              + appInsightsName          = {
                  + value = "am-prod"
                }
              + appInsightsQuery         = {
                  + value = "customEvents | where name == 'PRM Process 1 - Find Case Definition Changes - Failed'"
                }
              + commonTags               = {
                  + value = "eyJhcHBsaWNhdGlvbiI6ImFjY2Vzcy1tYW5hZ2VtZW50IiwiYnVpbHRGcm9tIjoiaHR0cHM6Ly9naXRodWIuY29tL0hNQ1RTL2FtLW9yZy1yb2xlLW1hcHBpbmctc2VydmljZS5naXQiLCJidXNpbmVzc0FyZWEiOiJDRlQiLCJjb250YWN0U2xhY2tDaGFubmVsIjoiI2FtLW1hc3Rlci1idWlsZHMiLCJlbnZpcm9ubWVudCI6InByb2R1Y3Rpb24iLCJtYW5hZ2VkQnkiOiJBTSJ9"
                }
              + customEmailSubject       = {
                  + value = "Alert: PRM Process 1 - Find Case Definition Changes failed in am-prod"
                }
              + frequencyInMinutes       = {
                  + value = "15"
                }
              + location                 = {
                  + value = "UK South"
                }
              + severityLevel            = {
                  + value = "2"
                }
              + timeWindowInMinutes      = {
                  + value = "10080"
                }
              + triggerThreshold         = {
                  + value = "0"
                }
              + triggerThresholdOperator = {
                  + value = "GreaterThan"
                }
            }
        )
      + resource_group_name = "am-shared-infrastructure-prod"
      + template_content    = jsonencode(
            {
              + "$schema"      = "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#"
              + contentVersion = "1.0.0.0"
              + parameters     = {
                  + actionGroupName          = {
                      + type = "string"
                    }
                  + actionGroupRg            = {
                      + type = "string"
                    }
                  + alertDesc                = {
                      + type = "string"
                    }
                  + alertName                = {
                      + type = "string"
                    }
                  + appInsightsName          = {
                      + type = "string"
                    }
                  + appInsightsQuery         = {
                      + type = "string"
                    }
                  + commonTags               = {
                      + type = "string"
                    }
                  + customEmailSubject       = {
                      + type = "string"
                    }
                  + frequencyInMinutes       = {
                      + defaultValue = "5"
                      + type         = "string"
                    }
                  + location                 = {
                      + type = "string"
                    }
                  + severityLevel            = {
                      + defaultValue = "3"
                      + type         = "string"
                    }
                  + timeWindowInMinutes      = {
                      + defaultValue = "5"
                      + type         = "string"
                    }
                  + triggerThreshold         = {
                      + type = "string"
                    }
                  + triggerThresholdOperator = {
                      + allowedValues = [
                          + "GreaterThan",
                          + "Equal",
                          + "LessThan",
                        ]
                      + defaultValue  = "GreaterThan"
                      + type          = "string"
                    }
                }
              + resources      = [
                  + {
                      + apiVersion = "2017-09-01-preview"
                      + location   = "[parameters('location')]"
                      + name       = "[parameters('alertName')]"
                      + properties = {
                          + action      = {
                              + aznsAction   = {
                                  + actionGroup  = [
                                      + "[resourceId(parameters('actionGroupRg'), 'microsoft.insights/actionGroups', parameters('actionGroupName'))]",
                                    ]
                                  + emailSubject = "[parameters('customEmailSubject')]"
                                }
                              + "odata.type" = "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction"
                              + severity     = "[parameters('severityLevel')]"
                              + status       = "Active"
                              + trigger      = {
                                  + consecutiveBreach = 1
                                  + threshold         = "[parameters('triggerThreshold')]"
                                  + thresholdOperator = "[parameters('triggerThresholdOperator')]"
                                }
                            }
                          + description = "[parameters('alertDesc')]"
                          + enabled     = "true"
                          + schedule    = {
                              + frequencyInMinutes  = "[parameters('frequencyInMinutes')]"
                              + timeWindowInMinutes = "[parameters('timeWindowInMinutes')]"
                            }
                          + skuType     = "L1"
                          + source      = {
                              + dataSourceId = "[resourceId('microsoft.insights/components', parameters('appInsightsName'))]"
                              + query        = "[parameters('appInsightsQuery')]"
                              + queryType    = "ResultCount"
                            }
                        }
                      + tags       = "[union(variables('tags'), variables('additionalTags'))]"
                      + type       = "microsoft.insights/scheduledqueryrules"
                    },
                ]
              + variables      = {
                  + additionalTags = {
                      + "[concat('hidden-link:', resourceId('microsoft.insights/components', parameters('appInsightsName')))]" = "Resource"
                    }
                  + tags           = "[base64ToJson(parameters('commonTags'))]"
                }
            }
        )
    }

  # module.prm-process-failure-alerts["prm-process-2"].azurerm_resource_group_template_deployment.custom_alert[0] will be created
  + resource "azurerm_resource_group_template_deployment" "custom_alert" {
      + deployment_mode     = "Incremental"
      + id                  = (known after apply)
      + name                = "am-prm-process-2-failure-alert"
      + output_content      = (known after apply)
      + parameters_content  = jsonencode(
            {
              + actionGroupName          = {
                  + value = "am-prm-support"
                }
              + actionGroupRg            = {
                  + value = "am-shared-infrastructure-prod"
                }
              + alertDesc                = {
                  + value = "Triggers when PRM Process 2 - Find Organisations with Stale Profiles fails am-prod."
                }
              + alertName                = {
                  + value = "am-prm-process-2-failure-alert"
                }
              + appInsightsName          = {
                  + value = "am-prod"
                }
              + appInsightsQuery         = {
                  + value = "customEvents | where name == 'PRM Process 2 - Find Organisations with Stale Profiles - Failed'"
                }
              + commonTags               = {
                  + value = "eyJhcHBsaWNhdGlvbiI6ImFjY2Vzcy1tYW5hZ2VtZW50IiwiYnVpbHRGcm9tIjoiaHR0cHM6Ly9naXRodWIuY29tL0hNQ1RTL2FtLW9yZy1yb2xlLW1hcHBpbmctc2VydmljZS5naXQiLCJidXNpbmVzc0FyZWEiOiJDRlQiLCJjb250YWN0U2xhY2tDaGFubmVsIjoiI2FtLW1hc3Rlci1idWlsZHMiLCJlbnZpcm9ubWVudCI6InByb2R1Y3Rpb24iLCJtYW5hZ2VkQnkiOiJBTSJ9"
                }
              + customEmailSubject       = {
                  + value = "Alert: PRM Process 2 - Find Organisations with Stale Profiles failed in am-prod"
                }
              + frequencyInMinutes       = {
                  + value = "15"
                }
              + location                 = {
                  + value = "UK South"
                }
              + severityLevel            = {
                  + value = "2"
                }
              + timeWindowInMinutes      = {
                  + value = "10080"
                }
              + triggerThreshold         = {
                  + value = "0"
                }
              + triggerThresholdOperator = {
                  + value = "GreaterThan"
                }
            }
        )
      + resource_group_name = "am-shared-infrastructure-prod"
      + template_content    = jsonencode(
            {
              + "$schema"      = "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#"
              + contentVersion = "1.0.0.0"
              + parameters     = {
                  + actionGroupName          = {
                      + type = "string"
                    }
                  + actionGroupRg            = {
                      + type = "string"
                    }
                  + alertDesc                = {
                      + type = "string"
                    }
                  + alertName                = {
                      + type = "string"
                    }
                  + appInsightsName          = {
                      + type = "string"
                    }
                  + appInsightsQuery         = {
                      + type = "string"
                    }
                  + commonTags               = {
                      + type = "string"
                    }
                  + customEmailSubject       = {
                      + type = "string"
                    }
                  + frequencyInMinutes       = {
                      + defaultValue = "5"
                      + type         = "string"
                    }
                  + location                 = {
                      + type = "string"
                    }
                  + severityLevel            = {
                      + defaultValue = "3"
                      + type         = "string"
                    }
                  + timeWindowInMinutes      = {
                      + defaultValue = "5"
                      + type         = "string"
                    }
                  + triggerThreshold         = {
                      + type = "string"
                    }
                  + triggerThresholdOperator = {
                      + allowedValues = [
                          + "GreaterThan",
                          + "Equal",
                          + "LessThan",
                        ]
                      + defaultValue  = "GreaterThan"
                      + type          = "string"
                    }
                }
              + resources      = [
                  + {
                      + apiVersion = "2017-09-01-preview"
                      + location   = "[parameters('location')]"
                      + name       = "[parameters('alertName')]"
                      + properties = {
                          + action      = {
                              + aznsAction   = {
                                  + actionGroup  = [
                                      + "[resourceId(parameters('actionGroupRg'), 'microsoft.insights/actionGroups', parameters('actionGroupName'))]",
                                    ]
                                  + emailSubject = "[parameters('customEmailSubject')]"
                                }
                              + "odata.type" = "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction"
                              + severity     = "[parameters('severityLevel')]"
                              + status       = "Active"
                              + trigger      = {
                                  + consecutiveBreach = 1
                                  + threshold         = "[parameters('triggerThreshold')]"
                                  + thresholdOperator = "[parameters('triggerThresholdOperator')]"
                                }
                            }
                          + description = "[parameters('alertDesc')]"
                          + enabled     = "true"
                          + schedule    = {
                              + frequencyInMinutes  = "[parameters('frequencyInMinutes')]"
                              + timeWindowInMinutes = "[parameters('timeWindowInMinutes')]"
                            }
                          + skuType     = "L1"
                          + source      = {
                              + dataSourceId = "[resourceId('microsoft.insights/components', parameters('appInsightsName'))]"
                              + query        = "[parameters('appInsightsQuery')]"
                              + queryType    = "ResultCount"
                            }
                        }
                      + tags       = "[union(variables('tags'), variables('additionalTags'))]"
                      + type       = "microsoft.insights/scheduledqueryrules"
                    },
                ]
              + variables      = {
                  + additionalTags = {
                      + "[concat('hidden-link:', resourceId('microsoft.insights/components', parameters('appInsightsName')))]" = "Resource"
                    }
                  + tags           = "[base64ToJson(parameters('commonTags'))]"
                }
            }
        )
    }

  # module.prm-process-failure-alerts["prm-process-3"].azurerm_resource_group_template_deployment.custom_alert[0] will be created
  + resource "azurerm_resource_group_template_deployment" "custom_alert" {
      + deployment_mode     = "Incremental"
      + id                  = (known after apply)
      + name                = "am-prm-process-3-failure-alert"
      + output_content      = (known after apply)
      + parameters_content  = jsonencode(
            {
              + actionGroupName          = {
                  + value = "am-prm-support"
                }
              + actionGroupRg            = {
                  + value = "am-shared-infrastructure-prod"
                }
              + alertDesc                = {
                  + value = "Triggers when PRM Process 3 - Find organisation changes fails am-prod."
                }
              + alertName                = {
                  + value = "am-prm-process-3-failure-alert"
                }
              + appInsightsName          = {
                  + value = "am-prod"
                }
              + appInsightsQuery         = {
                  + value = "customEvents | where name == 'PRM Process 3 - Find organisation changes - Failed'"
                }
              + commonTags               = {
                  + value = "eyJhcHBsaWNhdGlvbiI6ImFjY2Vzcy1tYW5hZ2VtZW50IiwiYnVpbHRGcm9tIjoiaHR0cHM6Ly9naXRodWIuY29tL0hNQ1RTL2FtLW9yZy1yb2xlLW1hcHBpbmctc2VydmljZS5naXQiLCJidXNpbmVzc0FyZWEiOiJDRlQiLCJjb250YWN0U2xhY2tDaGFubmVsIjoiI2FtLW1hc3Rlci1idWlsZHMiLCJlbnZpcm9ubWVudCI6InByb2R1Y3Rpb24iLCJtYW5hZ2VkQnkiOiJBTSJ9"
                }
              + customEmailSubject       = {
                  + value = "Alert: PRM Process 3 - Find organisation changes failed in am-prod"
                }
              + frequencyInMinutes       = {
                  + value = "15

# ...
# ... The maximum length of GitHub Comment is 65536, so the content is omitted by tfcmt.
# ...

                  + type = "string"
                    }
                  + actionGroupRg            = {
                      + type = "string"
                    }
                  + alertDesc                = {
                      + type = "string"
                    }
                  + alertName                = {
                      + type = "string"
                    }
                  + appInsightsName          = {
                      + type = "string"
                    }
                  + appInsightsQuery         = {
                      + type = "string"
                    }
                  + commonTags               = {
                      + type = "string"
                    }
                  + customEmailSubject       = {
                      + type = "string"
                    }
                  + frequencyInMinutes       = {
                      + defaultValue = "5"
                      + type         = "string"
                    }
                  + location                 = {
                      + type = "string"
                    }
                  + severityLevel            = {
                      + defaultValue = "3"
                      + type         = "string"
                    }
                  + timeWindowInMinutes      = {
                      + defaultValue = "5"
                      + type         = "string"
                    }
                  + triggerThreshold         = {
                      + type = "string"
                    }
                  + triggerThresholdOperator = {
                      + allowedValues = [
                          + "GreaterThan",
                          + "Equal",
                          + "LessThan",
                        ]
                      + defaultValue  = "GreaterThan"
                      + type          = "string"
                    }
                }
              + resources      = [
                  + {
                      + apiVersion = "2017-09-01-preview"
                      + location   = "[parameters('location')]"
                      + name       = "[parameters('alertName')]"
                      + properties = {
                          + action      = {
                              + aznsAction   = {
                                  + actionGroup  = [
                                      + "[resourceId(parameters('actionGroupRg'), 'microsoft.insights/actionGroups', parameters('actionGroupName'))]",
                                    ]
                                  + emailSubject = "[parameters('customEmailSubject')]"
                                }
                              + "odata.type" = "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction"
                              + severity     = "[parameters('severityLevel')]"
                              + status       = "Active"
                              + trigger      = {
                                  + consecutiveBreach = 1
                                  + threshold         = "[parameters('triggerThreshold')]"
                                  + thresholdOperator = "[parameters('triggerThresholdOperator')]"
                                }
                            }
                          + description = "[parameters('alertDesc')]"
                          + enabled     = "true"
                          + schedule    = {
                              + frequencyInMinutes  = "[parameters('frequencyInMinutes')]"
                              + timeWindowInMinutes = "[parameters('timeWindowInMinutes')]"
                            }
                          + skuType     = "L1"
                          + source      = {
                              + dataSourceId = "[resourceId('microsoft.insights/components', parameters('appInsightsName'))]"
                              + query        = "[parameters('appInsightsQuery')]"
                              + queryType    = "ResultCount"
                            }
                        }
                      + tags       = "[union(variables('tags'), variables('additionalTags'))]"
                      + type       = "microsoft.insights/scheduledqueryrules"
                    },
                ]
              + variables      = {
                  + additionalTags = {
                      + "[concat('hidden-link:', resourceId('microsoft.insights/components', parameters('appInsightsName')))]" = "Resource"
                    }
                  + tags           = "[base64ToJson(parameters('commonTags'))]"
                }
            }
        )
    }

  # module.prm-process-not-started-alerts["prm-process-5"].azurerm_resource_group_template_deployment.custom_alert[0] will be created
  + resource "azurerm_resource_group_template_deployment" "custom_alert" {
      + deployment_mode     = "Incremental"
      + id                  = (known after apply)
      + name                = "am-prm-process-5-not-started-alert"
      + output_content      = (known after apply)
      + parameters_content  = jsonencode(
            {
              + actionGroupName          = {
                  + value = "am-prm-support"
                }
              + actionGroupRg            = {
                  + value = "am-shared-infrastructure-prod"
                }
              + alertDesc                = {
                  + value = "Triggers when PRM Process 5 - Find User Changes has not started the expected time frame in am-prod."
                }
              + alertName                = {
                  + value = "am-prm-process-5-not-started-alert"
                }
              + appInsightsName          = {
                  + value = "am-prod"
                }
              + appInsightsQuery         = {
                  + value = "customEvents | where name == 'PRM Process 5 - Find User Changes - Started' | limit 1"
                }
              + commonTags               = {
                  + value = "eyJhcHBsaWNhdGlvbiI6ImFjY2Vzcy1tYW5hZ2VtZW50IiwiYnVpbHRGcm9tIjoiaHR0cHM6Ly9naXRodWIuY29tL0hNQ1RTL2FtLW9yZy1yb2xlLW1hcHBpbmctc2VydmljZS5naXQiLCJidXNpbmVzc0FyZWEiOiJDRlQiLCJjb250YWN0U2xhY2tDaGFubmVsIjoiI2FtLW1hc3Rlci1idWlsZHMiLCJlbnZpcm9ubWVudCI6InByb2R1Y3Rpb24iLCJtYW5hZ2VkQnkiOiJBTSJ9"
                }
              + customEmailSubject       = {
                  + value = "Alert: PRM Process 5 - Find User Changes has not started in expected time frame in am-prod"
                }
              + frequencyInMinutes       = {
                  + value = "15"
                }
              + location                 = {
                  + value = "UK South"
                }
              + severityLevel            = {
                  + value = "2"
                }
              + timeWindowInMinutes      = {
                  + value = "10080"
                }
              + triggerThreshold         = {
                  + value = "1"
                }
              + triggerThresholdOperator = {
                  + value = "LessThan"
                }
            }
        )
      + resource_group_name = "am-shared-infrastructure-prod"
      + template_content    = jsonencode(
            {
              + "$schema"      = "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#"
              + contentVersion = "1.0.0.0"
              + parameters     = {
                  + actionGroupName          = {
                      + type = "string"
                    }
                  + actionGroupRg            = {
                      + type = "string"
                    }
                  + alertDesc                = {
                      + type = "string"
                    }
                  + alertName                = {
                      + type = "string"
                    }
                  + appInsightsName          = {
                      + type = "string"
                    }
                  + appInsightsQuery         = {
                      + type = "string"
                    }
                  + commonTags               = {
                      + type = "string"
                    }
                  + customEmailSubject       = {
                      + type = "string"
                    }
                  + frequencyInMinutes       = {
                      + defaultValue = "5"
                      + type         = "string"
                    }
                  + location                 = {
                      + type = "string"
                    }
                  + severityLevel            = {
                      + defaultValue = "3"
                      + type         = "string"
                    }
                  + timeWindowInMinutes      = {
                      + defaultValue = "5"
                      + type         = "string"
                    }
                  + triggerThreshold         = {
                      + type = "string"
                    }
                  + triggerThresholdOperator = {
                      + allowedValues = [
                          + "GreaterThan",
                          + "Equal",
                          + "LessThan",
                        ]
                      + defaultValue  = "GreaterThan"
                      + type          = "string"
                    }
                }
              + resources      = [
                  + {
                      + apiVersion = "2017-09-01-preview"
                      + location   = "[parameters('location')]"
                      + name       = "[parameters('alertName')]"
                      + properties = {
                          + action      = {
                              + aznsAction   = {
                                  + actionGroup  = [
                                      + "[resourceId(parameters('actionGroupRg'), 'microsoft.insights/actionGroups', parameters('actionGroupName'))]",
                                    ]
                                  + emailSubject = "[parameters('customEmailSubject')]"
                                }
                              + "odata.type" = "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction"
                              + severity     = "[parameters('severityLevel')]"
                              + status       = "Active"
                              + trigger      = {
                                  + consecutiveBreach = 1
                                  + threshold         = "[parameters('triggerThreshold')]"
                                  + thresholdOperator = "[parameters('triggerThresholdOperator')]"
                                }
                            }
                          + description = "[parameters('alertDesc')]"
                          + enabled     = "true"
                          + schedule    = {
                              + frequencyInMinutes  = "[parameters('frequencyInMinutes')]"
                              + timeWindowInMinutes = "[parameters('timeWindowInMinutes')]"
                            }
                          + skuType     = "L1"
                          + source      = {
                              + dataSourceId = "[resourceId('microsoft.insights/components', parameters('appInsightsName'))]"
                              + query        = "[parameters('appInsightsQuery')]"
                              + queryType    = "ResultCount"
                            }
                        }
                      + tags       = "[union(variables('tags'), variables('additionalTags'))]"
                      + type       = "microsoft.insights/scheduledqueryrules"
                    },
                ]
              + variables      = {
                  + additionalTags = {
                      + "[concat('hidden-link:', resourceId('microsoft.insights/components', parameters('appInsightsName')))]" = "Resource"
                    }
                  + tags           = "[base64ToJson(parameters('commonTags'))]"
                }
            }
        )
    }

  # module.prm-process-not-started-alerts["prm-process-6"].azurerm_resource_group_template_deployment.custom_alert[0] will be created
  + resource "azurerm_resource_group_template_deployment" "custom_alert" {
      + deployment_mode     = "Incremental"
      + id                  = (known after apply)
      + name                = "am-prm-process-6-not-started-alert"
      + output_content      = (known after apply)
      + parameters_content  = jsonencode(
            {
              + actionGroupName          = {
                  + value = "am-prm-support"
                }
              + actionGroupRg            = {
                  + value = "am-shared-infrastructure-prod"
                }
              + alertDesc                = {
                  + value = "Triggers when PRM Process 6 - Refresh - Single User Mode and new PRM endpoint has not started the expected time frame in am-prod."
                }
              + alertName                = {
                  + value = "am-prm-process-6-not-started-alert"
                }
              + appInsightsName          = {
                  + value = "am-prod"
                }
              + appInsightsQuery         = {
                  + value = "customEvents | where name == 'PRM Process 6 - Refresh - Single User Mode and new PRM endpoint - Started' | limit 1"
                }
              + commonTags               = {
                  + value = "eyJhcHBsaWNhdGlvbiI6ImFjY2Vzcy1tYW5hZ2VtZW50IiwiYnVpbHRGcm9tIjoiaHR0cHM6Ly9naXRodWIuY29tL0hNQ1RTL2FtLW9yZy1yb2xlLW1hcHBpbmctc2VydmljZS5naXQiLCJidXNpbmVzc0FyZWEiOiJDRlQiLCJjb250YWN0U2xhY2tDaGFubmVsIjoiI2FtLW1hc3Rlci1idWlsZHMiLCJlbnZpcm9ubWVudCI6InByb2R1Y3Rpb24iLCJtYW5hZ2VkQnkiOiJBTSJ9"
                }
              + customEmailSubject       = {
                  + value = "Alert: PRM Process 6 - Refresh - Single User Mode and new PRM endpoint has not started in expected time frame in am-prod"
                }
              + frequencyInMinutes       = {
                  + value = "15"
                }
              + location                 = {
                  + value = "UK South"
                }
              + severityLevel            = {
                  + value = "2"
                }
              + timeWindowInMinutes      = {
                  + value = "10080"
                }
              + triggerThreshold         = {
                  + value = "1"
                }
              + triggerThresholdOperator = {
                  + value = "LessThan"
                }
            }
        )
      + resource_group_name = "am-shared-infrastructure-prod"
      + template_content    = jsonencode(
            {
              + "$schema"      = "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#"
              + contentVersion = "1.0.0.0"
              + parameters     = {
                  + actionGroupName          = {
                      + type = "string"
                    }
                  + actionGroupRg            = {
                      + type = "string"
                    }
                  + alertDesc                = {
                      + type = "string"
                    }
                  + alertName                = {
                      + type = "string"
                    }
                  + appInsightsName          = {
                      + type = "string"
                    }
                  + appInsightsQuery         = {
                      + type = "string"
                    }
                  + commonTags               = {
                      + type = "string"
                    }
                  + customEmailSubject       = {
                      + type = "string"
                    }
                  + frequencyInMinutes       = {
                      + defaultValue = "5"
                      + type         = "string"
                    }
                  + location                 = {
                      + type = "string"
                    }
                  + severityLevel            = {
                      + defaultValue = "3"
                      + type         = "string"
                    }
                  + timeWindowInMinutes      = {
                      + defaultValue = "5"
                      + type         = "string"
                    }
                  + triggerThreshold         = {
                      + type = "string"
                    }
                  + triggerThresholdOperator = {
                      + allowedValues = [
                          + "GreaterThan",
                          + "Equal",
                          + "LessThan",
                        ]
                      + defaultValue  = "GreaterThan"
                      + type          = "string"
                    }
                }
              + resources      = [
                  + {
                      + apiVersion = "2017-09-01-preview"
                      + location   = "[parameters('location')]"
                      + name       = "[parameters('alertName')]"
                      + properties = {
                          + action      = {
                              + aznsAction   = {
                                  + actionGroup  = [
                                      + "[resourceId(parameters('actionGroupRg'), 'microsoft.insights/actionGroups', parameters('actionGroupName'))]",
                                    ]
                                  + emailSubject = "[parameters('customEmailSubject')]"
                                }
                              + "odata.type" = "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction"
                              + severity     = "[parameters('severityLevel')]"
                              + status       = "Active"
                              + trigger      = {
                                  + consecutiveBreach = 1
                                  + threshold         = "[parameters('triggerThreshold')]"
                                  + thresholdOperator = "[parameters('triggerThresholdOperator')]"
                                }
                            }
                          + description = "[parameters('alertDesc')]"
                          + enabled     = "true"
                          + schedule    = {
                              + frequencyInMinutes  = "[parameters('frequencyInMinutes')]"
                              + timeWindowInMinutes = "[parameters('timeWindowInMinutes')]"
                            }
                          + skuType     = "L1"
                          + source      = {
                              + dataSourceId = "[resourceId('microsoft.insights/components', parameters('appInsightsName'))]"
                              + query        = "[parameters('appInsightsQuery')]"
                              + queryType    = "ResultCount"
                            }
                        }
                      + tags       = "[union(variables('tags'), variables('additionalTags'))]"
                      + type       = "microsoft.insights/scheduledqueryrules"
                    },
                ]
              + variables      = {
                  + additionalTags = {
                      + "[concat('hidden-link:', resourceId('microsoft.insights/components', parameters('appInsightsName')))]" = "Resource"
                    }
                  + tags           = "[base64ToJson(parameters('commonTags'))]"
                }
            }
        )
    }

Plan: 20 to add, 0 to change, 1 to destroy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants