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

Add the tribunals applications #5381

Merged
merged 748 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
748 commits
Select commit Hold shift + click to select a range
bdef71c
rebuild ec2
matthewsearle01 Apr 9, 2024
0334347
try using windows registry to execute script, destroy ec2
matthewsearle01 Apr 9, 2024
002db56
retrigger
matthewsearle01 Apr 9, 2024
acaf50c
try commenting out new code
matthewsearle01 Apr 9, 2024
67bcdac
try putting ec2 back in
matthewsearle01 Apr 9, 2024
4dfe052
destroy ec2
matthewsearle01 Apr 9, 2024
f9e0fdb
rebuild ec2
matthewsearle01 Apr 9, 2024
1479d42
try using scheduled task again, destroy ec2
matthewsearle01 Apr 9, 2024
af90bff
rebuild
matthewsearle01 Apr 9, 2024
5c79b99
remove commmented out code
matthewsearle01 Apr 9, 2024
928abeb
destroy ec2 to test task scheduler
matthewsearle01 Apr 10, 2024
e6cb5c3
re-build ec2
matthewsearle01 Apr 10, 2024
36fcd73
destroy ec2, update file monitoring script to use aws copy instead of…
matthewsearle01 Apr 12, 2024
8db6fbc
rebuild ec2
matthewsearle01 Apr 12, 2024
1ad4351
update relativePath variable to replace backslashes with forward slas…
matthewsearle01 Apr 12, 2024
1fc067b
rebuild ec2
matthewsearle01 Apr 12, 2024
649a683
rebuild dev
matthewsearle01 Apr 15, 2024
9e1b405
remove key pair from launch template
matthewsearle01 Apr 15, 2024
2ca3011
build care-standards
matthewsearle01 Apr 17, 2024
543b213
update lb target group name to be under character limit
matthewsearle01 Apr 17, 2024
4d4b56d
undo change to lb target group name, add variables for cicap creation
matthewsearle01 Apr 17, 2024
da889f0
add rds ingress for each tribunal for db migration
matthewsearle01 Apr 17, 2024
e6f4fe9
fix rds ingress rules for ecs services
matthewsearle01 Apr 17, 2024
e57a19d
remove last commented out ingress rules
matthewsearle01 Apr 17, 2024
aa5378c
add the rest of the tribunals
matthewsearle01 Apr 17, 2024
d7bd4df
use abbrieviations for app names
matthewsearle01 Apr 17, 2024
c697703
fix paths to sql migration scripts
matthewsearle01 Apr 18, 2024
a6f8a62
fix path for lands_chamber
matthewsearle01 Apr 18, 2024
86c7802
fix file names
matthewsearle01 Apr 18, 2024
7f6cda9
update app name for ahmlr
matthewsearle01 Apr 18, 2024
6b8770c
add dns for each tribunal
matthewsearle01 Apr 18, 2024
d94e293
fix module names in dns_ssl.tf
matthewsearle01 Apr 18, 2024
a9610df
increase ec2 instance type to allow more cpu
matthewsearle01 Apr 18, 2024
3f6e7ee
destroy ec2
matthewsearle01 Apr 18, 2024
234df62
rebuild ec2
matthewsearle01 Apr 18, 2024
284f422
change app name value for ftt
matthewsearle01 Apr 18, 2024
c0e8d55
add symlink back in to user-data script, update app name variables
matthewsearle01 Apr 19, 2024
958e87b
destroy ec2
matthewsearle01 Apr 19, 2024
b22e94d
revert name changes
matthewsearle01 Apr 19, 2024
13aba04
rebuild ec2
matthewsearle01 Apr 19, 2024
f15dc94
uncomment instance profile
matthewsearle01 Apr 19, 2024
172b89e
update lb target group name, update app names
matthewsearle01 Apr 22, 2024
e35953c
update load balancer name to lb
matthewsearle01 Apr 22, 2024
9dd3b84
setup dms
matthewsearle01 Apr 22, 2024
aca8336
revert last commit
matthewsearle01 Apr 22, 2024
a60cf97
attempt to fix rds deadlock issue with depends_on
matt-k1998 Apr 22, 2024
989a48d
add depends_on to just one module
matt-k1998 Apr 22, 2024
a2736c0
add depends_on to two modules
matt-k1998 Apr 22, 2024
55d5f5c
add two more depends_on
matt-k1998 Apr 22, 2024
c5b0dda
add the rest of depends_on back in
matt-k1998 Apr 22, 2024
24253fe
try to add depends_on to all except three
matt-k1998 Apr 22, 2024
5865d4b
get rif of two more depends_on
matt-k1998 Apr 22, 2024
9e47d49
delete depends_on, add more tribunals to security groups
matt-k1998 Apr 23, 2024
578d639
comment out 7 tribunals to test db creation
matthewsearle01 Apr 23, 2024
a116747
remove ingress rules for commented out tribunals
matthewsearle01 Apr 23, 2024
f887761
comment out removed tribunals in dns_ssl.tf
matthewsearle01 Apr 23, 2024
52d56fa
comment out EC2 ingress rules for missing tribunals
matthewsearle01 Apr 23, 2024
5ccdcff
update the app_setup_db null resource to acquire and release locks, u…
matt-k1998 Apr 23, 2024
8e7a2d4
update the null resource
matt-k1998 Apr 23, 2024
d57b046
change the trigger back to what it was
matt-k1998 Apr 23, 2024
0f86e63
add previous_module_dummy values to module inputs to avoid deadlock w…
matthewsearle01 Apr 23, 2024
649c020
remove null_resouce change
matthewsearle01 Apr 23, 2024
10e1ae9
add depends_on based on dummy variables
matt-k1998 Apr 23, 2024
a7a2204
comment out all tribunals but three
matt-k1998 Apr 23, 2024
3fcbe65
create the next 3 modules
matthewsearle01 Apr 24, 2024
676da17
build last 4 tribunals, uncomment dns and lb sg ingress rules
matthewsearle01 Apr 24, 2024
e5812f6
fix commented out code, remove individual route53 records so they can…
matthewsearle01 Apr 24, 2024
78c05e2
add app_url as output value for modules
matthewsearle01 Apr 24, 2024
33eff65
add missing tribunal names to platform_locals.tf
matthewsearle01 Apr 24, 2024
9549308
uncomment aws_route53_record
matthewsearle01 Apr 24, 2024
66f2e23
add dns dynamically
matthewsearle01 Apr 24, 2024
543b097
fix reference to tribunal_module_names
matthewsearle01 Apr 24, 2024
f3cf1ab
fix reference to ahmlr
matthewsearle01 Apr 24, 2024
b3983bd
try fixing reference to ${local.tribunal_module_names[count.index]}
matthewsearle01 Apr 24, 2024
0424325
revert to using hardcoded route53 records
matthewsearle01 Apr 24, 2024
ac2130d
change ahmlr app name back to hmlands
matthewsearle01 Apr 24, 2024
0fe4078
destroy ec2
matt-k1998 Apr 24, 2024
15f8ba6
create a bigger ec2 - 4xl
matt-k1998 Apr 24, 2024
17eab1f
reduce cpu and memory in container definition, delete ec2
matt-k1998 Apr 25, 2024
f7a6d7e
recreate ec2
matt-k1998 Apr 25, 2024
acb8f72
reduce cpu and memory again, make documents location dynamic, delete ec2
matt-k1998 Apr 25, 2024
ad43d3b
recreate ec2
matt-k1998 Apr 25, 2024
fa1523e
update the memory and cpu back to what it was
matt-k1998 Apr 25, 2024
db36671
attempt to add a new module for the ftp tribunals
matt-k1998 Apr 25, 2024
2bf84c6
small syntax fixes
matt-k1998 Apr 25, 2024
525df40
add a second container definition for the ftp sites
matt-k1998 Apr 25, 2024
8f4064d
update new container definition
matt-k1998 Apr 25, 2024
fc59b7a
add more folders to the volume for ftp sites, delete ec2
matt-k1998 Apr 25, 2024
47545a0
get rid of all references to task_definition_volume_ftp, recreate ec2
matt-k1998 Apr 25, 2024
ad98360
add dns for charity ftp tribunal, add outputs for ftp module
matthewsearle01 Apr 26, 2024
58a1640
remove moj vpn ingress rule
matthewsearle01 Apr 26, 2024
7e9a303
delete unused tf file
matthewsearle01 Apr 26, 2024
2972a72
fix name for route53 record
matthewsearle01 Apr 26, 2024
65774d8
fix module references
matthewsearle01 Apr 26, 2024
b534752
get rid of the default index.html page in the container definition
matt-k1998 Apr 26, 2024
db7f5b4
expose port 80 in the container def for ftp sites
matt-k1998 Apr 26, 2024
ee57d77
add ports 20 and 21 back in
matt-k1998 Apr 26, 2024
2d1afa1
add command back in to ftp container definition
matthewsearle01 Apr 29, 2024
bee8ab6
comment out parts required for rebuild
matthewsearle01 Apr 29, 2024
511eea8
comment out cicap
matthewsearle01 Apr 29, 2024
4c0710d
uncomment cicap
matthewsearle01 Apr 29, 2024
563595f
try building 2 tribunals at a time
matthewsearle01 Apr 29, 2024
72ca286
build 2 more tribunals
matthewsearle01 Apr 29, 2024
64a3717
build the next 3 tribunals
matthewsearle01 Apr 29, 2024
1815c5e
build next 3
matthewsearle01 Apr 29, 2024
57f396c
comment out immigration services tribunal
matthewsearle01 Apr 29, 2024
ec7bc13
build 2 more tribunals
matthewsearle01 Apr 29, 2024
6cdb1df
build last 2 tribunals & uncomment ingress rules
matthewsearle01 Apr 29, 2024
3095181
update container_definition to allow ports 21 and 20 to be mapped to …
matthewsearle01 Apr 29, 2024
3b41c2c
add ftp port access to ec2 security group
matthewsearle01 Apr 29, 2024
38b9c3d
destroy ec2
matthewsearle01 Apr 29, 2024
4fd892d
rebuild ec2 in public subnet
matthewsearle01 Apr 29, 2024
b52785b
destroy ec2, add associate_public_ip_address = true
matthewsearle01 Apr 29, 2024
760bf54
rebuild ec2 with public ip address
matthewsearle01 Apr 29, 2024
ed0c3b4
add target group and lb listener for ftp
matt-k1998 Apr 30, 2024
41ad4c9
fix syntax error
matt-k1998 Apr 30, 2024
a6daedd
fix another syntax error
matt-k1998 Apr 30, 2024
2734dcb
fix syntax error
matt-k1998 Apr 30, 2024
d9ca8b8
get rid of stickiness
matt-k1998 Apr 30, 2024
b93a74b
update TCP to HTTP in lb listener
matt-k1998 Apr 30, 2024
411f7b5
create a network load balancer for the ftp lb listener and ftp target…
matt-k1998 Apr 30, 2024
1732372
update the network LB name
matt-k1998 Apr 30, 2024
242d36f
get rid of certificate from ftp LB listener
matt-k1998 Apr 30, 2024
96f9e43
attempt to only create the right target groups and load balancers for…
matt-k1998 May 1, 2024
060c3d7
add the is_ftp_app variable for all tribunals
matt-k1998 May 1, 2024
3a82879
temporarily delete target group and load balancer
matt-k1998 May 1, 2024
ba11063
recreate network load balancers and target groups
matt-k1998 May 1, 2024
89af51e
update the ftp container definition to use port 22, delete unneeded i…
matt-k1998 May 1, 2024
228573b
add a random password for sftp
matt-k1998 May 1, 2024
48209fe
get rid of special characters in the sftp password
matt-k1998 May 1, 2024
0e765f5
update the server port for SFTP sites to be 22
matt-k1998 May 2, 2024
f196fb1
update the target group port to 22
matt-k1998 May 2, 2024
636ff04
add config for network load balancer (for sftp connections)
matthewsearle01 May 3, 2024
3862bbc
rename sftp ecs service resource
matthewsearle01 May 3, 2024
32245d8
add count index for output "sftp_tribunals_target_group_arn"
matthewsearle01 May 3, 2024
693ab41
add sftp lb to outputs
matthewsearle01 May 3, 2024
6221e56
Revert "add sftp lb to outputs"
matthewsearle01 May 3, 2024
7cfe1ef
fix reference to tribunals_lb_ftp
matthewsearle01 May 3, 2024
0f5f2bd
add tribunals_lb_ftp to ecs_loadbalancer module
matthewsearle01 May 3, 2024
6c0f9d2
remove index from output
matthewsearle01 May 3, 2024
11dca70
remove index from
matthewsearle01 May 3, 2024
3ec780f
add conditional check to outputs.tf
matthewsearle01 May 3, 2024
2028187
add conditional to aws_appautoscaling_target
matthewsearle01 May 3, 2024
5187328
add a healthcheck LB listener
matt-k1998 May 3, 2024
6cdac46
fix syntax error
matt-k1998 May 3, 2024
4b59b5a
update how the target group is linked to the ecs loadbalancer module
matt-k1998 May 3, 2024
e290ccb
get rid of the healtheck for network LB as it only allows HTTP and HTTPS
matt-k1998 May 3, 2024
b124919
change the sftp C name record to an A name record
matt-k1998 May 3, 2024
6f41924
undo last change
matt-k1998 May 3, 2024
eb29dc2
attempt to get rid of sftp in the domain name
matt-k1998 May 3, 2024
10403c9
add sftp back into the DNS name
matt-k1998 May 3, 2024
d12bb91
set custom port instead of port 22 to see if that fixes SFTP
matt-k1998 May 3, 2024
ea40368
attempt to fix the sftp_host_port variable
matt-k1998 May 3, 2024
acc7b31
fix syntax error
matt-k1998 May 3, 2024
7f2091f
get rid of 'id' in the output
matt-k1998 May 3, 2024
67f40d1
move sftp_host_port to outputs of ecs_loadbalancer module
matt-k1998 May 3, 2024
562d4c7
change the output value
matt-k1998 May 3, 2024
7a56e8c
change value in ecs-cluster-shared
matt-k1998 May 3, 2024
ea0b024
fix sftp_host_port
matt-k1998 May 3, 2024
8bc5dec
put sftp_host_port in quotes
matt-k1998 May 3, 2024
642b03f
try to fix error sftp_host_port
matt-k1998 May 3, 2024
cfb6101
change sftp_host_port back to an int
matt-k1998 May 3, 2024
c19d410
change syntax in tribunal_ftp
matt-k1998 May 3, 2024
aa4d55d
hardcode the container port for now
matt-k1998 May 3, 2024
7c35f08
rebuild two tribunals + ftp tribunal
matt-k1998 May 7, 2024
133ee98
only create the first tribunal app + ftp tribunal
matt-k1998 May 7, 2024
9d8f6f8
add allow_overwrite option to aws_route53_record
matt-k1998 May 7, 2024
eb393cf
add two more tribunals
matt-k1998 May 7, 2024
3f0f8cf
add the next two tribunals
matt-k1998 May 7, 2024
47d0601
add one more tribunal
matt-k1998 May 7, 2024
a9c9ecd
get rid of finance and tax tribunal
matt-k1998 May 7, 2024
522f244
add the next two tribunals
matt-k1998 May 7, 2024
c3501ea
delete immigration services tribunal
matt-k1998 May 7, 2024
b797fc8
add the next 2
matt-k1998 May 7, 2024
50b7bad
add last 2 tribunals
matt-k1998 May 7, 2024
79d2e16
re-add security group rules for ecs and ec2
matt-k1998 May 7, 2024
fd85e9d
attempt to make sftp_host_port anumber and pass it into container_def…
matt-k1998 May 7, 2024
d382ffe
fix syntax error in container definition
matt-k1998 May 7, 2024
30e137c
add a tonumber conversion to container definition
matt-k1998 May 7, 2024
3a1be46
undo last change
matt-k1998 May 7, 2024
56b2856
update the sftp app container definition to use a jsonencode isntead …
matt-k1998 May 7, 2024
6ca4798
fix syntax of container definition
matt-k1998 May 7, 2024
aa2b25a
attempt to change the predefined port to a random port for SFTP
matt-k1998 May 8, 2024
0575003
set the network_mode of aws_ecs_task_definition to awsvpc
matt-k1998 May 8, 2024
c98cdf9
revert last change
matt-k1998 May 8, 2024
c6c0a58
Revert "attempt to change the predefined port to a random port for SFTP"
matt-k1998 May 9, 2024
8efc0de
add the next sftp tribunal - claims management decisions
matt-k1998 May 9, 2024
a9b9c73
shorten app_name to fix error
matt-k1998 May 9, 2024
2b7373d
update the port number for second sftp tribunal to see if that fixes …
matt-k1998 May 9, 2024
cc03a6c
add ingress rules for port 22 back in (for ecs SG)
matt-k1998 May 9, 2024
715a7ab
add port 22 back in for LB
matt-k1998 May 9, 2024
3c7032d
delete ec2
matt-k1998 May 9, 2024
c5a61e6
recreate ec2
matt-k1998 May 9, 2024
889b7cb
attempt to set the same port for both sftp apps
matt-k1998 May 9, 2024
b4ea666
delete the claims_management_decisions module temporarily
matt-k1998 May 9, 2024
793c7be
delete two more references to claims_management_decisions
matt-k1998 May 9, 2024
b250da4
recreate the claims_management_decisions module
matt-k1998 May 9, 2024
e96fbd6
update the target group to port 22 and host port in container definit…
matt-k1998 May 10, 2024
91ba989
recreate appeals and both of the sftp sites (create temp ingress rule…
matt-k1998 May 10, 2024
e966c8d
fix tribunal name in user data, delete ec2
matt-k1998 May 10, 2024
f88aca4
recreate ec2
matt-k1998 May 10, 2024
44e3e92
get rid of the no longer needed sftp_host_port variable
matt-k1998 May 10, 2024
065964c
put the sftp container definition back into a separate json file
matt-k1998 May 10, 2024
6654f9c
re-add the rest of the modules (ignoring DB deadlocks)
matt-k1998 May 10, 2024
4a509de
uncomment the modules in main.tf
matt-k1998 May 10, 2024
6ab8c79
rebuild nuked resources
matthewsearle01 May 13, 2024
de6780c
rebuild first 2 tribunals
matthewsearle01 May 13, 2024
dfabb07
comment out other tribunals
matthewsearle01 May 13, 2024
8465b05
comment out ingress rules for missing tribunals
matthewsearle01 May 13, 2024
397a20f
add infrastructure for consumer_credit_appeals sftp tribunal
matthewsearle01 May 17, 2024
c7a70ce
fix name length for consumer_credit_appeals lb
matthewsearle01 May 17, 2024
4b60881
fix url name in new route53 record
matthewsearle01 May 17, 2024
ed1e1bc
add care-standards and cicap tribunals
matthewsearle01 May 20, 2024
f0b2b02
build infrastructure for the other sftp tribunals
matthewsearle01 May 20, 2024
324b99e
remove incorrect ingress rule
matthewsearle01 May 20, 2024
35d018e
fix reference to primary health lists
matthewsearle01 May 20, 2024
4242d40
fix app name length for tax chancery and tax tribunal
matthewsearle01 May 20, 2024
a15a932
destroy ec2 temporarily
matthewsearle01 May 20, 2024
f647f89
rebuild the ec2
matthewsearle01 May 20, 2024
343885d
uncomment dms setup
matthewsearle01 May 20, 2024
68a2974
comment out sg creation
matthewsearle01 May 20, 2024
4de7218
add sg back in, now that it has been deleted from dsd account
matthewsearle01 May 20, 2024
1c8dbf4
update staging environment variables
matthewsearle01 May 20, 2024
91aaa4a
remove moj_ip variable
matthewsearle01 May 20, 2024
fe500c3
tidy up, remove un-used variables
matthewsearle01 May 20, 2024
0b3fb9e
comment out dms resources again
matthewsearle01 May 20, 2024
e9947c8
update dms_source_db variable to point to prod
matthewsearle01 May 21, 2024
ccc29b5
uncomment dms security group creation
matthewsearle01 May 21, 2024
d5d89d8
add infrastructure for ftp.admin-appeals tribunal
matthewsearle01 May 21, 2024
3f8c11b
add two next web apps
matt-k1998 May 21, 2024
98e2124
rebuild ftp admin appeals with unique url
matthewsearle01 May 21, 2024
8668b36
destroy ec2
matthewsearle01 May 22, 2024
d5ccff1
rebuild ec2 with m5.4xlarge
matthewsearle01 May 22, 2024
0cde5c4
add the next two DB tribunals
matt-k1998 May 22, 2024
5a88ad9
add the last two tribunals
matt-k1998 May 22, 2024
2e045e4
update url for ftp admin appeals
matthewsearle01 May 23, 2024
be41612
remove comment
matthewsearle01 May 23, 2024
d73eea2
change url to adminappealsreports
matthewsearle01 May 23, 2024
acdccff
add temp DB access
matthewsearle01 May 24, 2024
b5d48a6
attempt to add a waf for tribunals
matt-k1998 May 24, 2024
34ed34a
configure waf to be created for dotnet tribunals only
matthewsearle01 May 24, 2024
382cc90
set waf_arn to empty string for ftp tribunals
matthewsearle01 May 24, 2024
3f95e30
attempt to fix invalid arn error
matt-k1998 May 24, 2024
5cc8bca
try adding lb listener rules for /admin and /secure access
matthewsearle01 May 24, 2024
373068f
split conditions into two
matthewsearle01 May 24, 2024
d381534
remove last lb rule
matthewsearle01 May 24, 2024
f3b0d03
try using source_ip for condition
matthewsearle01 May 24, 2024
b98503c
change condition for 2nd rule
matthewsearle01 May 24, 2024
9ac651d
comment out tribunals for staging build
matthewsearle01 May 28, 2024
6facaa7
update dom1 ip range
matthewsearle01 May 28, 2024
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
4 changes: 3 additions & 1 deletion terraform/environments/tribunals/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Service Runbook
## Service Runbook

<!-- This is a template that should be populated by the development team when moving to the modernisation platform, but also reviewed and kept up to date.
To ensure that people looking at your runbook can get the information they need quickly, your runbook should be short but clear. Throughout, only use acronyms if you’re confident that someone who has just been woken up at 3am would understand them. -->
Expand Down Expand Up @@ -74,3 +74,5 @@ Modernisation Platform
### **How to resolve specific issues:**

<!-- Describe the steps someone might take to resolve a specific issue or incident, often for use when on call. This may be a large amount of information, so may need to be split out into multiple pages, or link to other documents.-->


92 changes: 89 additions & 3 deletions terraform/environments/tribunals/application_variables.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,102 @@
{
"accounts": {
"development": {
"example_var": "dev-data"
"allocated_storage": "20",
"storage_type": "gp2",
"db_identifier": "tribunals-db-dev",
"engine": "sqlserver-se",
"engine_version": "15.00.4198.2.v1",
"instance_class": "db.m5.large",
"username": "admin",
"dms_source_db": "ec2-34-243-192-28.eu-west-1.compute.amazonaws.com",
"curserver": "DEVELOPMENT",
"support_team": "DTS Legacy Apps Support Team",
"support_email": "[email protected]",
"server_port_1": "80",
"lb_listener_protocol_1": "HTTP",
"server_port_2": "443",
"lb_listener_protocol_2": "HTTPS",
"server_port_3": "22",
"lb_listener_protocol_3": "TCP",
"ami_image_id": "ami-0d20b6fc5007adcb3",
"task_definition_volume": "tribunals",
"server_port": 8080,
"app_count": 1,
"appscaling_min_capacity": 1,
"appscaling_max_capacity": 2,
"ec2_scaling_cpu_threshold": 75,
"ec2_scaling_mem_threshold": 61,
"ecs_scaling_cpu_threshold": 80,
"ecs_scaling_mem_threshold": 80
},
"test": {
"example_var": "test-data"
},
"preproduction": {
"example_var": "preproduction-data"
"allocated_storage": "20",
"storage_type": "gp2",
"db_identifier": "tribunals-db-preprod",
"engine": "sqlserver-se",
"engine_version": "15.00.4198.2.v1",
"instance_class": "db.m5.large",
"username": "admin",
"dms_source_db": "ec2-34-243-192-28.eu-west-1.compute.amazonaws.com",
"curserver": "PREPRODUCTION",
"support_team": "DTS Legacy Apps Support Team",
"support_email": "[email protected]",
"server_port_1": "80",
"lb_listener_protocol_1": "HTTP",
"server_port_2": "443",
"lb_listener_protocol_2": "HTTPS",
"server_port_3": "22",
"lb_listener_protocol_3": "TCP",
"ami_image_id": "ami-0d20b6fc5007adcb3",
"task_definition_volume": "tribunals",
"server_port": 8080,
"app_count": 1,
"appscaling_min_capacity": 1,
"appscaling_max_capacity": 6,
"ecs_scaling_cpu_threshold": 80,
"ecs_scaling_mem_threshold": 80
},
"production": {
"example_var": "production-data"
"allocated_storage": "20",
"storage_type": "gp2",
"db_identifier": "tribunals-db-prod",
"engine": "sqlserver-se",
"engine_version": "15.00.4198.2.v1",
"instance_class": "db.m5.large",
"username": "admin",
"dms_source_db": "ec2-34-243-192-28.eu-west-1.compute.amazonaws.com",
"curserver": "PRODUCTION",
"support_team": "DTS Legacy Apps Support Team",
"support_email": "[email protected]",
"server_port_1": "80",
"lb_listener_protocol_1": "HTTP",
"server_port_2": "443",
"lb_listener_protocol_2": "HTTPS",
"server_port_3": "22",
"lb_listener_protocol_3": "TCP",
"ami_image_id": "ami-0d233dc36193b1c63",
"task_definition_volume": "tribunals",
"server_port": 8080,
"app_count": 2,
"appscaling_min_capacity": 2,
"appscaling_max_capacity": 6,
"ecs_scaling_cpu_threshold": 80,
"ecs_scaling_mem_threshold": 80
}
},
"ec2_sg_rules": {
"TCP_80": {
"from_port": 80,
"to_port": 80,
"protocol": "TCP"
},
"TCP_443": {
"from_port": 443,
"to_port": 443,
"protocol": "TCP"
}
}
}
263 changes: 263 additions & 0 deletions terraform/environments/tribunals/asg-shared.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,263 @@
locals {
app_name = "tribunals-shared"
instance_role_name = join("-", [local.app_name, "ec2-instance-role"])
instance_profile_name = join("-", [local.app_name, "ec2-instance-profile"])
ec2_instance_policy = join("-", [local.app_name, "ec2-instance-policy"])
tags_common = local.tags
}

# Create an IAM policy for the custom permissions required by the EC2 hosting instance
resource "aws_iam_policy" "ec2_instance_policy" { #tfsec:ignore:aws-iam-no-policy-wildcards
name = local.ec2_instance_policy
tags = merge(
local.tags_common,
{
Name = local.ec2_instance_policy
}
)
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DetachVolume",
"ec2:AttachVolume",
"ec2:DescribeVolumes",
"ec2:DescribeTags",
"ec2:DescribeInstances",
"ecs:CreateCluster",
"ecs:DeregisterContainerInstance",
"ecs:DiscoverPollEndpoint",
"ecs:Poll",
"ecs:RegisterContainerInstance",
"ecs:StartTelemetrySession",
"ecs:UpdateContainerInstancesState",
"ecs:Submit*",
"ecs:TagResource",
"ecr:*",
"logs:CreateLogStream",
"logs:PutLogEvents",
"logs:CreateLogGroup",
"logs:DescribeLogStreams",
"s3:ListBucket",
"s3:*Object*",
"kms:Decrypt",
"kms:Encrypt",
"kms:GenerateDataKey",
"kms:ReEncrypt",
"kms:GenerateDataKey",
"kms:DescribeKey",
"xray:*"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": "ecs:TagResource",
"Resource": "*",
"Condition": {
"StringEquals": {
"ecs:CreateAction": [
"CreateCluster",
"RegisterContainerInstance"
]
}
}
}
]
}
EOF
}

