forked from phzietsman/aws-slack-clickoops-watcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlambda.tf
51 lines (39 loc) · 1.28 KB
/
lambda.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
resource "aws_lambda_function" "func" {
function_name = local.naming_prefix
role = aws_iam_role.lambda.arn
handler = "main.handler"
runtime = "python3.8"
filename = data.archive_file.func.output_path
source_code_hash = filebase64sha256(data.archive_file.func.output_path)
timeout = var.event_processing_timeout
memory_size = 128
layers = [local.python_layers[var.region]]
environment {
variables = {
WEBHOOK_PARAMETER = aws_ssm_parameter.slack_webhook.name
EXCLUDED_ACCOUNTS = jsonencode(var.excluded_accounts)
INCLUDED_ACCOUNTS = jsonencode(var.included_accounts)
}
}
}
data "archive_file" "func" {
type = "zip"
source_dir = "${path.module}/lambda"
output_file_mode = "0666"
output_path = "${path.module}/lambda.zip"
}
resource "aws_lambda_event_source_mapping" "bucket_notifications" {
event_source_arn = aws_sqs_queue.bucket_notifications.arn
function_name = aws_lambda_function.func.arn
}
resource "aws_ssm_parameter" "slack_webhook" {
name = "/${local.naming_prefix}/slack-webhook"
description = "Slack Incomming Webhook. https://api.slack.com/messaging/webhooks"
type = "SecureString"
value = "REPLACE_ME"
lifecycle {
ignore_changes = [
value,
]
}
}