Skip to content

Commit

Permalink
Cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
Shajida Akthar authored and Shajida Akthar committed Feb 29, 2024
1 parent 624b41f commit bf6c7f6
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 21 deletions.
1 change: 0 additions & 1 deletion terraform/environments/hmpps-oem/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -226,5 +226,4 @@ locals {
}

cloudwatch_monitoring_options = local.environment_cloudwatch_monitoring_options[local.environment]

}
3 changes: 1 addition & 2 deletions terraform/environments/hmpps-oem/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ module "baseline" {
}

module "cloudwatch_dashboard" {
source = "./modules/cloudwatch"
source = "./modules/cloudwatch_dashboard"
options = local.cloudwatch_monitoring_options
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
variable "source_account_ids" {
type = list(string)
default = ["612659970365", "546088120047"]
default = ["612659970365", "546088120047"] #nomis-test and oasys-test
}

variable "options" {
Expand Down
9 changes: 4 additions & 5 deletions terraform/environments/nomis/cloudwatch_dashboard/oam.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

resource "aws_oam_link" "source_account_oam_link" {
count = var.options.enable_hmpps-oem_monitoring ? 1 : 0
count = var.options.enable_hmpps-oem_monitoring ? 1 : 0
label_template = "nomis"
resource_types = ["AWS::CloudWatch::Metric"]
sink_identifier = var.monitoring_account_sink_identifier
Expand Down Expand Up @@ -33,8 +32,8 @@ data "aws_iam_policy" "policy" {
}

resource "aws_iam_role" "aws_cloudwatch_metrics_role" {
count = var.options.enable_hmpps-oem_monitoring ? 1 : 0
name = "CloudWatch-CrossAccountSharingRole"
count = var.options.enable_hmpps-oem_monitoring ? 1 : 0
name = "CloudWatch-CrossAccountSharingRole"
assume_role_policy = jsonencode(local.policy)
}

Expand All @@ -44,5 +43,5 @@ resource "aws_iam_role_policy_attachment" "policy" {
if var.options.enable_hmpps-oem_monitoring
])
policy_arn = data.aws_iam_policy.policy[each.key].arn
role = aws_iam_role.aws_cloudwatch_metrics_role[0].name
role = aws_iam_role.aws_cloudwatch_metrics_role[0].name
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
variable "monitoring_account_sink_identifier" {
type = string
type = string
default = "arn:aws:oam:eu-west-2:775245656481:sink/c2161e14-4683-4d84-ae2e-1eb7385e715b"
}

variable "monitoring_account_id" {
type = string
type = string
default = "775245656481" # hmpps-oem-test account
}

Expand All @@ -13,4 +13,4 @@ variable "options" {
type = object({
enable_hmpps-oem_monitoring = optional(bool, false)
})
}
}
1 change: 0 additions & 1 deletion terraform/environments/nomis/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -188,5 +188,4 @@ locals {
}

cloudwatch_monitoring_options = local.environment_cloudwatch_monitoring_options[local.environment]

}
9 changes: 4 additions & 5 deletions terraform/environments/oasys/cloudwatch_dashboard/oam.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

resource "aws_oam_link" "source_account_oam_link" {
count = var.options.enable_hmpps-oem_monitoring ? 1 : 0
count = var.options.enable_hmpps-oem_monitoring ? 1 : 0
label_template = "oasys"
resource_types = ["AWS::CloudWatch::Metric"]
sink_identifier = var.monitoring_account_sink_identifier
Expand Down Expand Up @@ -33,8 +32,8 @@ data "aws_iam_policy" "policy" {
}

resource "aws_iam_role" "aws_cloudwatch_metrics_role" {
count = var.options.enable_hmpps-oem_monitoring ? 1 : 0
name = "CloudWatch-CrossAccountSharingRole"
count = var.options.enable_hmpps-oem_monitoring ? 1 : 0
name = "CloudWatch-CrossAccountSharingRole"
assume_role_policy = jsonencode(local.policy)
}

Expand All @@ -44,5 +43,5 @@ resource "aws_iam_role_policy_attachment" "policy" {
if var.options.enable_hmpps-oem_monitoring
])
policy_arn = data.aws_iam_policy.policy[each.key].arn
role = aws_iam_role.aws_cloudwatch_metrics_role[0].name
role = aws_iam_role.aws_cloudwatch_metrics_role[0].name
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
variable "monitoring_account_sink_identifier" {
type = string
type = string
default = "arn:aws:oam:eu-west-2:775245656481:sink/c2161e14-4683-4d84-ae2e-1eb7385e715b"
}

variable "monitoring_account_id" {
type = string
type = string
default = "775245656481" # hmpps-oem-test account
}

Expand Down
1 change: 0 additions & 1 deletion terraform/environments/oasys/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -471,5 +471,4 @@ locals {
}

cloudwatch_monitoring_options = local.environment_cloudwatch_monitoring_options[local.environment]

}

0 comments on commit bf6c7f6

Please sign in to comment.