terraform-aws-modules/terraform-aws-lambda

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

BetterToAutomateTheWorld opened this issue · 4 comments

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 :

  • aws_cloudwatch_log_group.example,
    this line
  • module.landing.cloudwatch_TEAM_log_group,
    Because we use a standard / shared log group for all of our AWS resources, our monitoring tool can only grab one cloudwatch_log_group (yeah, it sucks), our logs are inside the same Cloudwatch log group (already existing), and the json payload of each logs line contains attributes to be differentiated in the monitoring tool, so it's fine this way.

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

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?

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: #342 (comment)

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

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.