Skip to content

Commit

Permalink
TM-844: ncr: add maintenance mode lb option (#9195)
Browse files Browse the repository at this point in the history
* TM-844: add maintenance mode lb rule for test

* TM-844: add maintenance mode lb rule for preprod

* -

* -

* add preprod internal maintenance

* update policy
  • Loading branch information
drobinson-moj authored Jan 2, 2025
1 parent 1c6141e commit 49a0367
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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 <a href=\"https://moj.enterprise.slack.com/archives/C6D94J81E\">#ask-digital-studio-ops</a> slack channel if environment is unexpecedly down."
}

baseline_presets_preproduction = {
options = {
sns_topics = {
Expand Down Expand Up @@ -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/*",
]
}
]
}
Expand Down Expand Up @@ -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",
]
}
}]
}
}
})
})
Expand Down Expand Up @@ -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",
]
}
}]
}
}
})
})
Expand All @@ -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" },
]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/*",
]
}
]
}
Expand Down
62 changes: 62 additions & 0 deletions terraform/environments/nomis-combined-reporting/locals_test.tf
Original file line number Diff line number Diff line change
@@ -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 <a href=\"https://moj.enterprise.slack.com/archives/C6D94J81E\">#ask-digital-studio-ops</a> slack channel if environment is unexpecedly down."
}

baseline_presets_test = {
options = {
sns_topics = {
Expand Down Expand Up @@ -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/*",
]
}
]
}
Expand Down Expand Up @@ -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",
]
}
}]
}
}
})
})
Expand Down Expand Up @@ -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",
]
}
}]
}
}
})
})
Expand All @@ -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" },
]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>${maintenance_title}</title>
<meta name="description" content="">
<meta name="author" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
</head>
<body>
<h1>${maintenance_title}</h1>
<p>${maintenance_message}</p>
</body>
</html>

0 comments on commit 49a0367

Please sign in to comment.