Skip to content

Commit 4604809

Browse files
authored
Merge pull request #48 from NHSDigital/feature/CCM-8200_grafana
CCM-8200: Add IAM role for grafana access
2 parents 831ab71 + f2cacf3 commit 4604809

8 files changed

+43
-9
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
resource "aws_iam_role" "grafana_access" {
2+
name = "${local.csi}-grafana-cross-access-role"
3+
assume_role_policy = data.aws_iam_policy_document.observability_grafana_role_assume_role_policy.json
4+
}
5+
6+
data "aws_iam_policy_document" "observability_grafana_role_assume_role_policy" {
7+
statement {
8+
actions = ["sts:AssumeRole"]
9+
effect = "Allow"
10+
principals {
11+
type = "AWS"
12+
identifiers = ["arn:aws:iam::${var.observability_account_id}:role/${local.csi}-grafana-workspace-role"]
13+
}
14+
}
15+
}
16+
17+
resource "aws_iam_role_policy_attachment" "grafana_workspace_cloudwatch" {
18+
role = aws_iam_role.grafana_access.name
19+
policy_arn = "arn:aws:iam::aws:policy/CloudWatchReadOnlyAccess"
20+
}

infrastructure/terraform/components/acct/module_s3bucket_lambda_function_artefacts.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ data "aws_iam_policy_document" "s3bucket_lambda_artefacts" {
100100
]
101101

102102
principals {
103-
type = "AWS"
103+
type = "AWS"
104104
identifiers = [
105105
"arn:aws:iam::${var.aws_account_id}:root"
106106
]
@@ -120,7 +120,7 @@ data "aws_iam_policy_document" "s3bucket_lambda_artefacts" {
120120
]
121121

122122
principals {
123-
type = "AWS"
123+
type = "AWS"
124124
identifiers = [
125125
"arn:aws:iam::${var.aws_account_id}:root"
126126
]

infrastructure/terraform/components/acct/outputs.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ output "dns_zone" {
99
output "s3_buckets" {
1010
value = {
1111
lambda_function_artefacts = {
12-
arn = module.s3bucket_lambda_artefacts.arn
12+
arn = module.s3bucket_lambda_artefacts.arn
1313
bucket = module.s3bucket_lambda_artefacts.bucket
14-
id = module.s3bucket_lambda_artefacts.id
14+
id = module.s3bucket_lambda_artefacts.id
1515
}
1616
}
1717
}

infrastructure/terraform/components/acct/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,8 @@ variable "root_domain_name" {
6262
description = "The service's root DNS root nameespace, like nonprod.nhsnotify.national.nhs.uk"
6363
default = "nonprod.nhsnotify.national.nhs.uk"
6464
}
65+
66+
variable "observability_account_id" {
67+
type = string
68+
description = "The Observability Account ID that needs access"
69+
}

infrastructure/terraform/components/cdn/cloudfront_distribution_cdn.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ resource "aws_cloudfront_distribution" "main" {
1111
restrictions {
1212
geo_restriction {
1313
restriction_type = "none" # Moved to WAF
14-
locations = [] # Moved to WAF
14+
locations = [] # Moved to WAF
1515
}
1616
}
1717

@@ -71,8 +71,8 @@ resource "aws_cloudfront_distribution" "main" {
7171
}
7272

7373
lambda_function_association {
74-
event_type = "viewer-response"
75-
lambda_arn = module.lambda_rewrite_viewer_trailing_slashes.function_qualified_arn
74+
event_type = "viewer-response"
75+
lambda_arn = module.lambda_rewrite_viewer_trailing_slashes.function_qualified_arn
7676
}
7777

7878
viewer_protocol_policy = "redirect-to-https"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
resource "aws_cloudfront_monitoring_subscription" "cdn" {
2+
distribution_id = aws_cloudfront_distribution.main.id
3+
4+
monitoring_subscription {
5+
realtime_metrics_subscription_config {
6+
realtime_metrics_subscription_status = "Enabled"
7+
}
8+
}
9+
}

infrastructure/terraform/components/cdn/wafv2_ip_set.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
resource "aws_wafv2_ip_set" "github_actions_ipv4" {
2-
count = var.enable_github_actions_ip_access ? 1:0
2+
count = var.enable_github_actions_ip_access ? 1 : 0
33

44
provider = aws.us-east-1
55

@@ -11,7 +11,7 @@ resource "aws_wafv2_ip_set" "github_actions_ipv4" {
1111
}
1212

1313
resource "aws_wafv2_ip_set" "github_actions_ipv6" {
14-
count = var.enable_github_actions_ip_access ? 1:0
14+
count = var.enable_github_actions_ip_access ? 1 : 0
1515

1616
provider = aws.us-east-1
1717

infrastructure/terraform/modules/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)