Skip to content

Commit

Permalink
TM-784: nomis link to reporting improved redundancy (#9184)
Browse files Browse the repository at this point in the history
* add additional web server

* -

* -

* -
  • Loading branch information
drobinson-moj authored Dec 24, 2024
1 parent 1aa5067 commit 2ffa03b
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 54 deletions.
20 changes: 2 additions & 18 deletions terraform/environments/nomis-combined-reporting/locals_lbs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,10 @@ locals {
}
}
listeners = {
http = {
port = 80
http-7777 = {
port = 7777
protocol = "HTTP"

default_action = {
type = "redirect"
redirect = {
port = 443
protocol = "HTTPS"
status_code = "HTTP_301"
}
}
}
https = {
certificate_names_or_arns = ["nomis_combined_reporting_wildcard_cert"]
cloudwatch_metric_alarms = module.baseline_presets.cloudwatch_metric_alarms.lb
port = 443
protocol = "HTTPS"
ssl_policy = "ELBSecurityPolicy-TLS13-1-2-2021-06"

default_action = {
type = "fixed-response"
fixed_response = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,32 @@ locals {

lbs = {
private = merge(local.lbs.private, {
instance_target_groups = {
private-pp-http-7777 = merge(local.lbs.public.instance_target_groups.http-7777, {
attachments = [
{ ec2_instance_name = "pp-ncr-web-1" },
]
})
}
listeners = merge(local.lbs.private.listeners, {
https = merge(local.lbs.private.listeners.https, {
certificate_names_or_arns = ["nomis_combined_reporting_wildcard_cert"]
http-7777 = merge(local.lbs.private.listeners.http-7777, {
alarm_target_group_names = []
rules = {
web = {
priority = 200
actions = [{
type = "forward"
target_group_name = "private-pp-http-7777"
}]
conditions = [{
host_header = {
values = [
"int.preproduction.reporting.nomis.service.justice.gov.uk",
]
}
}]
}
}
})
})
})
Expand Down Expand Up @@ -366,6 +389,7 @@ locals {
lb_alias_records = [
{ name = "", type = "A", lbs_map_key = "public" },
{ name = "admin", type = "A", lbs_map_key = "public" },
{ name = "int", type = "A", lbs_map_key = "private" },
]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,38 +118,6 @@ locals {

lbs = {
private = merge(local.lbs.private, {

instance_target_groups = {
pd-ncr-web = merge(local.lbs.private.instance_target_groups.web, {
attachments = [
# { ec2_instance_name = "pd-ncr-web-1-a" },
# add more instances here when deployed
]
})
}
listeners = merge(local.lbs.private.listeners, {
https = merge(local.lbs.private.listeners.https, {
certificate_names_or_arns = ["nomis_combined_reporting_wildcard_cert"]

rules = {
pd-ncr-web = {
priority = 4580
actions = [{
type = "forward"
target_group_name = "pd-ncr-web"
}]
conditions = [{
host_header = {
values = [
"production.reporting.nomis.service.justice.gov.uk",
"reporting.nomis.service.justice.gov.uk",
]
}
}]
}
}
})
})
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ locals {
protocol = "tcp"
cidr_blocks = local.security_group_cidrs.enduserclient_internal
}
http7777 = {
description = "Allow http7777 ingress"
from_port = 7777
to_port = 7777
protocol = "tcp"
cidr_blocks = local.security_group_cidrs.http7xxx
}
https = {
description = "Allow https ingress"
from_port = 443
Expand Down
31 changes: 29 additions & 2 deletions terraform/environments/nomis-combined-reporting/locals_test.tf
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,34 @@ locals {

lbs = {
private = merge(local.lbs.private, {
instance_target_groups = {}
listeners = {}
instance_target_groups = {
private-t1-http-7777 = merge(local.lbs.public.instance_target_groups.http-7777, {
attachments = [
{ ec2_instance_name = "t1-ncr-web-1" },
]
})
}
listeners = merge(local.lbs.private.listeners, {
http-7777 = merge(local.lbs.private.listeners.http-7777, {
alarm_target_group_names = []
rules = {
web = {
priority = 200
actions = [{
type = "forward"
target_group_name = "private-t1-http-7777"
}]
conditions = [{
host_header = {
values = [
"t1-int.test.reporting.nomis.service.justice.gov.uk",
]
}
}]
}
}
})
})
})

public = merge(local.lbs.public, {
Expand Down Expand Up @@ -187,6 +213,7 @@ locals {
]
lb_alias_records = [
{ name = "t1", type = "A", lbs_map_key = "public" },
{ name = "t1-int", type = "A", lbs_map_key = "private" },
]
}
}
Expand Down

0 comments on commit 2ffa03b

Please sign in to comment.