Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions infrastructure/tf-core/availability_test.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
locals {
avail = var.availability_test
}

module "azurerm_application_insights_standard_availability_test" {
for_each = { for key, val in var.regions : key => val if val.is_primary_region && var.features.alerts_enabled && local.avail != null }

source = "../../../dtos-devops-templates/infrastructure/modules/application-insights-availability-test"
name = "${module.regions_config[each.key].names.function-app}-${var.availability_test.name_suffix}"
resource_group_name = data.azurerm_application_insights.ai.resource_group_name
location = each.key
action_group_id = var.features.alerts_enabled ? module.monitor_action_group_performance[0].monitor_action_group.id : null
application_insights_id = data.azurerm_application_insights.ai.id

target_url = var.availability_test.target_url

timeout = var.availability_test.timeout
frequency = var.availability_test.frequency

headers = {
OCP-Apim-Subscription-Key = var.OCP_APIM_SUBSCRIPTION_KEY
}

ssl_validation = {
expected_status_code = var.availability_test.ssl_validation.expected_status_code
ssl_cert_remaining_lifetime = var.availability_test.ssl_validation.ssl_cert_remaining_lifetime
}

alert = var.availability_test.alert
}
5 changes: 5 additions & 0 deletions infrastructure/tf-core/environments/development.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ tags = {
Environment = "development"
}

availability_test = {
name_suffix = "retrieve-cohort-request-audit-webtest"
target_url = "https://api.non-live.nationalscreening.nhs.uk/dev-uks-retrieve-cohort-request-audit/health"
}

regions = {
uksouth = {
is_primary_region = true
Expand Down
5 changes: 5 additions & 0 deletions infrastructure/tf-core/environments/production.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ tags = {
Environment = "production"
}

availability_test = {
name_suffix = "retrieve-cohort-request-audit-webtest"
target_url = "https://api.nationalscreening.nhs.uk/prod-uks-retrieve-cohort-request-audit/health"
}

regions = {
uksouth = {
is_primary_region = true
Expand Down
9 changes: 7 additions & 2 deletions infrastructure/tf-core/environments/sandbox.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ tags = {
Environment = "sandbox"
}

availability_test = {
name_suffix = "retrieve-cohort-request-audit-webtest"
target_url = "https://api.non-live.nationalscreening.nhs.uk/dev-uks-retrieve-cohort-request-audit/health"
}

regions = {
uksouth = {
is_primary_region = true
Expand Down Expand Up @@ -667,7 +672,7 @@ function_apps = {
}
]
env_vars_static = {
AcceptableLatencyThresholdMs = "500"
AcceptableLatencyThresholdMs = "500"
RetrieveSupersededRecordsLast = "true"
}
}
Expand Down Expand Up @@ -864,7 +869,7 @@ function_apps = {
]
env_vars_static = {
AcceptableLatencyThresholdMs = "500"
MaxRetryCount=3
MaxRetryCount = 3
}
}

Expand Down
33 changes: 33 additions & 0 deletions infrastructure/tf-core/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ variable "TARGET_SUBSCRIPTION_ID" {
type = string
}

variable "OCP_APIM_SUBSCRIPTION_KEY" {
description = "API Management subscription key"
type = string
sensitive = true
default = null
}

variable "application" {
description = "Project/Application code for deployment"
type = string
Expand Down Expand Up @@ -93,6 +100,32 @@ variable "features" {
type = map(bool)
}

variable "availability_test" {
description = "Configuration for the Application Insights Standard Web Test"
type = object({
name_suffix = string
target_url = string

frequency = optional(number, 900)
timeout = optional(number, 30)

ssl_validation = optional(object({
enabled = optional(bool, true)
expected_status_code = optional(number, 200)
ssl_cert_remaining_lifetime = optional(number, 30)
}), {})

alert = optional(object({
description = optional(string, "Endpoint Availability & Certificate Expiry Monitoring")
frequency = optional(string, "PT1H")
window_size = optional(string, "P1D")
auto_mitigate = optional(bool, false)
}), {})
})

default = null
}

variable "regions" {
type = map(object({
address_space = optional(string)
Expand Down
Loading