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

Add variable to manage the CreateLogGroup permission #503

Closed
jake-naughton opened this issue Oct 11, 2023 · 5 comments · Fixed by #514
Closed

Add variable to manage the CreateLogGroup permission #503

jake-naughton opened this issue Oct 11, 2023 · 5 comments · Fixed by #514

Comments

@jake-naughton
Copy link
Contributor

Is your request related to a new offering from AWS?

  • Already exists.

Is your request related to a problem? Please describe.

I have to manage IAM roles outside of this module because it enforces logs:CreateLogGroup permission when the module provisions the CloudWatch log group. However, there are many cases where you don't need or want this permission attached to your lambda and it is a nuisance when you are dealing with ephemeral environments. The problem is described in this issue:
#342

Describe the solution you'd like.

To add a variable that allows for the logs:CreateLogGroup to be turned off even when the module is responsible for provisioning the CloudWatch logs. By default it would be on so no change in behaviour.

variable "attach_create_log_group_permission" {
  description = "..."
  type             = bool
  default        = true
}

data "aws_iam_policy_document" "logs" {
  count = local.create_role && var.attach_cloudwatch_logs_policy ? 1 : 0

  statement {
    effect = "Allow"

    actions = compact([
      !var.use_existing_cloudwatch_log_group && var.attach_create_log_group_permission ? "logs:CreateLogGroup" : "",
      "logs:CreateLogStream",
      "logs:PutLogEvents"
    ])

    resources = flatten([for _, v in ["%v:*", "%v:*:*"] : format(v, local.log_group_arn)])
  }
}

Describe alternatives you've considered.

Creating my own IAM role outside of the module and passing it in. Could also create the CloudWatch log group outside of the module.

Additional context

Happy to put up a PR for this improvement if it is acceptable.

Copy link

This issue has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this issue will be closed in 10 days

@github-actions github-actions bot added the stale label Nov 13, 2023
@jake-naughton
Copy link
Contributor Author

Any thoughts on this?

@antonbabenko
Copy link
Member

Hi @jake-naughton !

Please make a PR with the proposed change.

@jake-naughton
Copy link
Contributor Author

Hi @antonbabenko, I have raised the PR here: #514

Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 23, 2023
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 a pull request may close this issue.

2 participants