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

Malformed log group name when used with terraform-aws-lambda-function #52

Open
MReggler opened this issue Feb 20, 2024 · 0 comments
Open
Labels
bug 🐛 An issue with the system

Comments

@MReggler
Copy link

MReggler commented Feb 20, 2024

Describe the Bug

When using terraform-aws-lambda-function to create a lambda and associated log group, the resulting log groups can in some cases not match the function name, which results in no logs being sent to the created group.

Expected Behavior

I create a lambda using the terraform-aws-lambda-function module, and the name of this lambda contains an underscore

module "lambda" {
  source  = "cloudposse/lambda-function/aws"
  version = "0.5.3"

  function_name      = "my_function_name"
  ...

  context = module.this.context
}

The resultant log group created by this module should be called /aws/lambda/my_function_name.

Instead the log group created is called /aws/lambda/myfunctionname, as the label for the log group contains a regex_replace_chars rule that does not allow for underscores.

This means the AWS creates its own log group (with default config like no expiration) for the lambda, and the log group created by this module is orphaned.

https://github.com/cloudposse/terraform-aws-cloudwatch-logs/blob/f622326cce042d0e49b2613cc994ab710355ac7f/main.tf#L5C1-L13C2

Steps to Reproduce

Invoke the lambda module with var.function_name set to a value that includes an underscore.

Screenshots

Screenshot 2024-02-20 at 16 32 36

Environment

v0.6.6 -- version of the module used in the lambda module -- IS AFFECTED
v0.6.8 -- current version of the module -- IS AFFECTED

Additional Context

This fix requires a bump to the version of the cloudwatch logs module used in the lambda module (and/or anywhere else in the CloudPosse module/component libraries that support the creation of resources with underscores in their names.

@MReggler MReggler added the bug 🐛 An issue with the system label Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An issue with the system
Projects
None yet
Development

No branches or pull requests

1 participant