-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.tf
37 lines (31 loc) · 906 Bytes
/
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
resource "aws_lambda_function" "main" {
filename = data.archive_file.source.output_path
role = aws_iam_role.lambda.arn
source_code_hash = data.archive_file.source.output_base64sha256
runtime = var.runtime
handler = local.handler
description = "Lambda SNS to Chat Notifications"
function_name = var.name
memory_size = var.memory_size
timeout = var.timeout
tracing_config {
mode = var.tracing_config
}
tags = merge(
var.tags,
map(
"Name", var.name,
"Workspace", terraform.workspace
)
)
lifecycle {
ignore_changes = [filename]
}
}
resource "aws_lambda_permission" "with_sns" {
statement_id = "AllowExecutionFromSNS"
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.main.function_name
principal = "sns.amazonaws.com"
source_arn = aws_sns_topic.main.arn
}