terraform-aws-modules / terraform-aws-lambda

Terraform module, which takes care of a lot of AWS Lambda/serverless tasks (build dependencies, packages, updates, deployments) in countless combinations 🇺🇦
https://registry.terraform.io/modules/terraform-aws-modules/lambda/aws
Apache License 2.0
886 stars 657 forks source link

Use Custom (already existing) Cloudwatch Log group for Lambda Function #411

Closed BetterToAutomateTheWorld closed 1 year ago

BetterToAutomateTheWorld commented 1 year ago

Is your request related to a new offering from AWS?

No, Lambda Function and Cloudwatch Log group isn't something new

Is your request related to a problem? Please describe.

When "use_existing_cloudwatch_log_group" is set to false, we want to be able to set our own Cloudwatch log group as Lambda function dependency (to be able to output logs to a custom cloudwatch log group, we're only using one as a combined/shared one in our case because of monitoring tool limitations)

From what i see, we don't any way in this module to edit the "depends_on" list, i wanted to put, instead of :

Describe the solution you'd like.

To use already existing cloudwatch_log_group for the lambda function log feature, to send the lambda function module logs to it

The simple feature to add (i can even do a quick PR for it) is to be able to add a custom line to the depends_on, since adding a cloudwatch log group dependency in this list from within a terraform "aws_lambda_function" call, grants the possibility for the Lambda Function to write

Describe alternatives you've considered.

None, it's mandatory from my side (Monitoring integration looking for only one cloudwatch log group)

Additional context

N/A

tculp commented 1 year ago

We also would like to have multiple functions that log to the same existing log group. An additional var like cloudwatch_log_group_name could be used to set the name of the log group if use_existing_cloudwatch_log_group is false, or could be used for the data source if use_existing_cloudwatch_log_group is true. Thoughts?

antonbabenko commented 1 year ago

You can't customize the name of the CW log group used for Lambda function. Each Lambda function writes logs to its own CW log group.

See also: https://github.com/terraform-aws-modules/terraform-aws-lambda/issues/342#issuecomment-1216317042

BetterToAutomateTheWorld commented 1 year ago

What a shame ! Thank you for your quick reply, sorry it was already asked but i didn't find it...

--> Let's open an AWS case to request this feature then :)

github-actions[bot] commented 1 year ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.