Created
June 27, 2022 12:17
-
-
Save nhammad/7240c5bc16fcbd75c7f37ca8a4423efb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data "aws_s3_bucket" "run_pipeline" { | |
bucket = local.bucket_name | |
} | |
resource "aws_s3_bucket_notification" "run_pipeline" { | |
bucket = data.aws_s3_bucket.run_pipeline.id | |
lambda_function { | |
lambda_function_arn = aws_lambda_function.processing_lambda.arn | |
events = ["s3:ObjectCreated:*", "s3:ObjectRemoved:*", "s3:ObjectRestore:*"] | |
filter_prefix = local.s3_prefix | |
filter_suffix = local.s3_suffix | |
} | |
depends_on = [aws_lambda_permission.allow_s3_to_run_lambda] | |
} | |
resource "aws_lambda_permission" "allow_s3_to_run_lambda" { | |
statement_id = "AllowExecutionFromS3Bucket" | |
action = "lambda:InvokeFunction" | |
function_name = aws_lambda_function.processing_lambda.arn | |
principal = "s3.amazonaws.com" | |
source_arn = data.aws_s3_bucket.run_pipeline.arn | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment