Skip to content

Commit 4cc1e3f

Browse files
Made changes requested in the pull request, removed potentially un-needed policies and roles
1 parent 7f8caa3 commit 4cc1e3f

File tree

1 file changed

+53
-53
lines changed

1 file changed

+53
-53
lines changed

infrastructure/cloudwatch_rum.tf

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
locals {
22
cognito_role_name = "${terraform.workspace}-cognito-unauth-role"
3-
rum_role_name = "${terraform.workspace}-rum-service-role"
3+
# rum_role_name = "${terraform.workspace}-rum-service-role"
44
}
55

6-
resource "aws_iam_role" "cloudwatch_rum" {
7-
count = local.is_production ? 0 : 1
8-
name = local.rum_role_name
9-
10-
assume_role_policy = jsonencode({
11-
Version = "2012-10-17",
12-
Statement = [
13-
{
14-
Effect = "Allow",
15-
Principal = {
16-
Service = "rum.amazonaws.com"
17-
},
18-
Action = "sts:AssumeRole"
19-
}
20-
]
21-
})
22-
}
6+
# resource "aws_iam_role" "cloudwatch_rum" {
7+
# count = local.is_production ? 0 : 1
8+
# name = local.rum_role_name
9+
10+
# assume_role_policy = jsonencode({
11+
# Version = "2012-10-17",
12+
# Statement = [
13+
# {
14+
# Effect = "Allow",
15+
# Principal = {
16+
# Service = "rum.amazonaws.com"
17+
# },
18+
# Action = "sts:AssumeRole"
19+
# }
20+
# ]
21+
# })
22+
# }
2323

2424
resource "aws_iam_role" "cognito_unauthenticated" {
2525
count = local.is_production ? 0 : 1
@@ -59,50 +59,50 @@ resource "aws_iam_policy" "cloudwatch_rum_cognito_access" {
5959
{
6060
"Effect" : "Allow",
6161
"Action" : "rum:PutRumEvents",
62-
"Resource" : "arn:aws:rum:${local.current_region}:${local.current_account_id}:appmonitor/${aws_rum_app_monitor.this[0].id}"
62+
"Resource" : "arn:aws:rum:${local.current_region}:${local.current_account_id}:appmonitor/${aws_rum_app_monitor.ndr[0].id}"
6363
}
6464
]
6565
})
6666
}
6767

68-
resource "aws_iam_policy" "cloudwatch_rum_management" {
69-
count = local.is_production ? 0 : 1
70-
name = "${terraform.workspace}-cloudwatch-rum-management-policy"
71-
description = "Policy to manage RUM app monitors and associated logs"
72-
73-
policy = jsonencode({
74-
Version = "2012-10-17",
75-
Statement = [
76-
{
77-
Effect = "Allow",
78-
Action = [
79-
"rum:CreateAppMonitor",
80-
"rum:DescribeAppMonitor",
81-
"rum:DeleteAppMonitor",
82-
"rum:UpdateAppMonitor",
83-
"rum:TagResource",
84-
"logs:CreateLogGroup",
85-
"logs:CreateLogStream",
86-
"logs:PutLogEvents",
87-
"iam:PassRole"
88-
],
89-
Resource = "*"
90-
}
91-
]
92-
})
93-
}
68+
# resource "aws_iam_policy" "cloudwatch_rum_management" {
69+
# count = local.is_production ? 0 : 1
70+
# name = "${terraform.workspace}-cloudwatch-rum-management-policy"
71+
# description = "Policy to manage RUM app monitors and associated logs"
72+
73+
# policy = jsonencode({
74+
# Version = "2012-10-17",
75+
# Statement = [
76+
# {
77+
# Effect = "Allow",
78+
# Action = [
79+
# "rum:CreateAppMonitor",
80+
# "rum:DescribeAppMonitor",
81+
# "rum:DeleteAppMonitor",
82+
# "rum:UpdateAppMonitor",
83+
# "rum:TagResource",
84+
# "logs:CreateLogGroup",
85+
# "logs:CreateLogStream",
86+
# "logs:PutLogEvents",
87+
# "iam:PassRole"
88+
# ],
89+
# Resource = "*"
90+
# }
91+
# ]
92+
# })
93+
# }
9494

9595
resource "aws_iam_role_policy_attachment" "cloudwatch_rum_cognito_unauth" {
9696
count = local.is_production ? 0 : 1
9797
role = aws_iam_role.cognito_unauthenticated[0].name
9898
policy_arn = aws_iam_policy.cloudwatch_rum_cognito_access[0].arn
9999
}
100100

101-
resource "aws_iam_role_policy_attachment" "cloudwatch_rum_management" {
102-
count = local.is_production ? 0 : 1
103-
role = aws_iam_role.cloudwatch_rum[0].name
104-
policy_arn = aws_iam_policy.cloudwatch_rum_management[0].arn
105-
}
101+
# resource "aws_iam_role_policy_attachment" "cloudwatch_rum_management" {
102+
# count = local.is_production ? 0 : 1
103+
# role = aws_iam_role.cloudwatch_rum[0].name
104+
# policy_arn = aws_iam_policy.cloudwatch_rum_management[0].arn
105+
# }
106106

107107
resource "aws_cognito_identity_pool_roles_attachment" "cloudwatch_rum" {
108108
count = local.is_production ? 0 : 1
@@ -119,16 +119,16 @@ resource "aws_cognito_identity_pool" "cloudwatch_rum" {
119119
allow_unauthenticated_identities = true
120120
}
121121

122-
resource "aws_rum_app_monitor" "this" {
122+
resource "aws_rum_app_monitor" "ndr" {
123123
count = local.is_production ? 0 : 1
124124
name = "${terraform.workspace}-app-monitor"
125-
domain = "*.patient-deductions.nhs.uk"
125+
domain = "*.${var.domain}"
126126
cw_log_enabled = false
127127

128128
app_monitor_configuration {
129129
identity_pool_id = aws_cognito_identity_pool.cloudwatch_rum[0].id
130130
allow_cookies = true
131-
enable_xray = true
131+
enable_xray = false
132132
session_sample_rate = 1.0
133133
telemetries = ["errors", "performance", "http"]
134134
}

0 commit comments

Comments
 (0)