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

fix: Use existing CloudWatch log group to avoid duplication #98

Closed
wants to merge 2 commits into from

Conversation

paul-pop
Copy link
Contributor

Description

Both this module and terraform-aws-lambda create a CloudWatch log group with the same name but different tags so they get duplicated hence throwing an error on creation.

Motivation and Context

Fixes #97

Breaking Changes

N/A

How Has This Been Tested?

  • Ran the usual pre-commit checks
  • I've used my fork version and ran a terraform plan which now only creates one CloudWatch log group

attach_cloudwatch_logs_policy = false
attach_policy_json = true
policy_json = element(concat(data.aws_iam_policy_document.lambda[*].json, [""]), 0)
use_existing_cloudwatch_log_group = aws_cloudwatch_log_group.lambda.name != "" ? true : false
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need to wait for the log group to be created first because the lambda module fetches this using a data source:

data "aws_cloudwatch_log_group" "lambda" {
  count = var.create && var.create_function && ! var.create_layer && var.use_existing_cloudwatch_log_group ? 1 : 0

  name = "/aws/lambda/${var.lambda_at_edge ? "us-east-1." : ""}${var.function_name}"
}

@antonbabenko
Copy link
Member

Closing this one in favor of #99 where this problem has been solved.

@github-actions
Copy link

github-actions bot commented Nov 9, 2022

I'm going to lock this pull request 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 related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bug] CloudWatch log group gets created twice and throws an error
3 participants