# Create the IAM role to which the custom and predefined policies will be attached
# The role will be added to the ec2 instance profile which is added to the launch template
resource "aws_iam_role" "ec2_instance_role" {
name = local.instance_role_name
tags = merge(
local.tags,
{
Name = local.instance_role_name
}
)
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
}
EOF
}

resource "aws_iam_role_policy" "ec2_s3_access" {
name = "ec2-s3-access-policy"
role = aws_iam_role.ec2_instance_role.id
policy = jsonencode({
Version = "2012-10-17",
Statement = [
{
Effect = "Allow",
Action = [
"s3:GetObject",
"s3:PutObject",
"s3:DeleteObject",
"s3:ListBucket"
],
Resource = [
"${aws_s3_bucket.ebs_backup.arn}",
"${aws_s3_bucket.ebs_backup.arn}/*"
]
}
]
})
}

# Attach the custom policy and predefined policies to the role
resource "aws_iam_role_policy_attachment" "ec2_policy_instance_policy" {
role = aws_iam_role.ec2_instance_role.name
policy_arn = aws_iam_policy.ec2_instance_policy.arn
}

resource "aws_iam_role_policy_attachment" "ec2_policy_ssm_core" {
role = aws_iam_role.ec2_instance_role.name
policy_arn = "arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore"
}

