Skip to content

PLT-1773 : Implement core log-retention service - #615

Open
jasonvinson wants to merge 3 commits into
mainfrom
PLT-1773/log-retention-core-service
Open

jasonvinson wants to merge 3 commits into
mainfrom
PLT-1773/log-retention-core-service

Conversation

@jasonvinson

Copy link
Copy Markdown
Contributor

🎫 Ticket

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

🛠 Changes

  • new long-term-retention S3 bucket
  • new Kinesis Firehose stream to deliver logs to S3
  • new dedicated KMS key

ℹ️ Context

We currently run a script periodically to enforce long-term log retention. We want to support this HIPAA requirement natively so that all resources created through Tofu comply in a standardized fashion.

🧪 Validation

Plans successfully targeting test. Will validate further once deployed to test env.

@jasonvinson
jasonvinson requested a review from a team as a code owner September 14, 2026 21:55
Comment thread terraform/modules/bucket/main.tf
Comment thread terraform/modules/bucket/variables.tf Outdated
@@ -0,0 +1,283 @@
locals {
firehose_name = "${var.app}-${var.env}-long-term-log-retention"

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.

This makes sense because our pattern is cdap-test-* for various shared services. Do you think, though, there's a better name that would mean this doesn't get confused for being just cdap related logs? This should be all service logs

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.

I added a new "shared" naming convention here. Wondering if "common" would fit our patterns better...but I felt "shared" was best for clarity. Would love your thoughts on this!

Comment thread terraform/services/701-long-term-log-retention/firehose.tf Outdated
policy = data.aws_iam_policy_document.log_retention_kms.json
}

resource "aws_kms_alias" "log_retention" {

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.

This alias implies that it's not a CDAP specific key, so per above comment, match the naming or the sorting convention. If we keep this all under "CDAP" as it's a platform service, then this should probably use the cdap-$env key per convention, and not get its own dedicated key. This would mean that when we have automated rotation with that key, we get this "for free" and the logs just start rotating.

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.

Updated to cdap-$env-log-retention

Comment thread terraform/services/701-long-term-log-retention/main.tf Outdated
Comment thread terraform/services/701-long-term-log-retention/main.tf Outdated
@@ -0,0 +1 @@
TARGET_ENVS="cdap-test cdap-prod"

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.

Lets make sure we firm up this pipeline fully in cdap-test before provisioning to prod with compliance mode to 6 years. Leave just as "cdap-test" until the work is complete and evaluated in cdap-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.

It might make sense, for testing and development purposes, to set up a config/.yml with variables here

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.

Agreed! I removed references to prod for now.

statement {
sid = "DeliveryErrorLogging"
actions = ["logs:PutLogEvents"]
resources = ["${aws_cloudwatch_log_group.firehose.arn}:log-stream:*"]

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.

Does this log group have to be individually created or can we leverage the cloudwatch log group module, noting that... those logs themselves will end up in this firehose.

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.

Updated to use the cloudwatch log group module.

Comment thread terraform/services/701-long-term-log-retention/firehose.tf Outdated
Comment thread terraform/services/701-long-term-log-retention/firehose.tf Outdated
Comment on lines +225 to +232
alarm_name = "${local.firehose_name}-s3-delivery-failure"
alarm_description = "Firehose is failing to deliver log records to the long-term retention bucket"
namespace = "AWS/Firehose"
metric_name = "DeliveryToS3.Success"
statistic = "Average"
period = 300
evaluation_periods = 3
threshold = 1

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.

This likely makes sense, though I'm curious if there's something in DataDog we could leverage instead.

- 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
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