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

TM-844: ncr: add maintenance mode lb option #9195

Merged
merged 6 commits into from
Jan 2, 2025
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
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>
Loading