Skip to content

PLT-1776 : modules support log retention - #624

Open
jasonvinson wants to merge 24 commits into
mainfrom
PLT-1776-modules-support-log-retention
Open

jasonvinson wants to merge 24 commits into
mainfrom
PLT-1776-modules-support-log-retention

Conversation

@jasonvinson

Copy link
Copy Markdown
Contributor

🎫 Ticket

https://jira.cms.gov/browse/PLT-1776

🛠 Changes

  • Replace raw cloudwatch_log_group creation in Function and Service modules with calls to shared cloudwatch_log_group module, ensuring unified log retention
  • add related permissions to Github Actions role
  • Move TFtesting example function to numbered service
  • Remove logs:CreateLogGroup permission from service module role to ensure any logs created are routed through shared cloudwatch_log_group module, ensuring unified log retention

ℹ️ Context

We are moving to a shared long term log retention strategy to ensure regulatory compliance.

🧪 Validation

Changes were tested by deploying test Function, Cluster, and Service instances to test environment and log delivery to retention bucket was verified.

- new shared naming convention for resources shared by multiple apps
- use modules/cloudwatch_log_group
- remove var.app as this pipeline is cdap managed only
- remove references to prod. We want to firm this up as much as possible in test first
- add cdap-test-log-retention KMS key references to 900-github-actions-role/config/cdap yml files
- also move tftesting function to numbered service
- update 701-log-retention/main.tf to properly parse cloudwatch control messages
@jasonvinson
jasonvinson requested a review from a team as a code owner October 5, 2026 18:56
@@ -1,5 +1,27 @@
locals {
cdap_env = contains(["prod", "sandbox"], var.env) ? "prod" : "test"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it fair to assume that inheriting the platform module here would be overload?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah the platform module is a bit heavy in terms of data lookups, so I think it would be overkill here.

kms_key_id = var.platform.kms_alias_primary.target_key_arn
skip_destroy = strcontains(local.env, "prod") ? true : false
retention_in_days = var.log_retention_days
module "function_logs" {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in some ways, this naming is nice because it's descriptive. if you want to keep it consistent, though, so you could do a quick find and replace across all modules, might work to do "log_group" or something or match the module name directly

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partially agree, though a single uniform name won't work since the service module has two instances (app_logs, datadog_logs).

service_name = coalesce(var.service_name_override, var.platform.service)
service_name_full = "${var.platform.app}-${var.platform.env}-${local.service_name}"

app_log_group_name = "/aws/ecs/fargate/${var.platform.app}-${var.platform.env}/${local.service_name}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be sure to verify this works with "parent_env" for ephemeral environments, assuming their logs get split up for analysis.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

${var.platform.env} already splits log groups per ephemeral env, so this line should be good. But this surfaced three issues which are now fixed in this PR: the cloudwatch_log_group env validation rejected ephemeral names, the log-retention SSM lookups needed a parent-env suffix match, and the GHA-role log ARN patterns didn't match ephemeral names.

@mianava mianava left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small items to validate, otherwise looks good to me!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants