Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for redaction and regex patterns #74

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions modules/s3-logfile/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ module "s3_processor" {
}


environment_variables = {
environment_variables = merge({
Copy link
Contributor

Choose a reason for hiding this comment

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

Which set of variables wins, first or second?

Copy link
Author

Choose a reason for hiding this comment

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

According to the Terraform docs the second set wins. I don't have a strong opinion on which order is better and would happily move the extra_env_vars first to avoid accidental/intentional overrides.

If more than one given map or object defines the same key or attribute, then the one that is later in the argument sequence takes precedence.

PARSER_TYPE = var.parser_type
FORCE_GUNZIP = true
ENVIRONMENT = var.environment
Expand All @@ -66,7 +66,9 @@ module "s3_processor" {
SAMPLE_RATE_RULES = jsonencode(var.sample_rate_rules)
FILTER_FIELDS = join(",", var.filter_fields)
RENAME_FIELDS = join(",", [for k, v in var.rename_fields : "${k}=${v}"])
}
REDACT_PATTERN = var.redact_pattern
REGEX_PATTERN = var.regex_pattern
}, var.extra_env_vars)

attach_policy = true
policy = aws_iam_policy.lambda.arn
Expand Down
18 changes: 18 additions & 0 deletions modules/s3-logfile/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,24 @@ variable "rename_fields" {
default = {}
}

variable "redact_pattern" {
type = string
description = "A regex pattern to redact sensitive information from the request field. Default is to redact nothing. All groups in the pattern will be replaced with a corresponding number of 'x' characters."
default = ""
}

variable "regex_pattern" {
description = "with `PARSER_TYPE=regex`, will define the regular expression to use for parsing each line in the log file. Honeycomb columns are generated by defining named capture groups. For example, `(?P<name>[a-z]+)` would create a column called 'name' if successfully parsed."
type = string
default = ""
}

variable "extra_env_vars" {
type = map(string)
description = "Extra environment variables to set in the Lambda function."
default = {}
}

variable "s3_bucket_arn" {
type = string
description = "The full ARN of the bucket storing load balancer access logs."
Expand Down
Loading