terraform-aws-modules / terraform-aws-s3-bucket

Terraform module to create AWS S3 resources πŸ‡ΊπŸ‡¦

Home Page:https://registry.terraform.io/modules/terraform-aws-modules/s3-bucket/aws

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

S3 bucket notification to Lambda

bfedorov-clgx opened this issue Β· comments

Description

Hello!
When Itry to create S33 bucket with notification to Lambda Igabe a issue.

Code

`module "s3_bucket" {
source = "terraform-aws-modules/s3-bucket/aws"

for_each = var.buckets

bucket = lookup(each.value, "bucket")
acl = lookup(each.value, "acl")
control_object_ownership = lookup(each.value, "control_object_ownership")
object_ownership = lookup(each.value, "object_ownership")
versioning = lookup(each.value, "versioning")
force_destroy = true
}

module "all_notifications" {
source = "../../modules/notification"

bucket = module.s3_bucket["source_bucket"].bucket

eventbridge = true

Common error - Error putting S3 notification configuration: InvalidArgument: Configuration is ambiguously defined. Cannot have overlapping suffixes in two rules if the prefixes are overlapping for the same event type.

lambda_notifications = {
lambda1 = {
function_name = module.lambda["function1"].function_name
events = ["s3:ObjectCreated:*"]
}
}
} `

issue

18:24:23 Initializing modules... 18:24:23 - all_notifications in 18:24:23 Downloading terraform-aws-modules/lambda/aws 5.3.0 for lambda... 18:24:23 - lambda in .terraform/modules/lambda 18:24:23 Downloading terraform-aws-modules/s3-bucket/aws 3.14.0 for s3_bucket... 18:24:24 - s3_bucket in .terraform/modules/s3_bucket 18:24:24 β•· 18:24:24 β”‚ Error: Unreadable module directory 18:24:24 β”‚ 18:24:24 β”‚ Unable to evaluate directory symlink: lstat ../../modules: no such file or 18:24:24 β”‚ directory 18:24:24 β•΅ 18:24:24 18:24:24 β•· 18:24:24 β”‚ Error: Failed to read module directory 18:24:24 β”‚ 18:24:24 β”‚ Module directory does not exist or cannot be read. 18:24:24 β•΅ 18:24:24

Change module source from:

source = "../../modules/notification"

to

source = "terraform-aws-modules/s3-bucket/aws//modules/notification"

Thanks a lot!

hello @antonbabenko

which version of Lambda module should I use in order to avoid this failure?
Everything is deployed and working but Jenkins job didn't succed

16:22:23 β”‚ Error: adding Lambda Permission (lambda-function/AllowExecutionFromS3Bucket): InvalidParameterValueException: We currently do not support adding policies for $LATEST.
16:22:23 β”‚ {
16:22:23 β”‚ RespMetadata: {
16:22:23 β”‚ StatusCode: 400,
16:22:23 β”‚ RequestID: "08293542-9973-4d17-b494-cfa3f47ae01b"
16:22:23 β”‚ },
16:22:23 β”‚ Message_: "We currently do not support adding policies for $LATEST.",
16:22:23 β”‚ Type: "User"
16:22:23 β”‚ }
16:22:23 β”‚
16:22:23 β”‚ with module.lambda["function1"].aws_lambda_permission.current_version_triggers["AllowExecutionFromS3Bucket"],
16:22:23 β”‚ on .terraform/modules/lambda/main.tf line 206, in resource "aws_lambda_permission" "current_version_triggers":
16:22:23 β”‚ 206: resource "aws_lambda_permission" "current_version_triggers" {
16:22:23 β”‚
16:22:23 β•΅

@bofedorov-clgx You should set create_current_version_allowed_triggers = false in the Lambda module

https://github.com/terraform-aws-modules/terraform-aws-lambda/blob/master/variables.tf#L367-L371