resource "aws_iam_role_policy_attachment" "ec2_policy_cloudwatch" {
role = aws_iam_role.ec2_instance_role.name
policy_arn = "arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy"
}

# Create the Instance profile for the role
resource "aws_iam_instance_profile" "ec2_instance_profile" {
name = local.instance_profile_name
role = aws_iam_role.ec2_instance_role.name
tags = merge(
local.tags_common,
{
Name = local.instance_profile_name
}
)
}

# Create the Launch Template and assign the instance profile
resource "aws_launch_template" "tribunals-all-lt" {
name_prefix = "tribunals-all"
image_id = "ami-0b145c21f0f71b68c"
instance_type = "m5.4xlarge"
update_default_version = true

iam_instance_profile {
name = aws_iam_instance_profile.ec2_instance_profile.name
}

block_device_mappings {
device_name = "/dev/sda1"

ebs {
volume_size = 80
volume_type = "gp2"
}
}
ebs_optimized = true

network_interfaces {
device_index = 0
security_groups = [aws_security_group.cluster_ec2.id]
subnet_id = data.aws_subnet.public_subnets_a.id
delete_on_termination = true
associate_public_ip_address = true
}

user_data = filebase64("ec2-shared-user-data.sh")
}

# Finally, create the Auto scaling group for the launch template
resource "aws_autoscaling_group" "tribunals-all-asg" {
vpc_zone_identifier = [data.aws_subnet.public_subnets_a.id]
desired_capacity = 1
max_size = 1
min_size = 1
name = local.app_name

launch_template {
id = "${aws_launch_template.tribunals-all-lt.id}"
version = "$Latest"
}
}

