Skip to content

Commit 05faaa7

Browse files
authored
Merge pull request #320 from NHSDigital/feature/CCM-8742_grafana
CCM-8742: grafana iam role
2 parents c6f5198 + 35c3ab8 commit 05faaa7

File tree

6 files changed

+20
-10
lines changed

6 files changed

+20
-10
lines changed

infrastructure/terraform/components/acct/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
| <a name="input_group"></a> [group](#input\_group) | The group variables are being inherited from (often synonmous with account short-name) | `string` | n/a | yes |
2020
| <a name="input_initial_cli_secrets_provision_override"></a> [initial\_cli\_secrets\_provision\_override](#input\_initial\_cli\_secrets\_provision\_override) | A map of default value to intialise SSM secret values with. Only useful for initial setup of the account due to lifecycle rules. | `map(string)` | `{}` | no |
2121
| <a name="input_log_retention_in_days"></a> [log\_retention\_in\_days](#input\_log\_retention\_in\_days) | The retention period in days for the Cloudwatch Logs events to be retained, default of 0 is indefinite | `number` | `0` | no |
22-
| <a name="input_observability_account_id"></a> [observability\_account\_id](#input\_observability\_account\_id) | The Observability Account ID that needs access | `string` | n/a | yes |
2322
| <a name="input_project"></a> [project](#input\_project) | The name of the tfscaffold project | `string` | n/a | yes |
2423
| <a name="input_region"></a> [region](#input\_region) | The AWS Region | `string` | n/a | yes |
2524
| <a name="input_root_domain_name"></a> [root\_domain\_name](#input\_root\_domain\_name) | The service's root DNS root nameespace, like nonprod.nhsnotify.national.nhs.uk | `string` | `"nonprod.nhsnotify.national.nhs.uk"` | no |

infrastructure/terraform/components/acct/variables.tf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,3 @@ variable "initial_cli_secrets_provision_override" {
7070
# Usage like:
7171
# ... -a apply -- -var initial_cli_secrets_provision_override={\"github_pat\":\"l0ngstr1ng"}
7272
}
73-
74-
variable "observability_account_id" {
75-
type = string
76-
description = "The Observability Account ID that needs access"
77-
}

infrastructure/terraform/components/app/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
| <a name="input_group"></a> [group](#input\_group) | The group variables are being inherited from (often synonmous with account short-name) | `string` | n/a | yes |
3838
| <a name="input_kms_deletion_window"></a> [kms\_deletion\_window](#input\_kms\_deletion\_window) | When a kms key is deleted, how long should it wait in the pending deletion state? | `string` | `"30"` | no |
3939
| <a name="input_log_retention_in_days"></a> [log\_retention\_in\_days](#input\_log\_retention\_in\_days) | The retention period in days for the Cloudwatch Logs events to be retained, default of 0 is indefinite | `number` | `0` | no |
40+
| <a name="input_observability_account_id"></a> [observability\_account\_id](#input\_observability\_account\_id) | The Observability Account ID that needs access | `string` | n/a | yes |
4041
| <a name="input_parent_acct_environment"></a> [parent\_acct\_environment](#input\_parent\_acct\_environment) | Name of the environment responsible for the acct resources used, affects things like DNS zone. Useful for named dev environments | `string` | `"main"` | no |
4142
| <a name="input_project"></a> [project](#input\_project) | The name of the tfscaffold project | `string` | n/a | yes |
4243
| <a name="input_region"></a> [region](#input\_region) | The AWS Region | `string` | n/a | yes |

infrastructure/terraform/components/acct/iam_role_grafana_access.tf renamed to infrastructure/terraform/components/app/iam_role_grafana_access.tf

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
resource "aws_iam_role" "grafana_access" {
2-
name = "${local.csi}-grafana-cross-access-role"
2+
name = replace("${local.csi}-grafana-cross-access-role", "-${var.component}", "")
33
assume_role_policy = data.aws_iam_policy_document.observability_grafana_role_assume_role_policy.json
44
}
55

@@ -8,8 +8,18 @@ data "aws_iam_policy_document" "observability_grafana_role_assume_role_policy" {
88
actions = ["sts:AssumeRole"]
99
effect = "Allow"
1010
principals {
11-
type = "AWS"
12-
identifiers = ["arn:aws:iam::${var.observability_account_id}:role/${local.csi}-grafana-workspace-role"]
11+
type = "AWS"
12+
identifiers = [
13+
"arn:aws:iam::${var.observability_account_id}:root"
14+
]
15+
}
16+
condition {
17+
test = "ArnLike"
18+
variable = "aws:PrincipalArn"
19+
20+
values = [
21+
"arn:aws:iam::${var.observability_account_id}:role/*grafana-workspace-role"
22+
]
1323
}
1424
}
1525
}

infrastructure/terraform/components/app/module_nhse_backup_vault.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module "nhse_backup_vault" {
22
source = "git::https://github.com/NHSDigital/nhs-notify-shared-modules.git//infrastructure/modules/aws-backup-source?ref=v1.0.8"
3-
count = var.destination_vault_arn != null ? 1:0
3+
count = var.destination_vault_arn != null ? 1 : 0
44

55
component = var.component
66
environment = var.environment

infrastructure/terraform/components/app/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,8 @@ variable "enable_letters" {
187187
description = "Feature flag for letters"
188188
default = false
189189
}
190+
191+
variable "observability_account_id" {
192+
type = string
193+
description = "The Observability Account ID that needs access"
194+
}

0 commit comments

Comments
 (0)