Skip to content

Commit

Permalink
Add nGsrv log groups
Browse files Browse the repository at this point in the history
  • Loading branch information
marcransome committed Apr 16, 2021
1 parent 48756df commit 7bd0419
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 5 deletions.
2 changes: 1 addition & 1 deletion groups/frontend/iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module "instance_profile" {
source = "[email protected]:companieshouse/terraform-modules//aws/instance_profile?ref=tags/1.0.62"
name = "tuxedo-frontend-profile"

cw_log_group_arns = [for log_group in aws_cloudwatch_log_group.logs : log_group.arn]
cw_log_group_arns = [for log_group in merge(aws_cloudwatch_log_group.tuxedo, aws_cloudwatch_log_group.ngsrv) : log_group.arn]
enable_SSM = true
kms_key_refs = [
local.ssm_kms_key_id
Expand Down
18 changes: 16 additions & 2 deletions groups/frontend/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ locals {
}
]...)

tuxedo_user_log_groups = merge([
tuxedo_user_log_groups = merge([
for tuxedo_service_key, tuxedo_logs_list in var.tuxedo_user_logs : {
for tuxedo_log in tuxedo_logs_list[*].name : "${var.service_subtype}-${var.service}-${tuxedo_service_key}-${lower(tuxedo_log)}" => {
log_retention_in_days = lookup(tuxedo_logs_list[index(tuxedo_logs_list.*.name, tuxedo_log)], "log_retention_in_days", var.default_log_retention_in_days)
Expand All @@ -51,7 +51,21 @@ locals {
}
]...)

tuxedo_log_groups = merge(local.tuxedo_service_log_groups, local.tuxedo_user_log_groups)
tuxedo_ngsrv_log_groups = merge([
for tuxedo_service_key, ngsrv_logs_list in var.tuxedo_ngsrv_logs : {
for ngsrv_log in ngsrv_logs_list[*].name : "${var.service_subtype}-${var.service}-${tuxedo_service_key}-ngsrv-${lower(ngsrv_log)}" => {
log_retention_in_days = lookup(ngsrv_logs_list[index(ngsrv_logs_list.*.name, ngsrv_log)], "log_retention_in_days", var.default_log_retention_in_days)
kms_key_id = lookup(ngsrv_logs_list[index(ngsrv_logs_list.*.name, ngsrv_log)], "kms_key_id", local.logs_kms_key_id)
tuxedo_service = tuxedo_service_key
log_name = ngsrv_log
}
}
]...)

tuxedo_log_groups = merge(
local.tuxedo_service_log_groups,
local.tuxedo_user_log_groups
)

logs_kms_key_id = data.vault_generic_secret.kms_keys.data["logs"]
}
15 changes: 14 additions & 1 deletion groups/frontend/logs.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resource "aws_cloudwatch_log_group" "logs" {
resource "aws_cloudwatch_log_group" "tuxedo" {
for_each = local.tuxedo_log_groups

name = each.key
Expand All @@ -11,3 +11,16 @@ resource "aws_cloudwatch_log_group" "logs" {
TuxedoLogType = each.value.log_type
})
}

resource "aws_cloudwatch_log_group" "ngsrv" {
for_each = local.tuxedo_ngsrv_log_groups

name = each.key
retention_in_days = each.value.log_retention_in_days
kms_key_id = each.value.kms_key_id

tags = merge(local.common_tags, {
TuxedoServerType = each.value.tuxedo_service
nGsrvLogName = each.value.log_name
})
}
28 changes: 27 additions & 1 deletion groups/frontend/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,36 @@ variable "service_subtype" {
default = "frontend"
}

variable "tuxedo_ngsrv_logs" {
type = map(list(any))
description = "A map whose keys represent server-side tuxedo server groups with lists of objects representing nGsrv log files for each server group. Each object is expected to have at a minimum a 'name' key. A single log group will be created for each object. Optional 'log_retention_in_days' and 'kms_key_id' attributes can be set per-oject to override the default values."
default = {
ewf = [
{ name: "ois" },
{ name: "search" },
{ name: "chips" },
{ name: "ef" },
{ name: "ixbrl" },
{ name: "tnep" },
{ name: "trans" },
{ name: "gen" }
]
xml = [
{ name: "ois" },
{ name: "search" },
{ name: "chips" },
{ name: "ef" },
{ name: "ixbrl" },
{ name: "tnep" },
{ name: "trans" },
{ name: "gen" }
]
}
}

variable "tuxedo_service_logs" {
type = map(list(any))
description = "A map whose keys represent server-side tuxedo server groups with lists of objects representing individual log files for each server group. Each object is expected to have at a minimum a 'name' key. Two CloudWatch log groups will be created for each object for standard output and standard error streams respectively. Optional 'log_retention_in_days' and 'kms_key_id' attributes can be set per-oject to override the default values and will apply to both standard error and standard output log groups for that log."
description = "A map whose keys represent server-side tuxedo server groups with lists of objects representing user log files for each server group. Each object is expected to have at a minimum a 'name' key. Two CloudWatch log groups will be created for each object for standard output and standard error streams respectively. Optional 'log_retention_in_days' and 'kms_key_id' attributes can be set per-oject to override the default values and will apply to both standard error and standard output log groups for that log."
default = {
ewf = [
{ name: "CHG" },
Expand Down

0 comments on commit 7bd0419

Please sign in to comment.