-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.tf
68 lines (59 loc) · 1.64 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Managed By : CloudDrove
# Terraform module to create Lambda resource on AWS for sending notification when anything done from console in AWS.
# Copyright @ CloudDrove. All Right Reserved.
resource "null_resource" "main" {
count = var.enabled ? 1 : 0
provisioner "local-exec" {
command = format("cd %s/slack && bash build.sh", path.module)
}
}
#Module : Cloudtrail Logs
#Description : This terraform module is designed to create cloudtrail log.
module "cloudtrail-slack" {
source = "clouddrove/lambda/aws"
version = "1.3.1"
name = var.name
repository = var.repository
environment = var.environment
managedby = var.managedby
attributes = var.attributes
label_order = var.label_order
filename = format("%s/slack/src", path.module)
handler = "index.handler"
runtime = "python3.7"
iam_actions = [
"logs:CreateLogStream",
"logs:CreateLogGroup",
"logs:PutLogEvents",
"s3:*"
]
timeout = 30
names = [
"python_layer"
]
layer_filenames = [format("%s/slack/packages/Python3-slack.zip", path.module)]
compatible_runtimes = [
["python3.8"]
]
statement_ids = [
"AllowExecutionFromS3Bucket"
]
actions = [
"lambda:InvokeFunction"
]
principals = [
"s3.amazonaws.com"
]
source_arns = [var.bucket_arn]
variables = var.variables
}
resource "aws_s3_bucket_notification" "bucket_notification" {
count = var.enabled ? 1 : 0
bucket = var.bucket_name
lambda_function {
lambda_function_arn = module.cloudtrail-slack.arn
events = ["s3:ObjectCreated:*"]
filter_prefix = var.filter_prefix
filter_suffix = var.filter_suffix
}
}