Skip to content

Commit 3efbf98

Browse files
author
Alistair Davidson
committed
Merge branch 'reporting_service_infrastructure' into spike/MAV-1406-auth-sharing-with-reporting
2 parents e22ef59 + b1cf718 commit 3efbf98

File tree

4 files changed

+51
-8
lines changed

4 files changed

+51
-8
lines changed

terraform/account/deployment_permissions.tf

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,33 @@ resource "aws_iam_role" "deploy_ecs_service" {
5555
description = "Role allowing terraform deployment of ECS services from github workflows"
5656
assume_role_policy = templatefile("resources/iam_role_github_trust_policy_${var.environment}.json.tftpl", {
5757
account_id = var.account_id,
58-
repository = "NHSDigital/mavis-reporting-prototype"
58+
repository = "NHSDigital/manage-vaccinations-in-schools-reporting"
59+
})
60+
}
61+
62+
resource "aws_iam_policy" "deploy_ecs_service" {
63+
name = "DeployECSServiceResources"
64+
description = "Permissions for GithubDeployECSService role"
65+
policy = file("resources/iam_policy_DeployECSServiceResources.json")
66+
lifecycle {
67+
ignore_changes = [description]
68+
}
69+
}
70+
71+
resource "aws_iam_role_policy_attachment" "deploy_ecs_service" {
72+
for_each = local.ecs_deploy_policies
73+
role = aws_iam_role.deploy_ecs_service.name
74+
policy_arn = each.value
75+
}
76+
77+
################# Deploy Monitoring ################
78+
79+
resource "aws_iam_role" "deploy_ecs_service" {
80+
name = "GithubDeployECSService"
81+
description = "Role allowing terraform deployment of ECS services from github workflows"
82+
assume_role_policy = templatefile("resources/iam_role_github_trust_policy_${var.environment}.json.tftpl", {
83+
account_id = var.account_id,
84+
repository = "nhsuk/manage-vaccinations-in-schools"
5985
})
6086
}
6187

terraform/account/resources/iam_policy_DeployMavisResources.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,13 @@
133133
"secretsmanager:CancelRotateSecret",
134134
"ssm:DeleteParameter",
135135
"ssm:DeleteParameters",
136-
"ssm:PutParameter"
136+
"ssm:PutParameter",
137+
"lambda:InvokeFunction",
138+
"lambda:DeleteFunction",
139+
"lambda:CreateFunction",
140+
"lambda:CreateAlias",
141+
"lambda:DeleteAlias",
142+
"lambda:UpdateAlias"
137143
],
138144
"Resource": ["*"]
139145
}

terraform/app/ecs.tf

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,17 @@ resource "aws_service_discovery_service" "web" {
7373
module "web_service" {
7474
source = "./modules/ecs_service"
7575
task_config = {
76-
environment = local.task_envs
76+
environment = concat(local.task_envs, [
77+
{
78+
name = "MAVIS__REPORTING_API__CLIENT_APP__CLIENT_ID"
79+
value = aws_secretsmanager_secret.jwt_sign.name
80+
}
81+
]
82+
)
7783
secrets = concat(
7884
local.task_secrets,
7985
[{
80-
name = "JSON_SIGNING_SECRET"
86+
name = "MAVIS__REPORTING_API__CLIENT_APP__SECRET"
8187
valueFrom = aws_secretsmanager_secret.jwt_sign.arn
8288
}]
8389
)
@@ -153,10 +159,14 @@ module "reporting_service" {
153159
{
154160
name = "VALKEY_PORT"
155161
value = aws_elasticache_serverless_cache.reporting_service.endpoint[0].port
162+
},
163+
{
164+
name = "CLIENT_ID"
165+
value = aws_secretsmanager_secret.jwt_sign.name
156166
}
157167
]
158168
secrets = [{
159-
name = "JSON_SIGNING_SECRET"
169+
name = "CLIENT_SECRET"
160170
valueFrom = aws_secretsmanager_secret.jwt_sign.arn
161171
}]
162172
cpu = 1024
@@ -166,7 +176,7 @@ module "reporting_service" {
166176
task_role_arn = aws_iam_role.ecs_task_role.arn
167177
log_group_name = aws_cloudwatch_log_group.ecs_log_group.name
168178
region = var.region
169-
health_check_command = ["CMD-SHELL", "wget http://localhost:${local.container_ports.reporting}/healthcheck || exit 0"] #TODO: Fix healthcheck and change to exit 1
179+
health_check_command = ["CMD-SHELL", "wget --no-cache --spider -S http://localhost:${local.container_ports.reporting}/reporting/healthcheck || exit 1"]
170180
}
171181
network_params = {
172182
subnets = [aws_subnet.private_subnet_a.id, aws_subnet.private_subnet_b.id]

terraform/app/loadbalancer.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ resource "aws_lb" "app_lb" {
6868
}
6969
security_groups = [aws_security_group.lb_service_sg.id]
7070
subnets = [aws_subnet.public_subnet_a.id, aws_subnet.public_subnet_b.id]
71+
depends_on = [aws_security_group_rule.lb_ingress_https] #TODO: Delete after migration
7172
drop_invalid_header_fields = true
7273
}
7374

@@ -114,7 +115,7 @@ resource "aws_lb_target_group" "reporting_blue" {
114115
vpc_id = aws_vpc.application_vpc.id
115116
target_type = "ip"
116117
health_check {
117-
path = "/healthcheck"
118+
path = "/reporting/healthcheck"
118119
protocol = "HTTP"
119120
port = "traffic-port"
120121
matcher = "200"
@@ -132,7 +133,7 @@ resource "aws_lb_target_group" "reporting_green" {
132133
vpc_id = aws_vpc.application_vpc.id
133134
target_type = "ip"
134135
health_check {
135-
path = "/healthcheck"
136+
path = "/reporting/healthcheck"
136137
protocol = "HTTP"
137138
port = "traffic-port"
138139
matcher = "200"

0 commit comments

Comments
 (0)