Skip to content

Commit

Permalink
Merge branch 'improvement/add_cloud-init_to_replace_cwa_configuration…
Browse files Browse the repository at this point in the history
…' into testing/redeployment_updates
  • Loading branch information
mcdonnnj committed Oct 6, 2023
2 parents e097779 + ccd6651 commit 8125e8b
Show file tree
Hide file tree
Showing 11 changed files with 594 additions and 1 deletion.
9 changes: 9 additions & 0 deletions terraform/bod_bastion_cloud_init.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,13 @@ data "cloudinit_config" "bod_bastion_cloud_init_tasks" {
filename = "set_hostname.yml"
merge_type = "list(append)+dict(recurse_array)+str()"
}

part {
content = templatefile("${path.module}/cloud-init/configure_cloudwatch_agent.tpl.yml", {
cloudwatch_agent_log_group_base_name = local.bod_cloudwatch_agent_log_group_base
})
content_type = "text/cloud-config"
filename = "configure_cloudwatch_agent.yml"
merge_type = "list(append)+dict(recurse_array)+str()"
}
}
9 changes: 9 additions & 0 deletions terraform/bod_docker_cloud_init.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ data "cloudinit_config" "bod_docker_cloud_init_tasks" {
merge_type = "list(append)+dict(recurse_array)+str()"
}

part {
content = templatefile("${path.module}/cloud-init/configure_cloudwatch_agent.tpl.yml", {
cloudwatch_agent_log_group_base_name = local.bod_cloudwatch_agent_log_group_base
})
content_type = "text/cloud-config"
filename = "configure_cloudwatch_agent.yml"
merge_type = "list(append)+dict(recurse_array)+str()"
}

part {
content = templatefile("${path.module}/cloud-init/chown_directory.tpl.sh", {
group = "cyhy"
Expand Down
513 changes: 513 additions & 0 deletions terraform/cloud-init/configure_cloudwatch_agent.tpl.yml

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions terraform/cyhy_bastion_cloud_init.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,13 @@ data "cloudinit_config" "cyhy_bastion_cloud_init_tasks" {
filename = "set_hostname.yml"
merge_type = "list(append)+dict(recurse_array)+str()"
}

part {
content = templatefile("${path.module}/cloud-init/configure_cloudwatch_agent.tpl.yml", {
cloudwatch_agent_log_group_base_name = local.cyhy_cloudwatch_agent_log_group_base
})
content_type = "text/cloud-config"
filename = "configure_cloudwatch_agent.yml"
merge_type = "list(append)+dict(recurse_array)+str()"
}
}
9 changes: 9 additions & 0 deletions terraform/cyhy_dashboard_cloud_init.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ data "cloudinit_config" "cyhy_dashboard_cloud_init_tasks" {
merge_type = "list(append)+dict(recurse_array)+str()"
}

part {
content = templatefile("${path.module}/cloud-init/configure_cloudwatch_agent.tpl.yml", {
cloudwatch_agent_log_group_base_name = local.cyhy_cloudwatch_agent_log_group_base
})
content_type = "text/cloud-config"
filename = "configure_cloudwatch_agent.yml"
merge_type = "list(append)+dict(recurse_array)+str()"
}

part {
content = templatefile("${path.module}/cloud-init/chown_directory.tpl.sh", {
group = "cyhy"
Expand Down
9 changes: 9 additions & 0 deletions terraform/cyhy_mongo_cloud_init.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ data "cloudinit_config" "cyhy_mongo_cloud_init_tasks" {
merge_type = "list(append)+dict(recurse_array)+str()"
}

part {
content = templatefile("${path.module}/cloud-init/configure_cloudwatch_agent.tpl.yml", {
cloudwatch_agent_log_group_base_name = local.cyhy_cloudwatch_agent_log_group_base
})
content_type = "text/cloud-config"
filename = "configure_cloudwatch_agent.yml"
merge_type = "list(append)+dict(recurse_array)+str()"
}

part {
content = templatefile("${path.module}/cloud-init/chown_directory.tpl.sh", {
group = "cyhy"
Expand Down
9 changes: 9 additions & 0 deletions terraform/cyhy_nessus_cloud_init.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ data "cloudinit_config" "cyhy_nessus_cloud_init_tasks" {
merge_type = "list(append)+dict(recurse_array)+str()"
}

part {
content = templatefile("${path.module}/cloud-init/configure_cloudwatch_agent.tpl.yml", {
cloudwatch_agent_log_group_base_name = local.cyhy_cloudwatch_agent_log_group_base
})
content_type = "text/cloud-config"
filename = "configure_cloudwatch_agent.yml"
merge_type = "list(append)+dict(recurse_array)+str()"
}

part {
content = templatefile("${path.module}/cloud-init/chown_directory.tpl.sh", {
group = "cyhy"
Expand Down
9 changes: 9 additions & 0 deletions terraform/cyhy_nmap_cloud_init.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ data "cloudinit_config" "cyhy_nmap_cloud_init_tasks" {
merge_type = "list(append)+dict(recurse_array)+str()"
}

part {
content = templatefile("${path.module}/cloud-init/configure_cloudwatch_agent.tpl.yml", {
cloudwatch_agent_log_group_base_name = local.cyhy_cloudwatch_agent_log_group_base
})
content_type = "text/cloud-config"
filename = "configure_cloudwatch_agent.yml"
merge_type = "list(append)+dict(recurse_array)+str()"
}

part {
content = templatefile("${path.module}/cloud-init/chown_directory.tpl.sh", {
group = "cyhy"
Expand Down
9 changes: 9 additions & 0 deletions terraform/cyhy_reporter_cloud_init.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ data "cloudinit_config" "cyhy_reporter_cloud_init_tasks" {
merge_type = "list(append)+dict(recurse_array)+str()"
}

part {
content = templatefile("${path.module}/cloud-init/configure_cloudwatch_agent.tpl.yml", {
cloudwatch_agent_log_group_base_name = local.cyhy_cloudwatch_agent_log_group_base
})
content_type = "text/cloud-config"
filename = "configure_cloudwatch_agent.yml"
merge_type = "list(append)+dict(recurse_array)+str()"
}

part {
content = templatefile("${path.module}/cloud-init/chown_directory.tpl.sh", {
group = "cyhy"
Expand Down
8 changes: 8 additions & 0 deletions terraform/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ locals {
bod_public_subdomain = "bod.ncats."
mgmt_public_subdomain = "mgmt.ncats."

# This base will be used by all instances for their CloudWatch Agent
# configuration
cloudwatch_agent_log_group_base = "/instance-logs/${terraform.workspace}"
# CloudWatch Agent log group name base for cyhy instances
cyhy_cloudwatch_agent_log_group_base = "${local.cloudwatch_agent_log_group_base}/${local.cyhy_private_domain}"
# CloudWatch Agent log group name base for bod instances
bod_cloudwatch_agent_log_group_base = "${local.cloudwatch_agent_log_group_base}/${local.bod_private_domain}"

# DNS zone calculations based on requested instances. The numbers
# represent the count of IP addresses in a subnet.
#
Expand Down
2 changes: 1 addition & 1 deletion terraform/nvdsync_failure_alarms.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ resource "aws_cloudwatch_log_group" "instance_logs" {
#
# We have to account for the fact that the local hostname on the
# instance drops the local domain name.
name = "/instance-logs/${split(".", each.value)[0]}"
name = "${local.cloudwatch_agent_log_group_base}/${split(".", each.value)[1]}/${split(".", each.value)[0]}"
}

# Create a log metric filter that bumps a metric when a syslog
Expand Down

0 comments on commit 8125e8b

Please sign in to comment.