diff --git a/terraform/environments/nomis-combined-reporting/locals_preproduction.tf b/terraform/environments/nomis-combined-reporting/locals_preproduction.tf index 75a20b6b00f..b6163478124 100644 --- a/terraform/environments/nomis-combined-reporting/locals_preproduction.tf +++ b/terraform/environments/nomis-combined-reporting/locals_preproduction.tf @@ -1,5 +1,10 @@ locals { + lb_maintenance_message_preproduction = { + maintenance_title = "Prison-NOMIS Reporting LSAST and/or Pre-Production Maintenance Window" + maintenance_message = "Prison-NOMIS Reporting LSAST and/or Pre-Production is currently unavailable due to planned maintenance or out-of-hours shutdown (7pm-7am). Please contact #ask-digital-studio-ops slack channel if environment is unexpecedly down." + } + baseline_presets_preproduction = { options = { sns_topics = { @@ -251,6 +256,23 @@ locals { "arn:aws:secretsmanager:*:*:secret:/oracle/database/*LS/*", "arn:aws:secretsmanager:*:*:secret:/oracle/database/LS*/*", ] + }, + { + effect = "Allow" + actions = [ + "elasticloadbalancing:Describe*", + ] + resources = ["*"] + }, + { + effect = "Allow" + actions = [ + "elasticloadbalancing:SetRulePriorities", + ] + resources = [ + "arn:aws:elasticloadbalancing:*:*:listener-rule/app/private-lb/*", + "arn:aws:elasticloadbalancing:*:*:listener-rule/app/public-lb/*", + ] } ] } @@ -319,6 +341,25 @@ locals { } }] } + maintenance = { + priority = 999 + actions = [{ + type = "fixed-response" + fixed_response = { + content_type = "text/html" + message_body = templatefile("templates/maintenance.html.tftpl", local.lb_maintenance_message_preproduction) + status_code = "200" + } + }] + conditions = [{ + host_header = { + values = [ + "int.preproduction.reporting.nomis.service.justice.gov.uk", + "maintenance-int.preproduction.reporting.nomis.service.justice.gov.uk", + ] + } + }] + } } }) }) @@ -369,6 +410,25 @@ locals { } }] } + maintenance = { + priority = 999 + actions = [{ + type = "fixed-response" + fixed_response = { + content_type = "text/html" + message_body = templatefile("templates/maintenance.html.tftpl", local.lb_maintenance_message_preproduction) + status_code = "200" + } + }] + conditions = [{ + host_header = { + values = [ + "maintenance.preproducion.reporting.nomis.service.justice.gov.uk", + "preproduction.reporting.nomis.service.justice.gov.uk", + ] + } + }] + } } }) }) @@ -390,6 +450,8 @@ locals { { name = "", type = "A", lbs_map_key = "public" }, { name = "admin", type = "A", lbs_map_key = "public" }, { name = "int", type = "A", lbs_map_key = "private" }, + { name = "maintenance", type = "A", lbs_map_key = "public" }, + { name = "maintenance-int", type = "A", lbs_map_key = "private" }, ] } } diff --git a/terraform/environments/nomis-combined-reporting/locals_production.tf b/terraform/environments/nomis-combined-reporting/locals_production.tf index 0e5ebee949d..8a37433ae87 100644 --- a/terraform/environments/nomis-combined-reporting/locals_production.tf +++ b/terraform/environments/nomis-combined-reporting/locals_production.tf @@ -111,6 +111,23 @@ locals { "arn:aws:secretsmanager:*:*:secret:/oracle/database/*PD/*", "arn:aws:secretsmanager:*:*:secret:/oracle/database/PD*/*", ] + }, + { + effect = "Allow" + actions = [ + "elasticloadbalancing:Describe*", + ] + resources = ["*"] + }, + { + effect = "Allow" + actions = [ + "elasticloadbalancing:SetRulePriorities", + ] + resources = [ + "arn:aws:elasticloadbalancing:*:*:listener-rule/app/private-lb/*", + "arn:aws:elasticloadbalancing:*:*:listener-rule/app/public-lb/*", + ] } ] } diff --git a/terraform/environments/nomis-combined-reporting/locals_test.tf b/terraform/environments/nomis-combined-reporting/locals_test.tf index 0903eaaa9ec..0de4aafd429 100644 --- a/terraform/environments/nomis-combined-reporting/locals_test.tf +++ b/terraform/environments/nomis-combined-reporting/locals_test.tf @@ -1,5 +1,10 @@ locals { + lb_maintenance_message_test = { + maintenance_title = "Prison-NOMIS Reporting T1 Maintenance Window" + maintenance_message = "Prison-NOMIS Reporting T1 is currently unavailable due to planned maintenance or out-of-hours shutdown (7pm-7am). Please contact #ask-digital-studio-ops slack channel if environment is unexpecedly down." + } + baseline_presets_test = { options = { sns_topics = { @@ -137,6 +142,23 @@ locals { "arn:aws:secretsmanager:*:*:secret:/oracle/database/*T1/*", "arn:aws:secretsmanager:*:*:secret:/oracle/database/T1*/*", ] + }, + { + effect = "Allow" + actions = [ + "elasticloadbalancing:Describe*", + ] + resources = ["*"] + }, + { + effect = "Allow" + actions = [ + "elasticloadbalancing:SetRulePriorities", + ] + resources = [ + "arn:aws:elasticloadbalancing:*:*:listener-rule/app/private-lb/*", + "arn:aws:elasticloadbalancing:*:*:listener-rule/app/public-lb/*", + ] } ] } @@ -169,6 +191,25 @@ locals { } }] } + maintenance = { + priority = 999 + actions = [{ + type = "fixed-response" + fixed_response = { + content_type = "text/html" + message_body = templatefile("templates/maintenance.html.tftpl", local.lb_maintenance_message_test) + status_code = "200" + } + }] + conditions = [{ + host_header = { + values = [ + "t1-int.test.reporting.nomis.service.justice.gov.uk", + "maintenance-int.test.reporting.nomis.service.justice.gov.uk", + ] + } + }] + } } }) }) @@ -200,6 +241,25 @@ locals { } }] } + maintenance = { + priority = 999 + actions = [{ + type = "fixed-response" + fixed_response = { + content_type = "text/html" + message_body = templatefile("templates/maintenance.html.tftpl", local.lb_maintenance_message_test) + status_code = "200" + } + }] + conditions = [{ + host_header = { + values = [ + "t1.test.reporting.nomis.service.justice.gov.uk", + "maintenance.test.reporting.nomis.service.justice.gov.uk", + ] + } + }] + } } }) }) @@ -212,6 +272,8 @@ locals { { name = "db", type = "CNAME", ttl = "3600", records = ["t1-ncr-db-1-a.nomis-combined-reporting.hmpps-test.modernisation-platform.service.justice.gov.uk"] }, ] lb_alias_records = [ + { name = "maintenance", type = "A", lbs_map_key = "public" }, + { name = "maintenance-int", type = "A", lbs_map_key = "private" }, { name = "t1", type = "A", lbs_map_key = "public" }, { name = "t1-int", type = "A", lbs_map_key = "private" }, ] diff --git a/terraform/environments/nomis-combined-reporting/templates/maintenance.html.tftpl b/terraform/environments/nomis-combined-reporting/templates/maintenance.html.tftpl new file mode 100644 index 00000000000..4ed7500b850 --- /dev/null +++ b/terraform/environments/nomis-combined-reporting/templates/maintenance.html.tftpl @@ -0,0 +1,17 @@ + + + + + ${maintenance_title} + + + + + + + + +

${maintenance_title}

+

${maintenance_message}

+ +