###########################################################################


# EC2 Security Group
# Controls access to the EC2 instances

resource "aws_security_group" "cluster_ec2" {
#checkov:skip=CKV_AWS_23
name = "tribunals-cluster-ec2-security-group"
description = "controls access to the cluster ec2 instance"
vpc_id = data.aws_vpc.shared.id

ingress {
description = "Cluster EC2 ingress rule"
from_port = 0
to_port = 0
protocol = "-1"
security_groups = [
module.appeals.tribunals_lb_sc_id,
module.ahmlr.tribunals_lb_sc_id,
module.care_standards.tribunals_lb_sc_id,
module.cicap.tribunals_lb_sc_id,
module.employment_appeals.tribunals_lb_sc_id,
module.finance_and_tax.tribunals_lb_sc_id,
module.immigration_services.tribunals_lb_sc_id,
module.information_tribunal.tribunals_lb_sc_id,
module.lands_tribunal.tribunals_lb_sc_id,
module.transport.tribunals_lb_sc_id,
module.charity_tribunal_decisions.tribunals_lb_sc_id, module.charity_tribunal_decisions.tribunals_lb_sc_id_sftp,
module.claims_management_decisions.tribunals_lb_sc_id, module.claims_management_decisions.tribunals_lb_sc_id_sftp,
module.consumer_credit_appeals.tribunals_lb_sc_id, module.consumer_credit_appeals.tribunals_lb_sc_id_sftp,
module.estate_agent_appeals.tribunals_lb_sc_id, module.estate_agent_appeals.tribunals_lb_sc_id_sftp,
module.primary_health_lists.tribunals_lb_sc_id, module.primary_health_lists.tribunals_lb_sc_id_sftp,
module.siac.tribunals_lb_sc_id, module.siac.tribunals_lb_sc_id_sftp,
module.sscs_venue_pages.tribunals_lb_sc_id, module.sscs_venue_pages.tribunals_lb_sc_id_sftp,
module.tax_chancery_decisions.tribunals_lb_sc_id, module.tax_chancery_decisions.tribunals_lb_sc_id_sftp,
module.tax_tribunal_decisions.tribunals_lb_sc_id, module.tax_tribunal_decisions.tribunals_lb_sc_id_sftp,
module.ftp-admin-appeals.tribunals_lb_sc_id, module.ftp-admin-appeals.tribunals_lb_sc_id_sftp
]
}

ingress {
protocol = "tcp"
description = "Allow traffic from bastion"
from_port = 0
to_port = 0
security_groups = [
module.bastion_linux.bastion_security_group
]
}

egress {
description = "Cluster EC2 loadbalancer egress rule"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}

tags = merge(
local.tags_common,
{
Name = "tribunals-cluster-ec2-security-group"
}
)
}
Loading