diff --git a/README.md b/README.md
index 6f6f7a19..bf847486 100644
--- a/README.md
+++ b/README.md
@@ -742,6 +742,7 @@ No modules.
| [assume\_role\_policy\_statements](#input\_assume\_role\_policy\_statements) | Map of dynamic policy statements for assuming Lambda Function role (trust relationship) | `any` | `{}` | no |
| [attach\_async\_event\_policy](#input\_attach\_async\_event\_policy) | Controls whether async event policy should be added to IAM role for Lambda Function | `bool` | `false` | no |
| [attach\_cloudwatch\_logs\_policy](#input\_attach\_cloudwatch\_logs\_policy) | Controls whether CloudWatch Logs policy should be added to IAM role for Lambda Function | `bool` | `true` | no |
+| [attach\_create\_log\_group\_permission](#input\_attach\_create\_log\_group\_permission) | Controls whether to add the create log group permission to the CloudWatch logs policy | `bool` | `true` | no |
| [attach\_dead\_letter\_policy](#input\_attach\_dead\_letter\_policy) | Controls whether SNS/SQS dead letter notification policy should be added to IAM role for Lambda Function | `bool` | `false` | no |
| [attach\_network\_policy](#input\_attach\_network\_policy) | Controls whether VPC/network policy should be added to IAM role for Lambda Function | `bool` | `false` | no |
| [attach\_policies](#input\_attach\_policies) | Controls whether list of policies should be added to IAM role for Lambda Function | `bool` | `false` | no |
diff --git a/examples/complete/README.md b/examples/complete/README.md
index 28e5b37a..0fa68c62 100644
--- a/examples/complete/README.md
+++ b/examples/complete/README.md
@@ -40,6 +40,7 @@ Note that this example may create resources which cost money. Run `terraform des
| [lambda\_function](#module\_lambda\_function) | ../../ | n/a |
| [lambda\_function\_existing\_package\_local](#module\_lambda\_function\_existing\_package\_local) | ../../ | n/a |
| [lambda\_function\_for\_each](#module\_lambda\_function\_for\_each) | ../../ | n/a |
+| [lambda\_function\_no\_create\_log\_group\_permission](#module\_lambda\_function\_no\_create\_log\_group\_permission) | ../../ | n/a |
| [lambda\_function\_with\_package\_deploying\_externally](#module\_lambda\_function\_with\_package\_deploying\_externally) | ../../ | n/a |
| [lambda\_layer\_local](#module\_lambda\_layer\_local) | ../../ | n/a |
| [lambda\_layer\_s3](#module\_lambda\_layer\_s3) | ../../ | n/a |
diff --git a/examples/complete/main.tf b/examples/complete/main.tf
index 0f2d0a8c..62e51084 100644
--- a/examples/complete/main.tf
+++ b/examples/complete/main.tf
@@ -372,6 +372,23 @@ module "lambda_function_with_package_deploying_externally" {
ignore_source_code_hash = true
}
+####################################################
+# Lambda Function no create log group permission
+####################################################
+
+module "lambda_function_no_create_log_group_permission" {
+ source = "../../"
+
+ function_name = "${random_pet.this.id}-lambda-no-create-log-group-permission"
+ handler = "index.lambda_handler"
+ runtime = "python3.8"
+
+ create_package = false
+ local_existing_package = "../fixtures/python3.8-zip/existing_package.zip"
+
+ attach_create_log_group_permission = false
+}
+
###########
# Disabled
###########
diff --git a/iam.tf b/iam.tf
index 0436a4a4..436a4398 100644
--- a/iam.tf
+++ b/iam.tf
@@ -122,7 +122,7 @@ data "aws_iam_policy_document" "logs" {
effect = "Allow"
actions = compact([
- !var.use_existing_cloudwatch_log_group ? "logs:CreateLogGroup" : "",
+ !var.use_existing_cloudwatch_log_group && var.attach_create_log_group_permission ? "logs:CreateLogGroup" : "",
"logs:CreateLogStream",
"logs:PutLogEvents"
])
diff --git a/variables.tf b/variables.tf
index b1713c82..61198bea 100644
--- a/variables.tf
+++ b/variables.tf
@@ -494,6 +494,12 @@ variable "attach_cloudwatch_logs_policy" {
default = true
}
+variable "attach_create_log_group_permission" {
+ description = "Controls whether to add the create log group permission to the CloudWatch logs policy"
+ type = bool
+ default = true
+}
+
variable "attach_dead_letter_policy" {
description = "Controls whether SNS/SQS dead letter notification policy should be added to IAM role for Lambda Function"
type = bool
diff --git a/wrappers/main.tf b/wrappers/main.tf
index d842223d..1ae65252 100644
--- a/wrappers/main.tf
+++ b/wrappers/main.tf
@@ -9,6 +9,7 @@ module "wrapper" {
assume_role_policy_statements = try(each.value.assume_role_policy_statements, var.defaults.assume_role_policy_statements, {})
attach_async_event_policy = try(each.value.attach_async_event_policy, var.defaults.attach_async_event_policy, false)
attach_cloudwatch_logs_policy = try(each.value.attach_cloudwatch_logs_policy, var.defaults.attach_cloudwatch_logs_policy, true)
+ attach_create_log_group_permission = try(each.value.attach_create_log_group_permission, var.defaults.attach_create_log_group_permission, true)
attach_dead_letter_policy = try(each.value.attach_dead_letter_policy, var.defaults.attach_dead_letter_policy, false)
attach_network_policy = try(each.value.attach_network_policy, var.defaults.attach_network_policy, false)
attach_policies = try(each.value.attach_policies, var.defaults.attach_policies, false)